|
|
|
@ -4,72 +4,232 @@
|
|
|
|
|
|
|
|
|
|
#import "RegistrationViewController.h"
|
|
|
|
|
#import "CodeVerificationViewController.h"
|
|
|
|
|
#import "CountryCodeViewController.h"
|
|
|
|
|
#import "Environment.h"
|
|
|
|
|
#import "PhoneNumber.h"
|
|
|
|
|
#import "PhoneNumberUtil.h"
|
|
|
|
|
#import "Signal-Swift.h"
|
|
|
|
|
#import "SignalKeyingStorage.h"
|
|
|
|
|
#import "TSAccountManager.h"
|
|
|
|
|
#import "UIView+OWS.h"
|
|
|
|
|
#import "Util.h"
|
|
|
|
|
#import "ViewControllerUtils.h"
|
|
|
|
|
|
|
|
|
|
static NSString *const kCodeSentSegue = @"codeSent";
|
|
|
|
|
|
|
|
|
|
@interface RegistrationViewController () <CountryCodeViewControllerDelegate>
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) NSString *callingCode;
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) UILabel *countryCodeLabel;
|
|
|
|
|
@property (nonatomic) UITextField *phoneNumberTextField;
|
|
|
|
|
@property (nonatomic) UILabel *examplePhoneNumberLabel;
|
|
|
|
|
@property (nonatomic) UIButton *activateButton;
|
|
|
|
|
@property (nonatomic) UIActivityIndicatorView *spinnerView;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
|
|
@implementation RegistrationViewController
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
- (void)loadView
|
|
|
|
|
{
|
|
|
|
|
[super loadView];
|
|
|
|
|
|
|
|
|
|
[self createViews];
|
|
|
|
|
|
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
_phoneNumberTextField.delegate = self;
|
|
|
|
|
_phoneNumberTextField.keyboardType = UIKeyboardTypeNumberPad;
|
|
|
|
|
[self populateDefaultCountryNameAndCode];
|
|
|
|
|
[[Environment getCurrent] setSignUpFlowNavigationController:self.navigationController];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_titleLabel.text = NSLocalizedString(@"REGISTRATION_TITLE_LABEL", @"");
|
|
|
|
|
[_countryNameButton
|
|
|
|
|
setTitle:NSLocalizedString(@"REGISTRATION_DEFAULT_COUNTRY_NAME", @"Label for the country code field")
|
|
|
|
|
forState:UIControlStateNormal];
|
|
|
|
|
_phoneNumberTextField.placeholder = NSLocalizedString(
|
|
|
|
|
@"REGISTRATION_ENTERNUMBER_DEFAULT_TEXT", @"Placeholder text for the phone number textfield");
|
|
|
|
|
[_phoneNumberButton
|
|
|
|
|
setTitle:NSLocalizedString(@"REGISTRATION_PHONENUMBER_BUTTON", @"Label for the phone number textfield")
|
|
|
|
|
forState:UIControlStateNormal];
|
|
|
|
|
[_phoneNumberButton.titleLabel setAdjustsFontSizeToFitWidth:YES];
|
|
|
|
|
[_sendCodeButton setTitle:NSLocalizedString(@"REGISTRATION_VERIFY_DEVICE", @"") forState:UIControlStateNormal];
|
|
|
|
|
[_existingUserButton setTitle:NSLocalizedString(@"ALREADY_HAVE_ACCOUNT_BUTTON", @"registration button text")
|
|
|
|
|
forState:UIControlStateNormal];
|
|
|
|
|
|
|
|
|
|
[self.countryNameButton addTarget:self
|
|
|
|
|
action:@selector(changeCountryCodeTapped)
|
|
|
|
|
forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
[self.countryCodeButton addTarget:self
|
|
|
|
|
action:@selector(changeCountryCodeTapped)
|
|
|
|
|
forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
[self.countryCodeRow
|
|
|
|
|
- (void)createViews
|
|
|
|
|
{
|
|
|
|
|
self.view.backgroundColor = [UIColor ows_signalBrandBlueColor];
|
|
|
|
|
|
|
|
|
|
UIView *header = [UIView new];
|
|
|
|
|
header.backgroundColor = [UIColor ows_signalBrandBlueColor];
|
|
|
|
|
[self.view addSubview:header];
|
|
|
|
|
[header autoPinToTopLayoutGuideOfViewController:self withInset:0];
|
|
|
|
|
[header autoPinWidthToSuperview];
|
|
|
|
|
|
|
|
|
|
UILabel *headerLabel = [UILabel new];
|
|
|
|
|
headerLabel.text = NSLocalizedString(@"REGISTRATION_TITLE_LABEL", @"");
|
|
|
|
|
headerLabel.textColor = [UIColor whiteColor];
|
|
|
|
|
headerLabel.font = [UIFont ows_mediumFontWithSize:ScaleFromIPhone5To7Plus(20.f, 24.f)];
|
|
|
|
|
[header addSubview:headerLabel];
|
|
|
|
|
[headerLabel autoHCenterInSuperview];
|
|
|
|
|
[headerLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:14.f];
|
|
|
|
|
|
|
|
|
|
CGFloat screenHeight = MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
|
|
|
|
|
if (screenHeight < 568) {
|
|
|
|
|
// iPhone 4s or smaller.
|
|
|
|
|
[header autoSetDimension:ALDimensionHeight toSize:20];
|
|
|
|
|
headerLabel.hidden = YES;
|
|
|
|
|
} else if (screenHeight < 667) {
|
|
|
|
|
// iPhone 5 or smaller.
|
|
|
|
|
[header autoSetDimension:ALDimensionHeight toSize:80];
|
|
|
|
|
} else {
|
|
|
|
|
[header autoSetDimension:ALDimensionHeight toSize:225];
|
|
|
|
|
|
|
|
|
|
UIImage *logo = [UIImage imageNamed:@"logoSignal"];
|
|
|
|
|
OWSAssert(logo);
|
|
|
|
|
UIImageView *logoView = [UIImageView new];
|
|
|
|
|
logoView.image = logo;
|
|
|
|
|
[header addSubview:logoView];
|
|
|
|
|
[logoView autoHCenterInSuperview];
|
|
|
|
|
[logoView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:headerLabel withOffset:-14.f];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIView *contentView = [UIView new];
|
|
|
|
|
contentView.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
[self.view addSubview:contentView];
|
|
|
|
|
[contentView autoPinToBottomLayoutGuideOfViewController:self withInset:0];
|
|
|
|
|
[contentView autoPinWidthToSuperview];
|
|
|
|
|
[contentView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:header];
|
|
|
|
|
|
|
|
|
|
const CGFloat kRowHeight = 60.f;
|
|
|
|
|
const CGFloat kRowLeftMargin = 20.f;
|
|
|
|
|
const CGFloat kRowRightMargin = 16.f;
|
|
|
|
|
const CGFloat kSeparatorHeight = 1.f;
|
|
|
|
|
const CGFloat kButtonHMargin = 30.f;
|
|
|
|
|
const CGFloat kExamplePhoneNumberVSpacing = 8.f;
|
|
|
|
|
const CGFloat fontSizePoints = ScaleFromIPhone5To7Plus(16.f, 20.f);
|
|
|
|
|
|
|
|
|
|
// Country
|
|
|
|
|
UIView *countryRow = [UIView new];
|
|
|
|
|
[contentView addSubview:countryRow];
|
|
|
|
|
[countryRow autoPinWidthToSuperview];
|
|
|
|
|
[countryRow autoPinEdgeToSuperviewEdge:ALEdgeTop];
|
|
|
|
|
[countryRow autoSetDimension:ALDimensionHeight toSize:kRowHeight];
|
|
|
|
|
[countryRow
|
|
|
|
|
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
|
|
|
|
|
action:@selector(countryCodeRowWasTapped:)]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
[self adjustScreenSizes];
|
|
|
|
|
UILabel *countryNameLabel = [UILabel new];
|
|
|
|
|
countryNameLabel.text
|
|
|
|
|
= NSLocalizedString(@"REGISTRATION_DEFAULT_COUNTRY_NAME", @"Label for the country code field");
|
|
|
|
|
countryNameLabel.textColor = [UIColor blackColor];
|
|
|
|
|
countryNameLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints];
|
|
|
|
|
[countryRow addSubview:countryNameLabel];
|
|
|
|
|
[countryNameLabel autoVCenterInSuperview];
|
|
|
|
|
[countryNameLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kRowLeftMargin];
|
|
|
|
|
|
|
|
|
|
UILabel *countryCodeLabel = [UILabel new];
|
|
|
|
|
self.countryCodeLabel = countryCodeLabel;
|
|
|
|
|
countryCodeLabel.textColor = [UIColor ows_materialBlueColor];
|
|
|
|
|
countryCodeLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints + 2.f];
|
|
|
|
|
[countryRow addSubview:countryCodeLabel];
|
|
|
|
|
[countryCodeLabel autoVCenterInSuperview];
|
|
|
|
|
[countryCodeLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kRowRightMargin];
|
|
|
|
|
|
|
|
|
|
UIView *separatorView1 = [UIView new];
|
|
|
|
|
separatorView1.backgroundColor = [UIColor colorWithWhite:0.75f alpha:1.f];
|
|
|
|
|
[contentView addSubview:separatorView1];
|
|
|
|
|
[separatorView1 autoPinWidthToSuperview];
|
|
|
|
|
[separatorView1 autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:countryRow];
|
|
|
|
|
[separatorView1 autoSetDimension:ALDimensionHeight toSize:kSeparatorHeight];
|
|
|
|
|
|
|
|
|
|
// Phone Number
|
|
|
|
|
UIView *phoneNumberRow = [UIView new];
|
|
|
|
|
[contentView addSubview:phoneNumberRow];
|
|
|
|
|
[phoneNumberRow autoPinWidthToSuperview];
|
|
|
|
|
[phoneNumberRow autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:separatorView1];
|
|
|
|
|
[phoneNumberRow autoSetDimension:ALDimensionHeight toSize:kRowHeight];
|
|
|
|
|
|
|
|
|
|
UILabel *phoneNumberLabel = [UILabel new];
|
|
|
|
|
phoneNumberLabel.text
|
|
|
|
|
= NSLocalizedString(@"REGISTRATION_PHONENUMBER_BUTTON", @"Label for the phone number textfield");
|
|
|
|
|
phoneNumberLabel.textColor = [UIColor blackColor];
|
|
|
|
|
phoneNumberLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints];
|
|
|
|
|
[phoneNumberRow addSubview:phoneNumberLabel];
|
|
|
|
|
[phoneNumberLabel autoVCenterInSuperview];
|
|
|
|
|
[phoneNumberLabel autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kRowLeftMargin];
|
|
|
|
|
|
|
|
|
|
UITextField *phoneNumberTextField = [UITextField new];
|
|
|
|
|
phoneNumberTextField.textAlignment = NSTextAlignmentRight;
|
|
|
|
|
phoneNumberTextField.delegate = self;
|
|
|
|
|
phoneNumberTextField.keyboardType = UIKeyboardTypeNumberPad;
|
|
|
|
|
phoneNumberTextField.placeholder = NSLocalizedString(
|
|
|
|
|
@"REGISTRATION_ENTERNUMBER_DEFAULT_TEXT", @"Placeholder text for the phone number textfield");
|
|
|
|
|
self.phoneNumberTextField = phoneNumberTextField;
|
|
|
|
|
phoneNumberTextField.textColor = [UIColor ows_materialBlueColor];
|
|
|
|
|
phoneNumberTextField.font = [UIFont ows_mediumFontWithSize:fontSizePoints];
|
|
|
|
|
[phoneNumberRow addSubview:phoneNumberTextField];
|
|
|
|
|
[phoneNumberTextField autoVCenterInSuperview];
|
|
|
|
|
[phoneNumberTextField autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kRowRightMargin];
|
|
|
|
|
|
|
|
|
|
UILabel *examplePhoneNumberLabel = [UILabel new];
|
|
|
|
|
self.examplePhoneNumberLabel = examplePhoneNumberLabel;
|
|
|
|
|
examplePhoneNumberLabel.font = [UIFont ows_regularFontWithSize:fontSizePoints - 2.f];
|
|
|
|
|
examplePhoneNumberLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f];
|
|
|
|
|
[contentView addSubview:examplePhoneNumberLabel];
|
|
|
|
|
[examplePhoneNumberLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kRowRightMargin];
|
|
|
|
|
[examplePhoneNumberLabel autoPinEdge:ALEdgeTop
|
|
|
|
|
toEdge:ALEdgeBottom
|
|
|
|
|
ofView:phoneNumberTextField
|
|
|
|
|
withOffset:kExamplePhoneNumberVSpacing];
|
|
|
|
|
|
|
|
|
|
UIView *separatorView2 = [UIView new];
|
|
|
|
|
separatorView2.backgroundColor = [UIColor colorWithWhite:0.75f alpha:1.f];
|
|
|
|
|
[contentView addSubview:separatorView2];
|
|
|
|
|
[separatorView2 autoPinWidthToSuperview];
|
|
|
|
|
[separatorView2 autoPinEdge:ALEdgeTop
|
|
|
|
|
toEdge:ALEdgeBottom
|
|
|
|
|
ofView:phoneNumberRow
|
|
|
|
|
withOffset:examplePhoneNumberLabel.font.lineHeight];
|
|
|
|
|
[separatorView2 autoSetDimension:ALDimensionHeight toSize:kSeparatorHeight];
|
|
|
|
|
|
|
|
|
|
// Activate Button
|
|
|
|
|
UIButton *activateButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
self.activateButton = activateButton;
|
|
|
|
|
activateButton.backgroundColor = [UIColor ows_signalBrandBlueColor];
|
|
|
|
|
[activateButton setTitle:NSLocalizedString(@"REGISTRATION_VERIFY_DEVICE", @"") forState:UIControlStateNormal];
|
|
|
|
|
[activateButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
|
|
activateButton.titleLabel.font = [UIFont ows_boldFontWithSize:fontSizePoints];
|
|
|
|
|
[activateButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
|
|
|
|
|
[activateButton setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
|
|
|
|
|
[contentView addSubview:activateButton];
|
|
|
|
|
[activateButton autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kButtonHMargin];
|
|
|
|
|
[activateButton autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kButtonHMargin];
|
|
|
|
|
[activateButton autoPinEdge:ALEdgeTop
|
|
|
|
|
toEdge:ALEdgeBottom
|
|
|
|
|
ofView:separatorView2
|
|
|
|
|
withOffset:ScaleFromIPhone5To7Plus(12.f, 15.f)];
|
|
|
|
|
[activateButton autoSetDimension:ALDimensionHeight toSize:47.f];
|
|
|
|
|
[activateButton addTarget:self action:@selector(sendCodeAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
|
|
|
|
UIActivityIndicatorView *spinnerView =
|
|
|
|
|
[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
|
|
|
|
|
self.spinnerView = spinnerView;
|
|
|
|
|
[activateButton addSubview:spinnerView];
|
|
|
|
|
[spinnerView autoVCenterInSuperview];
|
|
|
|
|
[spinnerView autoSetDimension:ALDimensionWidth toSize:20.f];
|
|
|
|
|
[spinnerView autoSetDimension:ALDimensionHeight toSize:20.f];
|
|
|
|
|
[spinnerView autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:20];
|
|
|
|
|
[spinnerView stopAnimating];
|
|
|
|
|
|
|
|
|
|
// Existing Account Button
|
|
|
|
|
UIButton *existingAccountButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[existingAccountButton setTitle:NSLocalizedString(@"ALREADY_HAVE_ACCOUNT_BUTTON", @"registration button text")
|
|
|
|
|
forState:UIControlStateNormal];
|
|
|
|
|
[existingAccountButton setTitleColor:[UIColor ows_materialBlueColor] forState:UIControlStateNormal];
|
|
|
|
|
existingAccountButton.titleLabel.font = [UIFont ows_mediumFontWithSize:fontSizePoints - 2.f];
|
|
|
|
|
[existingAccountButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
|
|
|
|
|
[existingAccountButton setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
|
|
|
|
|
[contentView addSubview:existingAccountButton];
|
|
|
|
|
[existingAccountButton autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kButtonHMargin];
|
|
|
|
|
[existingAccountButton autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kButtonHMargin];
|
|
|
|
|
[existingAccountButton autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:activateButton withOffset:9.f];
|
|
|
|
|
[existingAccountButton autoSetDimension:ALDimensionHeight toSize:36.f];
|
|
|
|
|
[existingAccountButton addTarget:self
|
|
|
|
|
action:@selector(didTapExistingUserButton:)
|
|
|
|
|
forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
|
|
|
|
|
|
[_sendCodeButton setEnabled:YES];
|
|
|
|
|
[_spinnerView stopAnimating];
|
|
|
|
|
[_phoneNumberTextField becomeFirstResponder];
|
|
|
|
|
[self.activateButton setEnabled:YES];
|
|
|
|
|
[self.spinnerView stopAnimating];
|
|
|
|
|
[self.phoneNumberTextField becomeFirstResponder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Country
|
|
|
|
@ -95,37 +255,17 @@ static NSString *const kCodeSentSegue = @"codeSent";
|
|
|
|
|
NSString *title = [NSString stringWithFormat:@"%@ (%@)",
|
|
|
|
|
callingCode,
|
|
|
|
|
countryCode.uppercaseString];
|
|
|
|
|
[_countryCodeButton setTitle:title
|
|
|
|
|
forState:UIControlStateNormal];
|
|
|
|
|
|
|
|
|
|
// In the absence of a rewrite to a programmatic layout,
|
|
|
|
|
// re-add the country code and name views in order to
|
|
|
|
|
// remove any layout constraints that apply to them.
|
|
|
|
|
UIView *superview = _countryCodeButton.superview;
|
|
|
|
|
[_countryNameButton removeFromSuperview];
|
|
|
|
|
[_countryCodeButton removeFromSuperview];
|
|
|
|
|
[_countryNameButton removeConstraints:_countryNameButton.constraints];
|
|
|
|
|
[_countryCodeButton removeConstraints:_countryCodeButton.constraints];
|
|
|
|
|
|
|
|
|
|
[superview addSubview:_countryNameButton];
|
|
|
|
|
[superview addSubview:_countryCodeButton];
|
|
|
|
|
[_countryNameButton autoVCenterInSuperview];
|
|
|
|
|
[_countryCodeButton autoVCenterInSuperview];
|
|
|
|
|
[_countryNameButton autoSetDimension:ALDimensionHeight toSize:26];
|
|
|
|
|
[_countryCodeButton autoSetDimension:ALDimensionHeight toSize:26];
|
|
|
|
|
[_countryNameButton autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:20];
|
|
|
|
|
[_countryCodeButton autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:16];
|
|
|
|
|
[_countryNameButton autoSetDimension:ALDimensionWidth toSize:150];
|
|
|
|
|
[_countryCodeButton autoSetDimension:ALDimensionWidth toSize:150];
|
|
|
|
|
_countryNameButton.translatesAutoresizingMaskIntoConstraints = NO;
|
|
|
|
|
_countryCodeButton.translatesAutoresizingMaskIntoConstraints = NO;
|
|
|
|
|
|
|
|
|
|
[superview layoutSubviews];
|
|
|
|
|
self.countryCodeLabel.text = title;
|
|
|
|
|
[self.countryCodeLabel setNeedsLayout];
|
|
|
|
|
|
|
|
|
|
self.examplePhoneNumberLabel.text =
|
|
|
|
|
[ViewControllerUtils examplePhoneNumberForCountryCode:countryCode callingCode:callingCode];
|
|
|
|
|
[self.examplePhoneNumberLabel setNeedsLayout];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Actions
|
|
|
|
|
|
|
|
|
|
- (IBAction)didTapExistingUserButton:(id)sender
|
|
|
|
|
- (void)didTapExistingUserButton:(id)sender
|
|
|
|
|
{
|
|
|
|
|
DDLogInfo(@"called %s", __PRETTY_FUNCTION__);
|
|
|
|
|
|
|
|
|
@ -137,7 +277,8 @@ static NSString *const kCodeSentSegue = @"codeSent";
|
|
|
|
|
message:NSLocalizedString(@"EXISTING_USER_REGISTRATION_ALERT_BODY", @"during registration")];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (IBAction)sendCodeAction:(id)sender {
|
|
|
|
|
- (void)sendCodeAction:(id)sender
|
|
|
|
|
{
|
|
|
|
|
NSString *phoneNumberText =
|
|
|
|
|
[_phoneNumberTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
|
|
|
|
if (phoneNumberText.length < 1) {
|
|
|
|
@ -162,14 +303,17 @@ static NSString *const kCodeSentSegue = @"codeSent";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[_sendCodeButton setEnabled:NO];
|
|
|
|
|
[_spinnerView startAnimating];
|
|
|
|
|
[_phoneNumberTextField resignFirstResponder];
|
|
|
|
|
[self.activateButton setEnabled:NO];
|
|
|
|
|
[self.spinnerView startAnimating];
|
|
|
|
|
[self.phoneNumberTextField resignFirstResponder];
|
|
|
|
|
|
|
|
|
|
__weak RegistrationViewController *weakSelf = self;
|
|
|
|
|
[TSAccountManager registerWithPhoneNumber:parsedPhoneNumber
|
|
|
|
|
success:^{
|
|
|
|
|
[self performSegueWithIdentifier:@"codeSent" sender:self];
|
|
|
|
|
[_spinnerView stopAnimating];
|
|
|
|
|
[weakSelf.spinnerView stopAnimating];
|
|
|
|
|
|
|
|
|
|
CodeVerificationViewController *vc = [CodeVerificationViewController new];
|
|
|
|
|
[weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
|
|
}
|
|
|
|
|
failure:^(NSError *error) {
|
|
|
|
|
if (error.code == 400) {
|
|
|
|
@ -179,8 +323,8 @@ static NSString *const kCodeSentSegue = @"codeSent";
|
|
|
|
|
[OWSAlerts showAlertWithTitle:error.localizedDescription message:error.localizedRecoverySuggestion];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[_sendCodeButton setEnabled:YES];
|
|
|
|
|
[_spinnerView stopAnimating];
|
|
|
|
|
[weakSelf.activateButton setEnabled:YES];
|
|
|
|
|
[weakSelf.spinnerView stopAnimating];
|
|
|
|
|
}
|
|
|
|
|
smsVerification:YES];
|
|
|
|
|
}
|
|
|
|
@ -257,24 +401,4 @@ static NSString *const kCodeSentSegue = @"codeSent";
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Unwind segue
|
|
|
|
|
|
|
|
|
|
- (IBAction)unwindToChangeNumber:(UIStoryboardSegue *)sender {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark iPhone 5s or shorter
|
|
|
|
|
|
|
|
|
|
- (void)adjustScreenSizes
|
|
|
|
|
{
|
|
|
|
|
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
|
|
|
|
|
|
|
|
|
|
if (screenHeight < 568) { // iphone 4s
|
|
|
|
|
self.signalLogo.hidden = YES;
|
|
|
|
|
_headerHeightConstraint.constant = 20;
|
|
|
|
|
} else if (screenHeight < 667) { // iphone 5
|
|
|
|
|
self.signalLogo.hidden = YES;
|
|
|
|
|
_headerHeightConstraint.constant = 120;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|