Signup: Locking UI while async requests

This commit is contained in:
dtsbourg 2014-11-27 09:49:50 +01:00 committed by Frederic Jacobs
parent 1eff2b3ad5
commit 211e20aaf7
5 changed files with 27 additions and 5 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="kts-vO-ui1">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14C68k" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="kts-vO-ui1">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
@ -1161,6 +1161,7 @@ Lorem ipsum : Quick explanation of Fingerprints</string>
<outlet property="countryCodeLabel" destination="TiF-CF-7WU" id="a8o-pE-QzV"/>
<outlet property="countryNameLabel" destination="4o4-Xj-5JG" id="dFh-dM-mgC"/>
<outlet property="phoneNumberTextField" destination="tTJ-pq-Z9L" id="gPX-pu-twz"/>
<outlet property="sendCodeButton" destination="7IK-hd-tli" id="zj7-3u-4OR"/>
<segue destination="3Uo-Ow-qOD" kind="show" identifier="codeSent" id="KhC-MI-Evx"/>
</connections>
</viewController>
@ -1398,6 +1399,7 @@ Lorem ipsum : Quick explanation of Fingerprints</string>
</variation>
</view>
<connections>
<outlet property="challengeButton" destination="PHu-da-Fan" id="hd0-4C-XqL"/>
<outlet property="challengeTextField" destination="yK6-ad-ihc" id="cnh-li-Z6O"/>
<segue destination="QKN-cj-wuH" kind="show" identifier="verifiedSegue" id="Wd2-mW-FfR"/>
</connections>
@ -3119,6 +3121,6 @@ Licensed under the GPLv3</string>
<image name="signals_tab.png" width="24" height="24"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="QK8-XK-Wd3"/>
<segue reference="qCk-gl-KCX"/>
</inferredMetricsTieBreakers>
</document>

View file

@ -12,6 +12,8 @@
@property(nonatomic, strong) IBOutlet UITextField* challengeTextField;
@property(nonatomic, strong) IBOutlet UIButton* challengeButton;
- (IBAction)verifyChallengeAction:(id)sender;
@end

View file

@ -29,6 +29,12 @@
[self initializeKeyboardHandlers];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[_challengeButton setEnabled:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
@ -37,6 +43,7 @@
- (IBAction)verifyChallengeAction:(id)sender {
[_challengeButton setEnabled:NO];
[_challengeTextField resignFirstResponder];
//TODO: Lock UI interactions
@ -47,6 +54,7 @@
// TODO: Unlock UI
NSLog(@"Failed to register");
[self showAlertForError:error];
[_challengeButton setEnabled:YES];
}];
}

View file

@ -20,4 +20,7 @@
//Phone number
@property(nonatomic, strong) IBOutlet UITextField* phoneNumberTextField;
//Button
@property(nonatomic, strong) IBOutlet UIButton* sendCodeButton;
@end

View file

@ -42,6 +42,13 @@
[self initializeKeyboardHandlers];
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[_sendCodeButton setEnabled:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
@ -67,10 +74,8 @@
PhoneNumber* localNumber = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:phoneNumber];
if(localNumber==nil){ return; }
//TO:DO Disable button
[_sendCodeButton setEnabled:NO];
[_phoneNumberTextField resignFirstResponder];
[SignalKeyingStorage setLocalNumberTo:localNumber];
[[RPServerRequestsManager sharedInstance]performRequest:[RPAPICall requestVerificationCode] success:^(NSURLSessionDataTask *task, id responseObject) {
@ -87,6 +92,8 @@
otherButtonTitles:nil, nil];
[registrationErrorAV show];
[_sendCodeButton setEnabled:YES];
}];
}