| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #import "remoting/ios/app/client_connection_view_controller.h" | 9 #import "remoting/ios/app/client_connection_view_controller.h" |
| 10 | 10 |
| 11 #import "base/mac/bind_objc_block.h" | 11 #import "base/mac/bind_objc_block.h" |
| 12 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MDCActivityIndicator.h" | 12 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MDCActivityIndicator.h" |
| 13 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" | 13 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
| 14 #import "ios/third_party/material_components_ios/src/components/NavigationBar/sr
c/MaterialNavigationBar.h" | 14 #import "ios/third_party/material_components_ios/src/components/NavigationBar/sr
c/MaterialNavigationBar.h" |
| 15 #import "remoting/ios/app/host_view_controller.h" | 15 #import "remoting/ios/app/host_view_controller.h" |
| 16 #import "remoting/ios/app/pin_entry_view.h" | 16 #import "remoting/ios/app/pin_entry_view.h" |
| 17 #import "remoting/ios/app/remoting_theme.h" |
| 17 #import "remoting/ios/domain/client_session_details.h" | 18 #import "remoting/ios/domain/client_session_details.h" |
| 18 #import "remoting/ios/domain/host_info.h" | 19 #import "remoting/ios/domain/host_info.h" |
| 19 #import "remoting/ios/facade/remoting_authentication.h" | 20 #import "remoting/ios/facade/remoting_authentication.h" |
| 20 #import "remoting/ios/facade/remoting_service.h" | 21 #import "remoting/ios/facade/remoting_service.h" |
| 21 #import "remoting/ios/session/remoting_client.h" | 22 #import "remoting/ios/session/remoting_client.h" |
| 22 | 23 |
| 23 #include "base/strings/sys_string_conversions.h" | 24 #include "base/strings/sys_string_conversions.h" |
| 24 #include "remoting/protocol/client_authentication_config.h" | 25 #include "remoting/protocol/client_authentication_config.h" |
| 25 | 26 |
| 26 static const CGFloat kIconRadius = 30.f; | 27 static const CGFloat kIconRadius = 30.f; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 forState:UIControlStateNormal]; | 80 forState:UIControlStateNormal]; |
| 80 [cancelButton addTarget:self | 81 [cancelButton addTarget:self |
| 81 action:@selector(didTapCancel:) | 82 action:@selector(didTapCancel:) |
| 82 forControlEvents:UIControlEventTouchUpInside]; | 83 forControlEvents:UIControlEventTouchUpInside]; |
| 83 self.navigationItem.leftBarButtonItem = | 84 self.navigationItem.leftBarButtonItem = |
| 84 [[UIBarButtonItem alloc] initWithCustomView:cancelButton]; | 85 [[UIBarButtonItem alloc] initWithCustomView:cancelButton]; |
| 85 | 86 |
| 86 _navBar = [[MDCNavigationBar alloc] initWithFrame:CGRectZero]; | 87 _navBar = [[MDCNavigationBar alloc] initWithFrame:CGRectZero]; |
| 87 [_navBar observeNavigationItem:self.navigationItem]; | 88 [_navBar observeNavigationItem:self.navigationItem]; |
| 88 | 89 |
| 89 [_navBar setBackgroundColor:[UIColor blackColor]]; | 90 [_navBar setBackgroundColor:RemotingTheme.connectionViewBackgroundColor]; |
| 90 MDCNavigationBarTextColorAccessibilityMutator* mutator = | 91 MDCNavigationBarTextColorAccessibilityMutator* mutator = |
| 91 [[MDCNavigationBarTextColorAccessibilityMutator alloc] init]; | 92 [[MDCNavigationBarTextColorAccessibilityMutator alloc] init]; |
| 92 [mutator mutate:_navBar]; | 93 [mutator mutate:_navBar]; |
| 93 [self.view addSubview:_navBar]; | 94 [self.view addSubview:_navBar]; |
| 94 _navBar.translatesAutoresizingMaskIntoConstraints = NO; | 95 _navBar.translatesAutoresizingMaskIntoConstraints = NO; |
| 95 | 96 |
| 96 // Attach navBar to the top of the view. | 97 // Attach navBar to the top of the view. |
| 97 [NSLayoutConstraint activateConstraints:@[ | 98 [NSLayoutConstraint activateConstraints:@[ |
| 98 [[_navBar topAnchor] constraintEqualToAnchor:[self.view topAnchor]], | 99 [[_navBar topAnchor] constraintEqualToAnchor:[self.view topAnchor]], |
| 99 [[_navBar leadingAnchor] | 100 [[_navBar leadingAnchor] |
| 100 constraintEqualToAnchor:[self.view leadingAnchor]], | 101 constraintEqualToAnchor:[self.view leadingAnchor]], |
| 101 [[_navBar trailingAnchor] | 102 [[_navBar trailingAnchor] |
| 102 constraintEqualToAnchor:[self.view trailingAnchor]], | 103 constraintEqualToAnchor:[self.view trailingAnchor]], |
| 103 [[_navBar heightAnchor] constraintEqualToConstant:kBarHeight], | 104 [[_navBar heightAnchor] constraintEqualToConstant:kBarHeight], |
| 104 ]]; | 105 ]]; |
| 105 } | 106 } |
| 106 return self; | 107 return self; |
| 107 } | 108 } |
| 108 | 109 |
| 109 #pragma mark - UIViewController | 110 #pragma mark - UIViewController |
| 110 | 111 |
| 111 - (void)loadView { | 112 - (void)loadView { |
| 112 [super loadView]; | 113 [super loadView]; |
| 113 | 114 |
| 114 self.view.backgroundColor = [UIColor blackColor]; | 115 self.view.backgroundColor = RemotingTheme.connectionViewBackgroundColor; |
| 115 | 116 |
| 116 _activityIndicator = [[MDCActivityIndicator alloc] initWithFrame:CGRectZero]; | 117 _activityIndicator = [[MDCActivityIndicator alloc] initWithFrame:CGRectZero]; |
| 117 [self.view addSubview:_activityIndicator]; | 118 [self.view addSubview:_activityIndicator]; |
| 118 | 119 |
| 119 _statusLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | 120 _statusLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
| 120 [self.view addSubview:_statusLabel]; | 121 [self.view addSubview:_statusLabel]; |
| 121 | 122 |
| 122 _iconView = [[UIImageView alloc] initWithFrame:CGRectZero]; | 123 _iconView = [[UIImageView alloc] initWithFrame:CGRectZero]; |
| 123 [self.view addSubview:_iconView]; | 124 [self.view addSubview:_iconView]; |
| 124 | 125 |
| 125 _pinEntryView = [[PinEntryView alloc] init]; | 126 _pinEntryView = [[PinEntryView alloc] init]; |
| 126 [self.view addSubview:_pinEntryView]; | 127 [self.view addSubview:_pinEntryView]; |
| 127 _pinEntryView.delegate = self; | 128 _pinEntryView.delegate = self; |
| 128 } | 129 } |
| 129 | 130 |
| 130 - (void)viewDidLoad { | 131 - (void)viewDidLoad { |
| 131 [super viewDidLoad]; | 132 [super viewDidLoad]; |
| 132 | 133 |
| 133 _iconView.contentMode = UIViewContentModeCenter; | 134 _iconView.contentMode = UIViewContentModeCenter; |
| 134 _iconView.alpha = 0.87f; | 135 _iconView.alpha = 0.87f; |
| 135 _iconView.backgroundColor = UIColor.lightGrayColor; | 136 _iconView.backgroundColor = RemotingTheme.onlineHostColor; |
| 136 _iconView.layer.cornerRadius = kIconRadius; | 137 _iconView.layer.cornerRadius = kIconRadius; |
| 137 _iconView.layer.masksToBounds = YES; | 138 _iconView.layer.masksToBounds = YES; |
| 138 _iconView.image = [UIImage imageNamed:@"ic_desktop"]; | 139 _iconView.image = [UIImage imageNamed:@"ic_desktop"]; |
| 139 | 140 |
| 140 _activityIndicator.radius = kActivityIndicatorRadius; | 141 _activityIndicator.radius = kActivityIndicatorRadius; |
| 141 _activityIndicator.trackEnabled = YES; | 142 _activityIndicator.trackEnabled = YES; |
| 142 _activityIndicator.strokeWidth = kActivityIndicatorStrokeWidth; | 143 _activityIndicator.strokeWidth = kActivityIndicatorStrokeWidth; |
| 143 _activityIndicator.cycleColors = @[ [UIColor whiteColor] ]; | 144 _activityIndicator.cycleColors = @[ UIColor.whiteColor ]; |
| 144 | 145 |
| 145 _statusLabel.numberOfLines = 1; | 146 _statusLabel.numberOfLines = 1; |
| 146 _statusLabel.lineBreakMode = NSLineBreakByTruncatingTail; | 147 _statusLabel.lineBreakMode = NSLineBreakByTruncatingTail; |
| 147 _statusLabel.textColor = [UIColor whiteColor]; | 148 _statusLabel.textColor = [UIColor whiteColor]; |
| 148 _statusLabel.textAlignment = NSTextAlignmentCenter; | 149 _statusLabel.textAlignment = NSTextAlignmentCenter; |
| 149 | 150 |
| 150 _pinEntryView.hidden = YES; | 151 _pinEntryView.hidden = YES; |
| 151 } | 152 } |
| 152 | 153 |
| 153 - (void)viewWillLayoutSubviews { | 154 - (void)viewWillLayoutSubviews { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 animateWithDuration:kKeyboardAnimationTime | 222 animateWithDuration:kKeyboardAnimationTime |
| 222 animations:^{ | 223 animations:^{ |
| 223 CGRect f = self.view.frame; | 224 CGRect f = self.view.frame; |
| 224 CGFloat newHeight = | 225 CGFloat newHeight = |
| 225 self.view.frame.size.height - keyboardSize.height; | 226 self.view.frame.size.height - keyboardSize.height; |
| 226 CGFloat overlap = | 227 CGFloat overlap = |
| 227 newHeight - (_pinEntryView.frame.origin.y + | 228 newHeight - (_pinEntryView.frame.origin.y + |
| 228 _pinEntryView.frame.size.height + kPadding); | 229 _pinEntryView.frame.size.height + kPadding); |
| 229 if (overlap < 0) { | 230 if (overlap < 0) { |
| 230 f.origin.y = overlap; | 231 f.origin.y = overlap; |
| 232 // TODO(yuweih): This may push the navigation bar off screen. |
| 231 self.view.frame = f; | 233 self.view.frame = f; |
| 232 } | 234 } |
| 233 }]; | 235 }]; |
| 234 } | 236 } |
| 235 | 237 |
| 236 - (void)keyboardWillHide:(NSNotification*)notification { | 238 - (void)keyboardWillHide:(NSNotification*)notification { |
| 237 [UIView animateWithDuration:kKeyboardAnimationTime | 239 [UIView animateWithDuration:kKeyboardAnimationTime |
| 238 animations:^{ | 240 animations:^{ |
| 239 CGRect f = self.view.frame; | 241 CGRect f = self.view.frame; |
| 240 f.origin.y = 0.f; | 242 f.origin.y = 0.f; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 _activityIndicator.hidden = NO; | 276 _activityIndicator.hidden = NO; |
| 275 _pinEntryView.hidden = YES; | 277 _pinEntryView.hidden = YES; |
| 276 [_activityIndicator startAnimating]; | 278 [_activityIndicator startAnimating]; |
| 277 } | 279 } |
| 278 | 280 |
| 279 - (void)showPinPromptState { | 281 - (void)showPinPromptState { |
| 280 _statusLabel.text = [NSString stringWithFormat:@"%@", _remoteHostName]; | 282 _statusLabel.text = [NSString stringWithFormat:@"%@", _remoteHostName]; |
| 281 [_activityIndicator stopAnimating]; | 283 [_activityIndicator stopAnimating]; |
| 282 _activityIndicator.hidden = YES; | 284 _activityIndicator.hidden = YES; |
| 283 _pinEntryView.hidden = NO; | 285 _pinEntryView.hidden = NO; |
| 286 |
| 287 // TODO(yuweih): This may be called before viewDidAppear and miss the keyboard |
| 288 // callback. |
| 284 [_pinEntryView becomeFirstResponder]; | 289 [_pinEntryView becomeFirstResponder]; |
| 285 } | 290 } |
| 286 | 291 |
| 287 - (void)showConnectedState { | 292 - (void)showConnectedState { |
| 288 [_pinEntryView endEditing:YES]; | 293 [_pinEntryView endEditing:YES]; |
| 289 _statusLabel.text = | 294 _statusLabel.text = |
| 290 [NSString stringWithFormat:@"Connected to %@", _remoteHostName]; | 295 [NSString stringWithFormat:@"Connected to %@", _remoteHostName]; |
| 291 _activityIndicator.progress = 0.0; | 296 _activityIndicator.progress = 0.0; |
| 292 _pinEntryView.hidden = YES; | 297 _pinEntryView.hidden = YES; |
| 293 _activityIndicator.hidden = NO; | 298 _activityIndicator.hidden = NO; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 default: | 355 default: |
| 351 LOG(ERROR) << "Unknown State for Session, " << sessionDetails.state; | 356 LOG(ERROR) << "Unknown State for Session, " << sessionDetails.state; |
| 352 return; | 357 return; |
| 353 } | 358 } |
| 354 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ | 359 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ |
| 355 [self setState:state]; | 360 [self setState:state]; |
| 356 }]; | 361 }]; |
| 357 } | 362 } |
| 358 | 363 |
| 359 @end | 364 @end |
| OLD | NEW |