diff --git a/iphone/Maps/Bookmarks/SelectSetVC.mm b/iphone/Maps/Bookmarks/SelectSetVC.mm index 4be8b6a6f8..bc0f88321b 100644 --- a/iphone/Maps/Bookmarks/SelectSetVC.mm +++ b/iphone/Maps/Bookmarks/SelectSetVC.mm @@ -112,10 +112,10 @@ } else { - auto const categoryId = [self.groupIds[indexPath.row] unsignedLongLongValue];; + auto const categoryId = [self.groupIds[indexPath.row] unsignedLongLongValue]; [self moveBookmarkToSetWithCategoryId:categoryId]; [self.delegate didSelectCategory:self.category withCategoryId:categoryId]; - [self backTap]; + [self goBack]; } } diff --git a/iphone/Maps/Categories/UIViewController+Navigation.h b/iphone/Maps/Categories/UIViewController+Navigation.h index 72a7db572d..598968371e 100644 --- a/iphone/Maps/Categories/UIViewController+Navigation.h +++ b/iphone/Maps/Categories/UIViewController+Navigation.h @@ -1,7 +1,6 @@ @interface UIViewController (Navigation) -- (void)showBackButton; -- (void)backTap; +- (void)goBack; - (UIBarButtonItem *)buttonWithImage:(UIImage *)image action:(SEL)action; - (NSArray *)alignedNavBarButtonItems:(NSArray *)items; diff --git a/iphone/Maps/Categories/UIViewController+Navigation.mm b/iphone/Maps/Categories/UIViewController+Navigation.mm index 87f561ba81..fe1ad3fa31 100644 --- a/iphone/Maps/Categories/UIViewController+Navigation.mm +++ b/iphone/Maps/Categories/UIViewController+Navigation.mm @@ -34,16 +34,6 @@ CGFloat constexpr kButtonExtraWidth = 16.0; return [@[ [self negativeSpacer] ] arrayByAddingObjectsFromArray:items]; } -- (UIBarButtonItem *)backButton -{ - return [self buttonWithImage:[UIImage imageNamed:@"ic_nav_bar_back"] action:@selector(backTap)]; -} - -- (void)showBackButton -{ - self.navigationItem.leftBarButtonItems = [self alignedNavBarButtonItems:@[ [self backButton] ]]; -} - -- (void)backTap { [self.navigationController popViewControllerAnimated:YES]; } +- (void)goBack { [self.navigationController popViewControllerAnimated:YES]; } @end diff --git a/iphone/Maps/Classes/Components/MWMNavigationController.mm b/iphone/Maps/Classes/Components/MWMNavigationController.mm index 5e9cee497e..0e70fa4097 100644 --- a/iphone/Maps/Classes/Components/MWMNavigationController.mm +++ b/iphone/Maps/Classes/Components/MWMNavigationController.mm @@ -37,9 +37,16 @@ NSAssert([viewController conformsToProtocol:@protocol(MWMController)], @"Controller must inherit ViewController or TableViewController class"); id vc = static_cast>(viewController); [navigationController setNavigationBarHidden:!vc.hasNavigationBar animated:animated]; +} - if ([navigationController.viewControllers count] > 1) - [viewController showBackButton]; +- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated +{ + auto topVC = self.viewControllers.lastObject; + topVC.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" + style:UIBarButtonItemStylePlain + target:nil + action:nil]; + [super pushViewController:viewController animated:animated]; } - (BOOL)shouldAutorotate diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 5f8539126e..4b0e2e7d9f 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -656,6 +656,10 @@ using namespace osm_auth_ios; navigationBar.titleTextAttributes = [self navigationBarTextAttributes]; navigationBar.translucent = NO; navigationBar.shadowImage = [UIImage new]; + auto backImage = [[UIImage imageNamed:@"ic_nav_bar_back_sys"] + imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; + navigationBar.backIndicatorImage = backImage; + navigationBar.backIndicatorTransitionMaskImage = backImage; } + (void)customizeAppearance diff --git a/iphone/Maps/Common/WebViewController.mm b/iphone/Maps/Common/WebViewController.mm index 95a5df7123..b68c25697c 100644 --- a/iphone/Maps/Common/WebViewController.mm +++ b/iphone/Maps/Common/WebViewController.mm @@ -6,6 +6,7 @@ @property(copy, nonatomic) MWMVoidBlock onFailure; @property(copy, nonatomic) MWMStringBlock onSuccess; +@property(nonatomic) BOOL authorized; @end @@ -90,11 +91,10 @@ [webView loadRequest:[NSURLRequest requestWithURL:self.m_url]]; } -- (void)backTap +- (void)viewDidDisappear:(BOOL)animated { - [self pop]; - - if (self.onFailure) + [super viewDidDisappear:animated]; + if (self.isMovingFromParentViewController && !self.authorized && self.onFailure) self.onFailure(); } @@ -113,11 +113,11 @@ { ASSERT(false, ("Incorrect query:", query.UTF8String)); [self pop]; - self.onFailure(); decisionHandler(WKNavigationActionPolicyCancel); return; } + self.authorized = YES; [self pop]; self.onSuccess(components[1]); decisionHandler(WKNavigationActionPolicyCancel); diff --git a/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/Contents.json b/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/Contents.json new file mode 100644 index 0000000000..920a5d06e9 --- /dev/null +++ b/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ic_nav_bar_back_sys.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "ic_nav_bar_back_sys@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "ic_nav_bar_back_sys@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/ic_nav_bar_back_sys.png b/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/ic_nav_bar_back_sys.png new file mode 100644 index 0000000000..f30a144011 Binary files /dev/null and b/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/ic_nav_bar_back_sys.png differ diff --git a/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/ic_nav_bar_back_sys@2x.png b/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/ic_nav_bar_back_sys@2x.png new file mode 100644 index 0000000000..47003b0836 Binary files /dev/null and b/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/ic_nav_bar_back_sys@2x.png differ diff --git a/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/ic_nav_bar_back_sys@3x.png b/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/ic_nav_bar_back_sys@3x.png new file mode 100644 index 0000000000..f5530bf2e6 Binary files /dev/null and b/iphone/Maps/Images.xcassets/Navigation Bar/ic_nav_bar_back_sys.imageset/ic_nav_bar_back_sys@3x.png differ diff --git a/iphone/Maps/UI/Downloader/MWMBaseMapDownloaderViewController.mm b/iphone/Maps/UI/Downloader/MWMBaseMapDownloaderViewController.mm index b8403c5581..bfc19bd7db 100644 --- a/iphone/Maps/UI/Downloader/MWMBaseMapDownloaderViewController.mm +++ b/iphone/Maps/UI/Downloader/MWMBaseMapDownloaderViewController.mm @@ -136,19 +136,6 @@ using namespace storage; - (void)configMyTarget { [MWMMyTarget manager].delegate = self; } -- (void)backTap -{ - UINavigationController * navVC = self.navigationController; - NSArray * viewControllers = navVC.viewControllers; - NSInteger const viewControllersCount = viewControllers.count; - NSInteger const prevVCIndex = viewControllersCount - 2; - Class const migrationClass = [MWMMigrationViewController class]; - if (prevVCIndex < 0 || [viewControllers[prevVCIndex] isKindOfClass:migrationClass]) - [navVC popToRootViewControllerAnimated:YES]; - else - [super backTap]; -} - - (void)notifyParentController { NSArray * viewControllers = [self.navigationController viewControllers]; diff --git a/iphone/Maps/UI/EditBookmark/MWMBookmarkColorViewController.mm b/iphone/Maps/UI/EditBookmark/MWMBookmarkColorViewController.mm index 3a18d84502..ca13a41375 100644 --- a/iphone/Maps/UI/EditBookmark/MWMBookmarkColorViewController.mm +++ b/iphone/Maps/UI/EditBookmark/MWMBookmarkColorViewController.mm @@ -76,7 +76,7 @@ array const kBookmarkColorsVariant [Statistics logEvent:kStatEventName(kStatPlacePage, kStatChangeBookmarkColor) withParameters:@{kStatValue : ios_bookmark_ui_helper::LocalizedTitleForBookmarkColor(bookmarkColor)}]; [self.delegate didSelectColor:bookmarkColor]; - [self backTap]; + [self goBack]; } @end diff --git a/iphone/Maps/UI/EditBookmark/MWMEditBookmarkController.mm b/iphone/Maps/UI/EditBookmark/MWMEditBookmarkController.mm index 360e0670be..26b8ef4b67 100644 --- a/iphone/Maps/UI/EditBookmark/MWMEditBookmarkController.mm +++ b/iphone/Maps/UI/EditBookmark/MWMEditBookmarkController.mm @@ -72,7 +72,6 @@ enum RowInMetaInfo - (void)configNavBar { - [self showBackButton]; self.title = L(@"bookmark").capitalizedString; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave @@ -113,7 +112,7 @@ enum RowInMetaInfo bookmark->SetCustomName(self.cachedTitle.UTF8String); f.UpdatePlacePageInfoForCurrentSelection(); - [self backTap]; + [self goBack]; } #pragma mark - UITableView @@ -253,7 +252,7 @@ enum RowInMetaInfo { [self.data updateBookmarkStatus:NO]; GetFramework().UpdatePlacePageInfoForCurrentSelection(); - [self backTap]; + [self goBack]; } #pragma mark - MWMNoteCellDelegate diff --git a/iphone/Maps/UI/Editor/MWMEditorViewController.mm b/iphone/Maps/UI/Editor/MWMEditorViewController.mm index b46bdada23..6b115e725e 100644 --- a/iphone/Maps/UI/Editor/MWMEditorViewController.mm +++ b/iphone/Maps/UI/Editor/MWMEditorViewController.mm @@ -194,6 +194,13 @@ void registerCellsForTableView(vector const & cells, UITableV self.featureStatus = osm::Editor::Instance().GetFeatureStatus(fid.m_mwmId, fid.m_index); self.isFeatureUploaded = osm::Editor::Instance().IsFeatureUploaded(fid.m_mwmId, fid.m_index); m_newAdditionalLanguages.clear(); + if (self.isCreating) + { + self.navigationItem.leftBarButtonItem = + [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(onCancel)]; + } } - (void)setFeatureToEdit:(FeatureID const &)fid @@ -226,27 +233,9 @@ void registerCellsForTableView(vector const & cells, UITableV action:@selector(onSave)]; } -- (void)backTap +- (void)onCancel { - if (self.isCreating) - [self.navigationController popToRootViewControllerAnimated:YES]; - else - [super backTap]; -} - -- (void)showBackButton -{ - if (self.isCreating) - { - self.navigationItem.leftBarButtonItem = - [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel - target:self - action:@selector(backTap)]; - } - else - { - [super showBackButton]; - } + [self.navigationController popToRootViewControllerAnimated:YES]; } #pragma mark - Actions @@ -969,7 +958,7 @@ void registerCellsForTableView(vector const & cells, UITableV atLocation:location]; GetFramework().CreateNote(self->m_mapObject, osm::Editor::NoteProblemType::PlaceDoesNotExist, additional); - [self backTap]; + [self goBack]; [self showDropDown]; }]; }; @@ -986,7 +975,7 @@ void registerCellsForTableView(vector const & cells, UITableV NSAssert(false, @"We shouldn't call this if we can't roll back!"); f.PokeSearchInViewport(); - [self backTap]; + [self goBack]; }; if (self.isFeatureUploaded) diff --git a/iphone/Maps/UI/Editor/MWMObjectsCategorySelectorController.mm b/iphone/Maps/UI/Editor/MWMObjectsCategorySelectorController.mm index d33d6e7510..b819fa5c88 100644 --- a/iphone/Maps/UI/Editor/MWMObjectsCategorySelectorController.mm +++ b/iphone/Maps/UI/Editor/MWMObjectsCategorySelectorController.mm @@ -82,17 +82,6 @@ string locale() self.selectedIndexPath = [NSIndexPath indexPathForRow:(distance(all.begin(), it)) inSection:0]; } -- (void)backTap -{ - id delegate = self.delegate; - if (delegate) - { - auto const object = self.createdObject; - [delegate reloadObject:object]; - } - [super backTap]; -} - - (UIStatusBarStyle)preferredStatusBarStyle { setStatusBarBackgroundColor(UIColor.clearColor); @@ -182,8 +171,13 @@ string locale() { self.selectedIndexPath = indexPath; - if (self.delegate) - [self backTap]; + id delegate = self.delegate; + if (delegate) + { + auto const object = self.createdObject; + [delegate reloadObject:object]; + [self goBack]; + } else [self performSegueWithIdentifier:kToEditorSegue sender:nil]; } diff --git a/iphone/Maps/UI/Migration/MWMMigrationViewController.mm b/iphone/Maps/UI/Migration/MWMMigrationViewController.mm index 5a4f44a55c..0184944771 100644 --- a/iphone/Maps/UI/Migration/MWMMigrationViewController.mm +++ b/iphone/Maps/UI/Migration/MWMMigrationViewController.mm @@ -8,11 +8,6 @@ #include "Framework.h" -namespace -{ -NSString * const kDownloaderSegue = @"Migration2MapDownloaderSegue"; -} // namespace - using namespace storage; @interface MWMStorage () @@ -68,7 +63,14 @@ using namespace storage; auto migrate = ^ { GetFramework().Migrate(!limited); - [self performSegueWithIdentifier:kDownloaderSegue sender:self]; + MWMMapDownloaderViewController * dvc = [self.storyboard + instantiateViewControllerWithIdentifier:@"MWMMapDownloaderViewController"]; + [dvc setParentCountryId:@(GetFramework().GetStorage().GetRootId().c_str()) + mode:MWMMapDownloaderModeDownloaded]; + NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers]; + [viewControllers removeLastObject]; + [viewControllers addObject:dvc]; + [self.navigationController setViewControllers:viewControllers animated:YES]; [Statistics logEvent:kStatDownloaderMigrationCompleted]; }; @@ -165,18 +167,6 @@ using namespace storage; [self setState:MWMMigrationViewState::Default]; } -#pragma mark - Segue - -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender -{ - if ([segue.identifier isEqualToString:kDownloaderSegue]) - { - MWMMapDownloaderViewController * dvc = segue.destinationViewController; - [dvc setParentCountryId:@(GetFramework().GetStorage().GetRootId().c_str()) - mode:MWMMapDownloaderModeDownloaded]; - } -} - #pragma mark - Actions - (IBAction)primaryAction diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCAddReview/UGCAddReviewController.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCAddReview/UGCAddReviewController.swift index 6a09c850ab..a33e1199ff 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCAddReview/UGCAddReviewController.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCAddReview/UGCAddReviewController.swift @@ -3,6 +3,7 @@ final class UGCAddReviewController: MWMTableViewController { typealias Model = UGCReviewModel weak var textCell: UGCAddReviewTextCell? + var reviewPosted = false enum Sections { case ratings @@ -34,10 +35,11 @@ final class UGCAddReviewController: MWMTableViewController { configTableView() } - override func backTap() { - guard let nc = navigationController else { return } - Statistics.logEvent(kStatUGCReviewCancel) - nc.popToRootViewController(animated: true) + override func viewDidDisappear(_ animated: Bool) { + super.viewDidDisappear(animated) + if isMovingFromParentViewController && !reviewPosted { + Statistics.logEvent(kStatUGCReviewCancel) + } } private func configNavBar() { @@ -59,6 +61,7 @@ final class UGCAddReviewController: MWMTableViewController { return } Statistics.logEvent(kStatUGCReviewSuccess) + reviewPosted = true model.text = text onSave(model) guard let nc = navigationController else { return }