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

Unified Diff: remoting/client/ios/app/pin_entry_view.mm

Issue 2846603002: Updating Pin Entry View and creating Connection Status View. (Closed)
Patch Set: Use viewWillLayoutSubviews. Created 3 years, 8 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
« no previous file with comments | « remoting/client/ios/app/pin_entry_view.h ('k') | remoting/client/ios/app/pin_entry_view_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/ios/app/pin_entry_view.mm
diff --git a/remoting/client/ios/app/pin_entry_view.mm b/remoting/client/ios/app/pin_entry_view.mm
new file mode 100644
index 0000000000000000000000000000000000000000..9cfb2cd0b805e83becada75d8200a30c2f4a3140
--- /dev/null
+++ b/remoting/client/ios/app/pin_entry_view.mm
@@ -0,0 +1,123 @@
+// 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/client/ios/app/pin_entry_view.h"
+
+#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h"
+
+static const CGFloat kMargin = 5.f;
+static const CGFloat kPadding = 6.f;
+static const CGFloat kLineSpace = 12.f;
+
+@interface PinEntryView () {
+ UISwitch* _pairingSwitch;
+ UILabel* _pairingLabel;
+ MDCFloatingButton* _pinButton;
+ UITextField* _pinEntry;
+}
+@end
+
+@implementation PinEntryView
+
+@synthesize delegate = _delegate;
+
+- (id)initWithFrame:(CGRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ self.backgroundColor = [UIColor clearColor];
+
+ _pairingSwitch = [[UISwitch alloc] init];
+ _pairingSwitch.tintColor =
+ [UIColor colorWithRed:1.f green:1.f blue:1.f alpha:0.5];
+ _pairingSwitch.transform = CGAffineTransformMakeScale(0.5, 0.5);
+ [self addSubview:_pairingSwitch];
+
+ _pairingLabel = [[UILabel alloc] init];
+ _pairingLabel.textColor =
+ [UIColor colorWithRed:1.f green:1.f blue:1.f alpha:0.5];
+ _pairingLabel.font = [UIFont systemFontOfSize:12.f];
+ _pairingLabel.text = @"Remember my PIN on this device.";
+ [self addSubview:_pairingLabel];
+
+ _pinButton =
+ [MDCFloatingButton floatingButtonWithShape:MDCFloatingButtonShapeMini];
+ [_pinButton setTitle:@"+" forState:UIControlStateNormal];
+
+ // TODO(nicholss): Update "->" to the arrow icon.
+ [_pinButton setTitle:@"->" forState:UIControlStateNormal];
+ [_pinButton addTarget:self
+ action:@selector(didTapPinEntry:)
+ forControlEvents:UIControlEventTouchUpInside];
+ _pinButton.translatesAutoresizingMaskIntoConstraints = NO;
+ [self addSubview:_pinButton];
+
+ _pinEntry = [[UITextField alloc] init];
+ _pinEntry.textColor = [UIColor whiteColor];
+ _pinEntry.secureTextEntry = YES;
+ _pinEntry.keyboardType = UIKeyboardTypeNumberPad;
+ // TODO(nicholss): L18N this.
+ _pinEntry.attributedPlaceholder = [[NSAttributedString alloc]
+ initWithString:@"Enter PIN"
+ attributes:@{
+ NSForegroundColorAttributeName :
+ [UIColor colorWithRed:1.f green:1.f blue:1.f alpha:0.5]
+ }];
+ [self addSubview:_pinEntry];
+ }
+ return self;
+}
+
+#pragma mark - UIView
+
+- (BOOL)canBecomeFirstResponder {
+ return [_pinEntry canBecomeFirstResponder];
+}
+
+- (BOOL)becomeFirstResponder {
+ return [_pinEntry becomeFirstResponder];
+}
+
+- (BOOL)endEditing:(BOOL)force {
+ return [_pinEntry endEditing:force];
+}
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+
+ [_pinButton sizeToFit];
+ CGFloat buttonSize = _pinButton.frame.size.width; // Assume circle.
+
+ _pinEntry.frame =
+ CGRectMake(kMargin, 0.f,
+ self.frame.size.width - kPadding - kMargin * 2.f - buttonSize,
+ buttonSize);
+
+ [_pinButton sizeToFit];
+ _pinButton.frame =
+ CGRectMake(self.frame.size.width - kPadding - kMargin - buttonSize, 0.f,
+ buttonSize, buttonSize);
+
+ [_pairingSwitch sizeToFit];
+ _pairingSwitch.center = CGPointMake(
+ kMargin + _pairingSwitch.frame.size.width / 2.f,
+ buttonSize + _pairingSwitch.frame.size.height / 2.f + kLineSpace);
+
+ _pairingLabel.frame =
+ CGRectMake(kMargin + _pairingSwitch.frame.size.width + kPadding,
+ buttonSize + kLineSpace, 0.f, 0.f);
+ [_pairingLabel sizeToFit];
+}
+
+#pragma mark - Private
+
+- (void)didTapPinEntry:(id)sender {
+ [_delegate didProvidePin:_pinEntry.text createPairing:_pairingSwitch.isOn];
+ [_pinEntry endEditing:YES];
+}
+
+@end
« no previous file with comments | « remoting/client/ios/app/pin_entry_view.h ('k') | remoting/client/ios/app/pin_entry_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698