From d16966c51c492570ff1a162835a28c752b0c026d Mon Sep 17 00:00:00 2001 From: Abdul Rehman Date: Tue, 19 Nov 2019 02:13:06 +0500 Subject: [PATCH] Use branch "fixed-canada-issue" for MRCountryPicker and updated the check for US --- .../Profile/EditViewController.m | 41 ++++++++++++++----- Podfile | 2 +- Podfile.lock | 8 ++-- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/FuelMeDriver/FuelMeDriver/Classes/ViewControllers/Profile/EditViewController.m b/FuelMeDriver/FuelMeDriver/Classes/ViewControllers/Profile/EditViewController.m index 1af1523..3f01aed 100644 --- a/FuelMeDriver/FuelMeDriver/Classes/ViewControllers/Profile/EditViewController.m +++ b/FuelMeDriver/FuelMeDriver/Classes/ViewControllers/Profile/EditViewController.m @@ -52,6 +52,7 @@ @interface EditViewController () @property (nonatomic) PhoneNumberFormatter* phoneNumberFormatter; @property (nonatomic) RAPhotoPickerControllerManager *pickerManager; @property (nonatomic) UIBarButtonItem *saveButton; +@property (nonatomic) BOOL changePhoneText; @end @@ -89,7 +90,7 @@ - (void)viewDidLoad { [self configureNavigationBar]; [self addEdgeInsetsToTextFields]; - + self.changePhoneText = YES; self.previousContentSize = self.scrollViewContainer.contentSize; [self configureCountryPicker]; [self configureData]; @@ -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 @@ -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; @@ -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; } diff --git a/Podfile b/Podfile index 7678ed4..7466a4d 100644 --- a/Podfile +++ b/Podfile @@ -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 diff --git a/Podfile.lock b/Podfile.lock index 206f614..b1ee066 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -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 @@ -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 @@ -270,7 +270,7 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: MRCountryPicker: - :commit: 2da0e003ea17c20457eb3f96f435c2e59fb29eae + :commit: ec0c73b11809649848805957ae80df8a2ead352e :git: https://github.com/tedgonzalez/MRCountryPicker.git TrueTime: :commit: 8aadebabe2590d6ab295c390df5bbc109b346348 @@ -329,6 +329,6 @@ SPEC CHECKSUMS: UIActivityIndicator-for-SDWebImage: 7bf7ebbf0ed1747dedc0d6e949c4603a6d0f9e0c XLForm: b8d47a9a00fb6166981cb40de7169d70d611e9be -PODFILE CHECKSUM: 4a031b432c3c0cf9ec78b26eefec10958c63c32e +PODFILE CHECKSUM: ae14423664436acf8b3d46d1a7f684cf119ac883 COCOAPODS: 1.5.3