Chromium Code Reviews| 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_error_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 kMargin = 5.f; | |
|
Yuwei
2017/07/05 21:43:42
What are these commented numbers for?
nicholss
2017/07/06 20:49:02
gone.
| |
| 15 // static const CGFloat kPadding = 8.f; | |
| 16 // static const CGFloat kLineSpace = 12.f; | |
| 17 static const CGFloat kReconnectButtonWidth = 120.f; | |
| 18 static const CGFloat kReconnectButtonHeight = 30.f; | |
| 19 | |
| 20 @interface SessionErrorView () { | |
| 21 MDCRaisedButton* _reconnectButton; | |
| 22 } | |
| 23 @end | |
| 24 | |
| 25 @implementation SessionErrorView | |
| 26 | |
| 27 @synthesize delegate = _delegate; | |
| 28 | |
| 29 - (id)initWithFrame:(CGRect)frame { | |
| 30 self = [super initWithFrame:frame]; | |
| 31 if (self) { | |
| 32 self.backgroundColor = [UIColor clearColor]; | |
| 33 | |
| 34 _reconnectButton = [[MDCRaisedButton alloc] init]; | |
| 35 [_reconnectButton setElevation:4.0f forState:UIControlStateNormal]; | |
| 36 [_reconnectButton setTitle:@"Reconnect" forState:UIControlStateNormal]; | |
| 37 [_reconnectButton addTarget:self | |
| 38 action:@selector(didTapReconnect:) | |
| 39 forControlEvents:UIControlEventTouchUpInside]; | |
| 40 [self addSubview:_reconnectButton]; | |
| 41 } | |
| 42 return self; | |
| 43 } | |
| 44 | |
| 45 #pragma mark - UIView | |
| 46 | |
| 47 - (void)layoutSubviews { | |
| 48 [super layoutSubviews]; | |
| 49 _reconnectButton.frame = | |
| 50 CGRectMake((self.frame.size.width - kReconnectButtonWidth) / 2.f, 0, | |
|
Yuwei
2017/07/05 21:43:42
Will it be simpler to do self.center.x - kReconnec
nicholss
2017/07/06 20:49:02
Used autolayout
| |
| 51 kReconnectButtonWidth, kReconnectButtonHeight); | |
| 52 } | |
| 53 | |
| 54 #pragma mark - Private | |
| 55 | |
| 56 - (void)didTapReconnect:(id)sender { | |
| 57 if ([_delegate respondsToSelector:@selector(didTapReconnect)]) { | |
| 58 [_delegate didTapReconnect]; | |
| 59 } | |
| 60 } | |
| 61 | |
| 62 @end | |
| OLD | NEW |