Skip to content

Commit

Permalink
Use branch "fixed-canada-issue" for MRCountryPicker and updated the c…
Browse files Browse the repository at this point in the history
…heck for US
  • Loading branch information
abdulrehman-xo committed Nov 19, 2019
1 parent 196441c commit d16966c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ @interface EditViewController ()
@property (nonatomic) PhoneNumberFormatter* phoneNumberFormatter;
@property (nonatomic) RAPhotoPickerControllerManager *pickerManager;
@property (nonatomic) UIBarButtonItem *saveButton;
@property (nonatomic) BOOL changePhoneText;

@end

Expand Down Expand Up @@ -89,7 +90,7 @@ - (void)viewDidLoad {

[self configureNavigationBar];
[self addEdgeInsetsToTextFields];

self.changePhoneText = YES;
self.previousContentSize = self.scrollViewContainer.contentSize;
[self configureCountryPicker];
[self configureData];
Expand Down Expand Up @@ -383,10 +384,22 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang

@implementation EditViewController (CountryPickerDelegate)

- (void)setMobileTextfieldEnabled {
BOOL enabled = YES;
UIImage *bg = enabled ? [UIImage imageNamed:@"Field"] : [UIImage imageNamed:@"Field-unactive"];
self.mobileTextField.background = bg;
self.mobileTextField.enabled = enabled;
}

- (void)countryPhoneCodePicker:(MRCountryPicker *)picker didSelectCountryWithName:(NSString *)name countryCode:(NSString *)countryCode phoneCode:(NSString *)phoneCode flag:(UIImage *)flag {
[self.ivFlag setImage:flag];
[self.mobileTextField setText:phoneCode];
self.countryCode= phoneCode;
if (self.changePhoneText) {
[self.mobileTextField setText:phoneCode];
[self setMobileTextfieldEnabled];
} else {
self.changePhoneText = YES;
}
self.countryCode = phoneCode;
}

@end
Expand Down Expand Up @@ -456,6 +469,14 @@ - (void)keyboardWillHide:(NSNotification*)notification {

@implementation EditViewController (Private)

- (void)verifyFlagForPhoneNumber:(NSString *)phoneNumber{
NSString *countryCode = [phoneNumber countryCode];
self.changePhoneText = NO;
if (countryCode) {
[self.countryPicker setCountryByPhoneCode:countryCode];
}
}

- (void)configureData {
RADriverDataModel *driver = [RASessionManager shared].currentSession.driver;
RAUserDataModel *user = driver.user;
Expand All @@ -472,14 +493,12 @@ - (void)configureData {
placeholderImage:[UIImage imageNamed:@"person_placeholder"]
usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
}
NSString *phoneNumber = user.phoneNumber;
if (phoneNumber) {
NSString *countryCode = phoneNumber.countryCode;
if (countryCode) {
[self.countryPicker setCountryByPhoneCode:countryCode];
self.mobileTextField.text = phoneNumber.clearedPhoneNumber;
} else {
[self showAlertUnrecognizedCountryCode:user.phoneNumber];

NSString *phone = [user.phoneNumber clearedPhoneNumber];
if (phone) {
[self verifyFlagForPhoneNumber:phone];
if (phone.countryCode == nil) {
[self showAlertUnrecognizedCountryCode:phone];
[self.countryPicker setCountry:@"US"];
self.mobileTextField.text = self.countryCode;
}
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract_target 'driver_pods' do
#swift
# pod 'MRCountryPicker', :git => 'https://github.com/tedgonzalez/MRCountryPicker.git' #swift 3
# pod 'TrueTime', '~> 4.1.5' #swift 3
pod 'MRCountryPicker', :git => 'https://github.com/tedgonzalez/MRCountryPicker.git', :branch => 'objc' #swift 4
pod 'MRCountryPicker', :git => 'https://github.com/tedgonzalez/MRCountryPicker.git', :branch => 'fixed-canada-issue' #swift 4
pod 'TrueTime', :git => 'https://github.com/instacart/TrueTime.swift.git', :commit => '8aadebabe2590d6ab295c390df5bbc109b346348' #swift 4

#for testing
Expand Down
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ DEPENDENCIES:
- GooglePlaces
- LGRefreshView (~> 1)
- Mantle
- MRCountryPicker (from `https://github.com/tedgonzalez/MRCountryPicker.git`, branch `objc`)
- MRCountryPicker (from `https://github.com/tedgonzalez/MRCountryPicker.git`, branch `fixed-canada-issue`)
- "NSString+RemoveEmoji"
- OHHTTPStubs
- REFormattedNumberField
Expand Down Expand Up @@ -260,7 +260,7 @@ SPEC REPOS:

EXTERNAL SOURCES:
MRCountryPicker:
:branch: objc
:branch: fixed-canada-issue
:git: https://github.com/tedgonzalez/MRCountryPicker.git
TrueTime:
:commit: 8aadebabe2590d6ab295c390df5bbc109b346348
Expand All @@ -270,7 +270,7 @@ EXTERNAL SOURCES:

CHECKOUT OPTIONS:
MRCountryPicker:
:commit: 2da0e003ea17c20457eb3f96f435c2e59fb29eae
:commit: ec0c73b11809649848805957ae80df8a2ead352e
:git: https://github.com/tedgonzalez/MRCountryPicker.git
TrueTime:
:commit: 8aadebabe2590d6ab295c390df5bbc109b346348
Expand Down Expand Up @@ -329,6 +329,6 @@ SPEC CHECKSUMS:
UIActivityIndicator-for-SDWebImage: 7bf7ebbf0ed1747dedc0d6e949c4603a6d0f9e0c
XLForm: b8d47a9a00fb6166981cb40de7169d70d611e9be

PODFILE CHECKSUM: 4a031b432c3c0cf9ec78b26eefec10958c63c32e
PODFILE CHECKSUM: ae14423664436acf8b3d46d1a7f684cf119ac883

COCOAPODS: 1.5.3

0 comments on commit d16966c

Please sign in to comment.