From 1a72a7782aa0eda4a78b61b09f67a31aa11d88c2 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Fri, 15 Jan 2016 20:17:49 +0300 Subject: [PATCH] [ios] Updated authorization ui. --- .../CustomViews/Login/MWMAuthorizationCommon.h | 3 +++ .../Login/MWMAuthorizationCommon.mm | 12 ++++++++++++ .../MWMAuthorizationLoginViewController.h | 2 ++ .../MWMAuthorizationLoginViewController.mm | 8 +++++++- .../Classes/Editor/MWMEditorViewController.mm | 18 +++++++++++++++--- iphone/Maps/Mapsme.storyboard | 6 ++++-- iphone/Maps/SettingsAndMoreVC.mm | 5 +++-- 7 files changed, 46 insertions(+), 8 deletions(-) diff --git a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.h b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.h index e82d180362..c4db7b324c 100644 --- a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.h +++ b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.h @@ -13,3 +13,6 @@ void MWMAuthorizationConfigButton(UIButton * btn, MWMAuthorizationButtonType typ void MWMAuthorizationStoreCredentials(osm::TKeySecret const & keySecret); BOOL MWMAuthorizationHaveCredentials(); + +void MWMAuthorizationSetUserSkip(); +BOOL MWMAuthorizationIsUserSkip(); diff --git a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.mm b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.mm index 84d402b603..49e80d45fc 100644 --- a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.mm +++ b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationCommon.mm @@ -5,6 +5,7 @@ namespace { NSString * const kOSMRequestToken = @"OSMRequestToken"; NSString * const kOSMRequestSecret = @"OSMRequestSecret"; +NSString * const kAuthUserSkip = @"AuthUserSkip"; } // namespace UIColor * MWMAuthorizationButtonTextColor(MWMAuthorizationButtonType type) @@ -64,3 +65,14 @@ BOOL MWMAuthorizationHaveCredentials() NSString * requestSecret = [ud stringForKey:kOSMRequestSecret]; return requestToken && requestSecret; } + +void MWMAuthorizationSetUserSkip() +{ + NSUserDefaults * ud = [NSUserDefaults standardUserDefaults]; + [ud setObject:[NSDate date] forKey:kAuthUserSkip]; +} + +BOOL MWMAuthorizationIsUserSkip() +{ + return [[NSUserDefaults standardUserDefaults] objectForKey:kAuthUserSkip] != nil; +} diff --git a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.h b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.h index ef7d4628a2..aec78e0ea2 100644 --- a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.h +++ b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.h @@ -2,4 +2,6 @@ @interface MWMAuthorizationLoginViewController : ViewController +@property (nonatomic) BOOL isCalledFromSettings; + @end diff --git a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.mm b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.mm index 1991a43a9f..6a6c5804e9 100644 --- a/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.mm +++ b/iphone/Maps/Classes/CustomViews/Login/MWMAuthorizationLoginViewController.mm @@ -81,7 +81,13 @@ - (IBAction)cancel { - [self dismissViewControllerAnimated:YES completion:nil]; + if (!self.isCalledFromSettings) + MWMAuthorizationSetUserSkip(); + UINavigationController * parentNavController = self.navigationController.navigationController; + if (parentNavController) + [parentNavController popViewControllerAnimated:YES]; + else + [self dismissViewControllerAnimated:YES completion:nil]; } #pragma mark - Segue diff --git a/iphone/Maps/Classes/Editor/MWMEditorViewController.mm b/iphone/Maps/Classes/Editor/MWMEditorViewController.mm index 07288cd5b6..9de22fa77b 100644 --- a/iphone/Maps/Classes/Editor/MWMEditorViewController.mm +++ b/iphone/Maps/Classes/Editor/MWMEditorViewController.mm @@ -1,4 +1,5 @@ #import "MWMAuthorizationCommon.h" +#import "MWMAuthorizationLoginViewController.h" #import "MWMCuisineEditorViewController.h" #import "MWMEditorCommon.h" #import "MWMEditorSelectTableViewCell.h" @@ -19,6 +20,7 @@ namespace NSString * const kOpeningHoursEditorSegue = @"Editor2OpeningHoursEditorSegue"; NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue"; NSString * const kStreetEditorSegue = @"Editor2StreetEditorSegue"; +NSString * const kAuthorizationSegue = @"Editor2AuthorizationSegue"; typedef NS_ENUM(NSUInteger, MWMEditorSection) { @@ -101,11 +103,11 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) - (void)checkAuthorization { - if (!MWMAuthorizationHaveCredentials()) + if (!MWMAuthorizationHaveCredentials() && !MWMAuthorizationIsUserSkip()) { [[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime) withParameters:@{kStatValue : kStatAuthorization}]; - [self performSegueWithIdentifier:@"Editor2AuthorizationSegue" sender:nil]; + [self performSegueWithIdentifier:kAuthorizationSegue sender:nil]; } } @@ -129,7 +131,11 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) - (void)onCancel { - [self dismissViewControllerAnimated:YES completion:nil]; + UINavigationController * parentNavController = self.navigationController.navigationController; + if (parentNavController) + [parentNavController popViewControllerAnimated:YES]; + else + [self dismissViewControllerAnimated:YES completion:nil]; } - (void)onSave @@ -567,6 +573,12 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType) MWMStreetEditorViewController * dvc = segue.destinationViewController; dvc.delegate = self; } + else if ([segue.identifier isEqualToString:kAuthorizationSegue]) + { + UINavigationController * dvc = segue.destinationViewController; + MWMAuthorizationLoginViewController * authVC = (MWMAuthorizationLoginViewController *)[dvc topViewController]; + authVC.isCalledFromSettings = NO; + } } @end diff --git a/iphone/Maps/Mapsme.storyboard b/iphone/Maps/Mapsme.storyboard index de2b951752..11e4f1af48 100644 --- a/iphone/Maps/Mapsme.storyboard +++ b/iphone/Maps/Mapsme.storyboard @@ -10,6 +10,7 @@ HelveticaNeue-Medium + HelveticaNeue-Medium @@ -1713,9 +1714,10 @@ the world. Join us! + - + @@ -2321,6 +2323,6 @@ the world. Join us! - + diff --git a/iphone/Maps/SettingsAndMoreVC.mm b/iphone/Maps/SettingsAndMoreVC.mm index 9f7dd7a250..aad367af19 100644 --- a/iphone/Maps/SettingsAndMoreVC.mm +++ b/iphone/Maps/SettingsAndMoreVC.mm @@ -1,4 +1,5 @@ #import "CommunityVC.h" +#import "MWMAuthorizationLoginViewController.h" #import "RichTextVC.h" #import "SettingsAndMoreVC.h" #import "SettingsViewController.h" @@ -164,8 +165,8 @@ extern NSDictionary * const deviceNames = @{@"x86_64" : @"Simulator", { [[Statistics instance] logEvent:kStatSettingsOpenSection withParameters:@{kStatName : kStatAuthorization}]; UINavigationController * vc = [self.mainStoryboard instantiateViewControllerWithIdentifier:@"LoginNavigationController"]; - vc.modalPresentationStyle = UIModalPresentationFormSheet; - vc.preferredContentSize = {520, 600}; + MWMAuthorizationLoginViewController * authVC = (MWMAuthorizationLoginViewController *)[vc topViewController]; + authVC.isCalledFromSettings = YES; [self.navigationController presentViewController:vc animated:YES completion:nil]; }