OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." |
| 7 #endif |
| 8 |
| 9 #import "remoting/ios/app/session_reconnect_view.h" |
| 10 |
| 11 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
| 12 #import "remoting/ios/app/remoting_theme.h" |
| 13 |
| 14 static const CGFloat kReconnectButtonWidth = 120.f; |
| 15 static const CGFloat kReconnectButtonHeight = 30.f; |
| 16 |
| 17 @interface SessionReconnectView () { |
| 18 MDCRaisedButton* _reconnectButton; |
| 19 } |
| 20 @end |
| 21 |
| 22 @implementation SessionReconnectView |
| 23 |
| 24 @synthesize delegate = _delegate; |
| 25 |
| 26 - (id)initWithFrame:(CGRect)frame { |
| 27 self = [super initWithFrame:frame]; |
| 28 if (self) { |
| 29 self.backgroundColor = [UIColor clearColor]; |
| 30 |
| 31 _reconnectButton = [[MDCRaisedButton alloc] init]; |
| 32 [_reconnectButton setElevation:4.0f forState:UIControlStateNormal]; |
| 33 [_reconnectButton setTitle:@"Reconnect" forState:UIControlStateNormal]; |
| 34 [_reconnectButton addTarget:self |
| 35 action:@selector(didTapReconnect:) |
| 36 forControlEvents:UIControlEventTouchUpInside]; |
| 37 _reconnectButton.translatesAutoresizingMaskIntoConstraints = NO; |
| 38 [self addSubview:_reconnectButton]; |
| 39 |
| 40 [self initializeLayoutConstraintsWithViews:NSDictionaryOfVariableBindings( |
| 41 _reconnectButton)]; |
| 42 } |
| 43 return self; |
| 44 } |
| 45 |
| 46 - (void)initializeLayoutConstraintsWithViews:(NSDictionary*)views { |
| 47 NSMutableArray* layoutConstraints = [NSMutableArray array]; |
| 48 |
| 49 [layoutConstraints addObject:[_reconnectButton.centerYAnchor |
| 50 constraintEqualToAnchor:self.centerYAnchor]]; |
| 51 |
| 52 [layoutConstraints addObject:[_reconnectButton.centerXAnchor |
| 53 constraintEqualToAnchor:self.centerXAnchor]]; |
| 54 |
| 55 [layoutConstraints |
| 56 addObject:[_reconnectButton.widthAnchor |
| 57 constraintEqualToConstant:kReconnectButtonWidth]]; |
| 58 |
| 59 [layoutConstraints |
| 60 addObject:[_reconnectButton.heightAnchor |
| 61 constraintEqualToConstant:kReconnectButtonHeight]]; |
| 62 |
| 63 [NSLayoutConstraint activateConstraints:layoutConstraints]; |
| 64 [self setNeedsUpdateConstraints]; |
| 65 } |
| 66 |
| 67 #pragma mark - Private |
| 68 |
| 69 - (void)didTapReconnect:(id)sender { |
| 70 if ([_delegate respondsToSelector:@selector(didTapReconnect)]) { |
| 71 [_delegate didTapReconnect]; |
| 72 } |
| 73 } |
| 74 |
| 75 @end |
OLD | NEW |