Rationalize the segues between registration view and country code view.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 157baa1f90
commit ea9dc3fe77

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1217" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="zqr-Ab-axp">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="zqr-Ab-axp">
<device id="retina4_0" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
@ -75,9 +75,6 @@
<color key="titleColor" red="0.054103322330000002" green="0.45790460710000003" blue="0.9261735082" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<segue destination="CCL-Zs-hfU" kind="presentation" id="foJ-CL-5wr"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="tailTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Pu7-Ia-adg">
<rect key="frame" x="20" y="0.0" width="195" height="60"/>
@ -89,9 +86,6 @@
<state key="normal" title="Country Code">
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<segue destination="CCL-Zs-hfU" kind="presentation" id="uxC-Up-OyM"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -228,6 +222,7 @@
<nil key="simulatedTopBarMetrics"/>
<connections>
<outlet property="countryCodeButton" destination="aSz-jb-g2o" id="HAe-2D-BxF"/>
<outlet property="countryCodeRow" destination="ogW-8F-AvT" id="5uE-tH-utQ"/>
<outlet property="countryNameButton" destination="Pu7-Ia-adg" id="PFU-m2-gzV"/>
<outlet property="existingUserButton" destination="AqN-gc-h3O" id="XQz-rJ-HOP"/>
<outlet property="headerHeightConstraint" destination="EX0-kF-4ZZ" id="e8J-On-rOg"/>
@ -282,7 +277,7 @@
<rect key="frame" x="0.0" y="66" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="LFg-KJ-GnQ" id="o6y-AP-QLT" userLabel="Country Code Table Row">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="United states" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eyx-0e-8jI">
@ -399,7 +394,4 @@
<image name="btnCancel--white" width="44" height="44"/>
<image name="logoSignal" width="138" height="139"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="uxC-Up-OyM"/>
</inferredMetricsTieBreakers>
</document>

@ -15,15 +15,10 @@
@end
@interface CountryCodeViewController
: UIViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UISearchDisplayDelegate>
#pragma mark -
@interface CountryCodeViewController : UIViewController
@property (nonatomic) IBOutlet UITableView *countryCodeTableView;
@property (nonatomic) IBOutlet UISearchBar *searchBar;
@property (nonatomic, weak) id<CountryCodeViewControllerDelegate> delegate;
@property (nonatomic) NSString *countryCodeSelected;
@property (nonatomic) NSString *callingCodeSelected;
@property (nonatomic) NSString *countryNameSelected;
@property (nonatomic) BOOL shouldDismissWithoutSegue;
@end

@ -2,33 +2,45 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "CountryCodeTableViewCell.h"
#import "CountryCodeViewController.h"
#import "PhoneNumberUtil.h"
#import "CountryCodeTableViewCell.h"
#import "FunctionalUtil.h"
#import "PhoneNumberUtil.h"
#import "UIView+OWS.h"
static NSString *const CONTRY_CODE_TABLE_CELL_IDENTIFIER = @"CountryCodeTableViewCell";
static NSString *const kUnwindToCountryCodeWasSelectedSegue = @"UnwindToCountryCodeWasSelectedSegue";
@interface CountryCodeViewController () {
@interface CountryCodeViewController () <UITableViewDelegate,
UITableViewDataSource,
UISearchBarDelegate,
UISearchDisplayDelegate> {
NSArray *_countryCodes;
}
@property (nonatomic) IBOutlet UITableView *countryCodeTableView;
@property (nonatomic) IBOutlet UISearchBar *searchBar;
@property (nonatomic) NSString *countryCodeSelected;
@property (nonatomic) NSString *callingCodeSelected;
@property (nonatomic) NSString *countryNameSelected;
@end
@implementation CountryCodeViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self.view addRedBorder];
[self.navigationController.navigationBar setTranslucent:NO];
_countryCodes = [PhoneNumberUtil countryCodesForSearchTerm:nil];
self.title = NSLocalizedString(@"COUNTRYCODE_SELECT_TITLE", @"");
self.searchBar.delegate = self;
if (self.shouldDismissWithoutSegue) {
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self
action:@selector(dismissWasPressed:)];
}
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self
action:@selector(dismissWasPressed:)];
}
#pragma mark - UITableViewDelegate
@ -66,11 +78,7 @@ static NSString *const kUnwindToCountryCodeWasSelectedSegue = @"UnwindToCountryC
countryName:_countryNameSelected
callingCode:_callingCodeSelected];
[self.searchBar resignFirstResponder];
if (self.shouldDismissWithoutSegue) {
[self dismissViewControllerAnimated:YES completion:nil];
} else {
[self performSegueWithIdentifier:kUnwindToCountryCodeWasSelectedSegue sender:self];
}
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)dismissWasPressed:(id)sender {

@ -1,9 +1,5 @@
//
// RegistrationViewController.h
// Signal
//
// Created by Dylan Bourgeois on 13/11/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h>
@ -13,18 +9,19 @@
@interface RegistrationViewController : UIViewController <UITextFieldDelegate>
// Country code
@property (nonatomic, strong) IBOutlet UIButton *countryNameButton;
@property (nonatomic, strong) IBOutlet UIButton *countryCodeButton;
@property (nonatomic) IBOutlet UIButton *countryNameButton;
@property (nonatomic) IBOutlet UIButton *countryCodeButton;
@property (nonatomic) IBOutlet UIView *countryCodeRow;
// Phone number
@property (nonatomic, strong) IBOutlet UITextField *phoneNumberTextField;
@property (nonatomic, strong) IBOutlet UIButton *phoneNumberButton;
@property (nonatomic, strong) IBOutlet UILabel *titleLabel;
@property (nonatomic) IBOutlet UITextField *phoneNumberTextField;
@property (nonatomic) IBOutlet UIButton *phoneNumberButton;
@property (nonatomic) IBOutlet UILabel *titleLabel;
// Button
@property (nonatomic, strong) IBOutlet UIButton *sendCodeButton;
@property (nonatomic, strong) IBOutlet UIButton *existingUserButton;
@property (nonatomic) IBOutlet UIButton *sendCodeButton;
@property (nonatomic) IBOutlet UIButton *existingUserButton;
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView *spinnerView;
@property (nonatomic) IBOutlet UIActivityIndicatorView *spinnerView;
@property (nonatomic) IBOutlet UIImageView *signalLogo;
@property (nonatomic) IBOutlet UIView *registrationHeader;

@ -16,7 +16,7 @@
static NSString *const kCodeSentSegue = @"codeSent";
@interface RegistrationViewController ()
@interface RegistrationViewController () <CountryCodeViewControllerDelegate>
@property (nonatomic) NSString *callingCode;
@ -48,6 +48,16 @@ static NSString *const kCodeSentSegue = @"codeSent";
[_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
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(countryCodeRowWasTapped:)]];
}
- (void)viewWillAppear:(BOOL)animated {
@ -175,9 +185,21 @@ static NSString *const kCodeSentSegue = @"codeSent";
smsVerification:YES];
}
- (IBAction)changeCountryCodeTapped {
CountryCodeViewController *countryCodeController = [CountryCodeViewController new];
[self presentViewController:countryCodeController animated:YES completion:[UIUtil modalCompletionBlock]];
- (void)countryCodeRowWasTapped:(UIGestureRecognizer *)sender
{
if (sender.state == UIGestureRecognizerStateRecognized) {
[self changeCountryCodeTapped];
}
}
- (void)changeCountryCodeTapped
{
CountryCodeViewController *countryCodeController = [[UIStoryboard storyboardWithName:@"Registration" bundle:NULL]
instantiateViewControllerWithIdentifier:@"CountryCodeViewController"];
countryCodeController.delegate = self;
UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:countryCodeController];
[self presentViewController:navigationController animated:YES completion:[UIUtil modalCompletionBlock]];
}
- (void)presentInvalidCountryCodeError {
@ -187,6 +209,20 @@ static NSString *const kCodeSentSegue = @"codeSent";
@"DISMISS_BUTTON_TEXT", @"Generic short text for button to dismiss a dialog")];
}
#pragma mark - CountryCodeViewControllerDelegate
- (void)countryCodeViewController:(CountryCodeViewController *)vc
didSelectCountryCode:(NSString *)countryCode
countryName:(NSString *)countryName
callingCode:(NSString *)callingCode
{
[self updateCountryWithName:countryName callingCode:callingCode countryCode:countryCode];
// Trigger the formatting logic with a no-op edit.
[self textField:self.phoneNumberTextField shouldChangeCharactersInRange:NSMakeRange(0, 0) replacementString:@""];
}
#pragma mark - Keyboard notifications
- (void)initializeKeyboardHandlers {
@ -224,19 +260,6 @@ static NSString *const kCodeSentSegue = @"codeSent";
- (IBAction)unwindToChangeNumber:(UIStoryboardSegue *)sender {
}
- (IBAction)unwindToCountryCodeSelectionCancelled:(UIStoryboardSegue *)segue {
}
- (IBAction)unwindToCountryCodeWasSelected:(UIStoryboardSegue *)segue {
CountryCodeViewController *vc = [segue sourceViewController];
[self updateCountryWithName:vc.countryNameSelected
callingCode:vc.callingCodeSelected
countryCode:vc.countryCodeSelected];
// Reformat phone number
[self textField:_phoneNumberTextField shouldChangeCharactersInRange:NSMakeRange(0, 0) replacementString:@""];
}
#pragma mark iPhone 5s or shorter
- (void)adjustScreenSizes

@ -287,7 +287,6 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
CountryCodeViewController *countryCodeController = [[UIStoryboard storyboardWithName:@"Registration" bundle:NULL]
instantiateViewControllerWithIdentifier:@"CountryCodeViewController"];
countryCodeController.delegate = self;
countryCodeController.shouldDismissWithoutSegue = YES;
UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:countryCodeController];
[self presentViewController:navigationController animated:YES completion:[UIUtil modalCompletionBlock]];

Loading…
Cancel
Save