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

Unified Diff: remoting/ios/app/pin_entry_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/pin_entry_view.mm
diff --git a/remoting/ios/app/pin_entry_view.mm b/remoting/ios/app/pin_entry_view.mm
index 87a5a6b2523419773823b9488783e7d36bfe962b..1a8fbd5aa17b3f22b3c1ca69575c01a80279a37a 100644
--- a/remoting/ios/app/pin_entry_view.mm
+++ b/remoting/ios/app/pin_entry_view.mm
@@ -12,10 +12,10 @@
#import "remoting/ios/app/remoting_theme.h"
static const CGFloat kMargin = 5.f;
-static const CGFloat kPadding = 6.f;
+static const CGFloat kPadding = 8.f;
static const CGFloat kLineSpace = 12.f;
-@interface PinEntryView () {
+@interface PinEntryView ()<UITextFieldDelegate> {
UISwitch* _pairingSwitch;
UILabel* _pairingLabel;
MDCFloatingButton* _pinButton;
@@ -52,6 +52,7 @@ static const CGFloat kLineSpace = 12.f;
action:@selector(didTapPinEntry:)
forControlEvents:UIControlEventTouchUpInside];
_pinButton.translatesAutoresizingMaskIntoConstraints = NO;
+ _pinButton.enabled = NO;
[self addSubview:_pinButton];
_pinEntry = [[UITextField alloc] init];
@@ -65,6 +66,7 @@ static const CGFloat kLineSpace = 12.f;
NSForegroundColorAttributeName :
[UIColor colorWithRed:1.f green:1.f blue:1.f alpha:0.5]
}];
+ _pinEntry.delegate = self;
[self addSubview:_pinEntry];
}
return self;
@@ -111,6 +113,34 @@ static const CGFloat kLineSpace = 12.f;
[_pairingLabel sizeToFit];
}
+#pragma mark - UITextFieldDelegate
+
+- (BOOL)textField:(UITextField*)textField
+ shouldChangeCharactersInRange:(NSRange)range
+ replacementString:(NSString*)string {
+ if (textField == _pinEntry) {
+ NSUInteger length = _pinEntry.text.length - range.length + string.length;
+ _pinButton.enabled = length >= 6;
+ }
+ return YES;
+}
+
+- (BOOL)textFieldShouldReturn:(UITextField*)textField {
+ NSLog(@"textFieldShouldReturn");
+ if ([_pinButton isEnabled]) {
+ [self didTapPinEntry:textField];
+ return YES;
+ }
+ return NO;
+}
+
+#pragma mark - Public
+
+- (void)clearPinEntry {
+ _pinEntry.text = @"";
+ _pinButton.enabled = NO;
+}
+
#pragma mark - Private
- (void)didTapPinEntry:(id)sender {

Powered by Google App Engine
This is Rietveld 408576698