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

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

Issue 2971903002: Adding error handling to the connection flow. (Closed)
Patch Set: Minor cleanup before review. 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_error_view.mm
diff --git a/remoting/ios/app/session_error_view.mm b/remoting/ios/app/session_error_view.mm
new file mode 100644
index 0000000000000000000000000000000000000000..33b7da4fa5e04b6767d4dd7d41ac06052fd15e36
--- /dev/null
+++ b/remoting/ios/app/session_error_view.mm
@@ -0,0 +1,62 @@
+// 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_error_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 kMargin = 5.f;
Yuwei 2017/07/05 21:43:42 What are these commented numbers for?
nicholss 2017/07/06 20:49:02 gone.
+// static const CGFloat kPadding = 8.f;
+// static const CGFloat kLineSpace = 12.f;
+static const CGFloat kReconnectButtonWidth = 120.f;
+static const CGFloat kReconnectButtonHeight = 30.f;
+
+@interface SessionErrorView () {
+ MDCRaisedButton* _reconnectButton;
+}
+@end
+
+@implementation SessionErrorView
+
+@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];
+ [self addSubview:_reconnectButton];
+ }
+ return self;
+}
+
+#pragma mark - UIView
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+ _reconnectButton.frame =
+ 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
+ kReconnectButtonWidth, kReconnectButtonHeight);
+}
+
+#pragma mark - Private
+
+- (void)didTapReconnect:(id)sender {
+ if ([_delegate respondsToSelector:@selector(didTapReconnect)]) {
+ [_delegate didTapReconnect];
+ }
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698