Assistant Link view contorl phone number

This commit is contained in:
REIS Benjamin 2016-10-06 16:58:38 +02:00
parent eb4acee2e6
commit 7d86b9bd88
3 changed files with 20 additions and 2 deletions

View file

@ -9,7 +9,7 @@
#import "PhoneMainView.h"
#import <UIKit/UIKit.h>
@interface AssistantLinkView : UIViewController <UICompositeViewDelegate>
@interface AssistantLinkView : UIViewController <UITextFieldDelegate, UICompositeViewDelegate>
@property(weak, nonatomic) IBOutlet UIView *linkAccountView;
@property(weak, nonatomic) IBOutlet UIView *activateSMSView;

View file

@ -11,6 +11,7 @@
#import "AssistantLinkView.h"
#import "UITextField+DoneButton.h"
#import "UIAssistantTextField.h"
@implementation AssistantLinkView {
LinphoneAccountCreator *account_creator;
@ -20,6 +21,7 @@
[super viewDidLoad];
// every UITextField subviews with phone keyboard must be tweaked to have a done button
[self addDoneButtonRecursivelyInView:self.view];
self.phoneField.delegate = self;
}
- (void)addDoneButtonRecursivelyInView:(UIView *)subview {
@ -230,4 +232,20 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph
_countryCodeField.text = [country objectForKey:@"code"];
}
#pragma mark - UITextFieldDelegate Functions
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
LinphoneAccountCreatorStatus status = linphone_account_creator_set_phone_number(account_creator, [_phoneField.text UTF8String], [_countryCodeField.text UTF8String]);
if (status == LinphoneAccountCreatorPhoneNumberTooLong || self.phoneField.text.length < 8 || status == LinphoneAccountCreatorPhoneNumberInvalid) {
self.phoneField.layer.borderWidth = .8;
self.phoneField.layer.cornerRadius = 4.f;
self.phoneField.layer.borderColor = [[UIColor redColor] CGColor];
self.linkAccountButton.enabled = FALSE;
} else {
self.phoneField.layer.borderColor = [[UIColor clearColor] CGColor];
self.linkAccountButton.enabled = TRUE;
}
return YES;
}
@end

View file

@ -531,7 +531,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}];
UIAssistantTextField *password2 = [self findTextField:ViewElement_Password2];
[password2 showError:NSLocalizedString(@"Passwords do not match.", nil)
[password2 showError:NSLocalizedString(@"The confirmation code is invalid. \nPlease check your SMS and try again.", nil)
when:^BOOL(NSString *inputEntry) {
return ![inputEntry isEqualToString:[self findTextField:ViewElement_Password].text];
}];