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 |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 static const CGFloat kPinEntryViewWidth = 240.f; | 25 static const CGFloat kPinEntryViewWidth = 240.f; |
26 static const CGFloat kPinEntryViewHeight = 90.f; | 26 static const CGFloat kPinEntryViewHeight = 90.f; |
27 | 27 |
28 static const CGFloat kCenterShift = -80.f; | 28 static const CGFloat kCenterShift = -80.f; |
29 static const CGFloat kPadding = 20.f; | 29 static const CGFloat kPadding = 20.f; |
30 static const CGFloat kMargin = 20.f; | 30 static const CGFloat kMargin = 20.f; |
31 | 31 |
32 static const CGFloat kBarHeight = 58.f; | 32 static const CGFloat kBarHeight = 58.f; |
33 | 33 |
| 34 static const CGFloat kKeyboardAnimationTime = 0.3; |
| 35 |
34 @interface ClientConnectionViewController ()<PinEntryDelegate> { | 36 @interface ClientConnectionViewController ()<PinEntryDelegate> { |
35 UIImageView* _iconView; | 37 UIImageView* _iconView; |
36 MDCActivityIndicator* _activityIndicator; | 38 MDCActivityIndicator* _activityIndicator; |
37 UILabel* _statusLabel; | 39 UILabel* _statusLabel; |
38 MDCNavigationBar* _navBar; | 40 MDCNavigationBar* _navBar; |
39 PinEntryView* _pinEntryView; | 41 PinEntryView* _pinEntryView; |
40 NSString* _remoteHostName; | 42 NSString* _remoteHostName; |
41 } | 43 } |
42 @end | 44 @end |
43 | 45 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 - (void)viewWillDisappear:(BOOL)animated { | 170 - (void)viewWillDisappear:(BOOL)animated { |
169 [super viewWillDisappear:animated]; | 171 [super viewWillDisappear:animated]; |
170 [_activityIndicator stopAnimating]; | 172 [_activityIndicator stopAnimating]; |
171 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 173 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
172 } | 174 } |
173 | 175 |
174 #pragma mark - Keyboard | 176 #pragma mark - Keyboard |
175 | 177 |
176 - (void)keyboardWillShow:(NSNotification*)notification { | 178 - (void)keyboardWillShow:(NSNotification*)notification { |
177 CGSize keyboardSize = | 179 CGSize keyboardSize = |
178 [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] | 180 [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] |
179 CGRectValue] | 181 CGRectValue] |
180 .size; | 182 .size; |
181 | 183 |
182 [UIView | 184 [UIView |
183 animateWithDuration:0.3 | 185 animateWithDuration:kKeyboardAnimationTime |
184 animations:^{ | 186 animations:^{ |
185 CGRect f = self.view.frame; | 187 CGRect f = self.view.frame; |
186 CGFloat newHeight = | 188 CGFloat newHeight = |
187 self.view.frame.size.height - keyboardSize.height; | 189 self.view.frame.size.height - keyboardSize.height; |
188 CGFloat overlap = | 190 CGFloat overlap = |
189 newHeight - (_pinEntryView.frame.origin.y + | 191 newHeight - (_pinEntryView.frame.origin.y + |
190 _pinEntryView.frame.size.height + kPadding); | 192 _pinEntryView.frame.size.height + kPadding); |
191 if (overlap < 0) { | 193 if (overlap < 0) { |
192 f.origin.y = overlap; | 194 f.origin.y = overlap; |
193 self.view.frame = f; | 195 self.view.frame = f; |
194 } | 196 } |
195 }]; | 197 }]; |
196 } | 198 } |
197 | 199 |
198 - (void)keyboardWillHide:(NSNotification*)notification { | 200 - (void)keyboardWillHide:(NSNotification*)notification { |
199 [UIView animateWithDuration:0.3 | 201 [UIView animateWithDuration:kKeyboardAnimationTime |
200 animations:^{ | 202 animations:^{ |
201 CGRect f = self.view.frame; | 203 CGRect f = self.view.frame; |
202 f.origin.y = 0.f; | 204 f.origin.y = 0.f; |
203 self.view.frame = f; | 205 self.view.frame = f; |
204 }]; | 206 }]; |
205 } | 207 } |
206 | 208 |
207 #pragma mark - Properties | 209 #pragma mark - Properties |
208 | 210 |
209 - (void)setState:(ClientConnectionViewState)state { | 211 - (void)setState:(ClientConnectionViewState)state { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 default: | 316 default: |
315 LOG(ERROR) << "Unknown State for Session, " << sessionDetails.state; | 317 LOG(ERROR) << "Unknown State for Session, " << sessionDetails.state; |
316 return; | 318 return; |
317 } | 319 } |
318 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ | 320 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ |
319 [self setState:state]; | 321 [self setState:state]; |
320 }]; | 322 }]; |
321 } | 323 } |
322 | 324 |
323 @end | 325 @end |
OLD | NEW |