Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2387)

Unified Diff: remoting/ios/app/session_reconnect_view.mm

Issue 2971903002: Adding error handling to the connection flow. (Closed)
Patch Set: Adding pin entry and reconnect auto-layout.: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/ios/app/session_reconnect_view.mm
diff --git a/remoting/ios/app/session_reconnect_view.mm b/remoting/ios/app/session_reconnect_view.mm
new file mode 100644
index 0000000000000000000000000000000000000000..0faaa8b348af85c75872575dfa1418fb01a5021d
--- /dev/null
+++ b/remoting/ios/app/session_reconnect_view.mm
@@ -0,0 +1,82 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+#import "remoting/ios/app/session_reconnect_view.h"
+
+#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h"
+#import "remoting/ios/app/remoting_theme.h"
+
+static const CGFloat kReconnectButtonWidth = 120.f;
+static const CGFloat kReconnectButtonHeight = 30.f;
+
+@interface SessionReconnectView () {
+ MDCRaisedButton* _reconnectButton;
+}
+@end
+
+@implementation SessionReconnectView
+
+@synthesize delegate = _delegate;
+
+- (id)initWithFrame:(CGRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ self.backgroundColor = [UIColor clearColor];
+
+ _reconnectButton = [[MDCRaisedButton alloc] init];
+ [_reconnectButton setElevation:4.0f forState:UIControlStateNormal];
+ [_reconnectButton setTitle:@"Reconnect" forState:UIControlStateNormal];
+ [_reconnectButton addTarget:self
+ action:@selector(didTapReconnect:)
+ forControlEvents:UIControlEventTouchUpInside];
+ _reconnectButton.translatesAutoresizingMaskIntoConstraints = NO;
+ [self addSubview:_reconnectButton];
+
+ [self initializeLayoutConstraintsWithViews:NSDictionaryOfVariableBindings(
+ _reconnectButton)];
+ }
+ return self;
+}
+
+- (void)initializeLayoutConstraintsWithViews:(NSDictionary*)views {
+ // Metrics to use in visual format strings.
+ NSDictionary* layoutMetrics = @{
+ @"reconnectButtonWidth" : @(kReconnectButtonWidth),
+ @"reconnectButtonHeight" : @(kReconnectButtonHeight),
+ };
+
+ [_reconnectButton.centerYAnchor constraintEqualToAnchor:self.centerYAnchor]
+ .active = YES;
+ [_reconnectButton.centerXAnchor constraintEqualToAnchor:self.centerXAnchor]
+ .active = YES;
+
+ [self addConstraints:[NSLayoutConstraint
Yuwei 2017/07/06 21:52:39 For simple constraints like this I would probably
nicholss 2017/07/06 22:15:06 Done.
Yuwei 2017/07/06 22:36:28 FYI you could simplify these with array literal if
+ constraintsWithVisualFormat:
+ @"H:[_reconnectButton(reconnectButtonWidth)]"
+ options:0
+ metrics:layoutMetrics
+ views:views]];
+
+ [self addConstraints:[NSLayoutConstraint
+ constraintsWithVisualFormat:
+ @"V:[_reconnectButton(reconnectButtonHeight)]"
+ options:0
+ metrics:layoutMetrics
+ views:views]];
+ [self setNeedsUpdateConstraints];
+}
+
+#pragma mark - Private
+
+- (void)didTapReconnect:(id)sender {
+ if ([_delegate respondsToSelector:@selector(didTapReconnect)]) {
+ [_delegate didTapReconnect];
+ }
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698