diff --git a/iphone/Maps/Bookmarks/SelectSetVC.mm b/iphone/Maps/Bookmarks/SelectSetVC.mm index df42f43fe9..d6e2d8c88d 100644 --- a/iphone/Maps/Bookmarks/SelectSetVC.mm +++ b/iphone/Maps/Bookmarks/SelectSetVC.mm @@ -9,7 +9,6 @@ @interface SelectSetVC () @property (weak, nonatomic) MWMPlacePageViewManager * manager; -@property (nonatomic) CGFloat realPlacePageHeight; @end @@ -32,7 +31,6 @@ if (!self.iPadOwnerNavigationController) return; [self.iPadOwnerNavigationController setNavigationBarHidden:NO]; - self.realPlacePageHeight = self.iPadOwnerNavigationController.view.height; UIImage * backImage = [UIImage imageNamed:@"NavigationBarBackButton"]; UIButton * backButton = [[UIButton alloc] initWithFrame:CGRectMake(0., 0., backImage.size.width, backImage.size.height)]; [backButton addTarget:self action:@selector(backTap) forControlEvents:UIControlEventTouchUpInside]; @@ -52,7 +50,7 @@ - (void)backTap { - [self popViewController]; + [self.navigationController popViewControllerAnimated:YES]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation @@ -137,26 +135,8 @@ { [self moveBookmarkToSetWithIndex:static_cast(indexPath.row)]; [self.manager reloadBookmark]; - [self popViewController]; - } -} - -- (void)popViewController -{ - if (!self.iPadOwnerNavigationController) - { [self.navigationController popViewControllerAnimated:YES]; - return; } - - [UIView animateWithDuration:0.1 animations:^ - { - self.iPadOwnerNavigationController.view.height = self.realPlacePageHeight; - } - completion:^(BOOL finished) - { - [self.navigationController popViewControllerAnimated:YES]; - }]; } - (void)viewWillDisappear:(BOOL)animated diff --git a/iphone/Maps/Classes/MWMBookmarkColorViewController.mm b/iphone/Maps/Classes/MWMBookmarkColorViewController.mm index 574abf6f38..fa54c23d10 100644 --- a/iphone/Maps/Classes/MWMBookmarkColorViewController.mm +++ b/iphone/Maps/Classes/MWMBookmarkColorViewController.mm @@ -19,7 +19,6 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; @interface MWMBookmarkColorViewController () @property (weak, nonatomic) IBOutlet UITableView * tableView; -@property (nonatomic) CGFloat realPlacePageHeight; @property (nonatomic) BOOL colorWasChanged; @end @@ -39,7 +38,6 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; if (!self.iPadOwnerNavigationController) return; - self.realPlacePageHeight = self.iPadOwnerNavigationController.view.height; CGFloat const bottomOffset = 88.; self.iPadOwnerNavigationController.view.height = self.tableView.height + bottomOffset; UIImage * backImage = [UIImage imageNamed:@"NavigationBarBackButton"]; @@ -58,7 +56,7 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; - (void)backTap { - [self popViewController]; + [self.navigationController popViewControllerAnimated:YES]; } - (void)configureTableViewForOrientation:(UIInterfaceOrientation)orientation @@ -110,33 +108,13 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; return YES; } -- (void)popViewController -{ - if (!self.iPadOwnerNavigationController) - { - [self.navigationController popViewControllerAnimated:YES]; - return; - } - - [UIView animateWithDuration:0.1 animations:^ - { - self.iPadOwnerNavigationController.view.height = self.realPlacePageHeight; - } - completion:^(BOOL finished) - { - [self.navigationController popViewControllerAnimated:YES]; - }]; -} - - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; if (self.colorWasChanged && !self.iPadOwnerNavigationController) - { [self.placePageManager reloadBookmark]; - return; - } - self.iPadOwnerNavigationController.navigationBar.hidden = YES; + else + self.iPadOwnerNavigationController.navigationBar.hidden = YES; } @end diff --git a/iphone/Maps/Classes/MWMiPadPlacePage.mm b/iphone/Maps/Classes/MWMiPadPlacePage.mm index fe3cff06a4..431f0f0ce5 100644 --- a/iphone/Maps/Classes/MWMiPadPlacePage.mm +++ b/iphone/Maps/Classes/MWMiPadPlacePage.mm @@ -71,6 +71,22 @@ static CGFloat const kBottomOffset = 12.; [super pushViewController:viewController animated:animated]; } +- (UIViewController *)popViewControllerAnimated:(BOOL)animated +{ + NSUInteger const count = self.viewControllers.count; + CGFloat const height = count > 1 ? ((UIViewController *)self.viewControllers[count - 2]).view.height + self.navigationBar.height: 0.0; + + [UIView animateWithDuration:0.1 animations:^ + { + self.view.height = height; + } + completion:^(BOOL finished) + { + [super popViewControllerAnimated:animated]; + }]; + return self.viewControllers.lastObject; +} + @end @interface MWMiPadPlacePage () @@ -210,7 +226,7 @@ static CGFloat const kBottomOffset = 12.; - (void)updatePlacePagePosition { UIView * view = self.navigationController.view; - view.maxY = self.availableHeight + kTopOffset; + view.maxY = [self getAvailableHeight] + kTopOffset; view.minY = MIN(view.minY, self.topBound + kTopOffset); [self configureContentInset]; } @@ -235,7 +251,7 @@ static CGFloat const kBottomOffset = 12.; } } -- (CGFloat)availableHeight +- (CGFloat)getAvailableHeight { return self.parentViewHeight - self.keyboardHeight - kTopOffset - kBottomOffset; } @@ -244,7 +260,7 @@ static CGFloat const kBottomOffset = 12.; - (void)setHeight:(CGFloat)height { - _height = MIN(height, self.availableHeight); + _height = MIN(height, [self getAvailableHeight]); self.navigationController.view.height = _height; self.extendedPlacePageView.height = _height; } diff --git a/iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm b/iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm index df96426565..032c250efe 100644 --- a/iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm +++ b/iphone/Maps/Classes/MWMiPhonePortraitPlacePage.mm @@ -69,10 +69,12 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState) CGSize const size = UIScreen.mainScreen.bounds.size; CGFloat const width = MIN(size.width, size.height); CGFloat const height = MAX(size.width, size.height); - self.extendedPlacePageView.frame = CGRectMake(0., height, width, 2 * height); + UIView * ppv = self.extendedPlacePageView; + ppv.frame = CGRectMake(0., height, width, 2 * height); + _targetPoint = ppv.center; self.actionBar.width = width; self.actionBar.center = CGPointMake(width / 2., height + self.actionBar.height / 2.); - [self.manager addSubviews:@[self.extendedPlacePageView, self.actionBar] withNavigationController:nil]; + [self.manager addSubviews:@[ppv, self.actionBar] withNavigationController:nil]; [UIView animateWithDuration:0.3f delay:0. options:UIViewAnimationOptionCurveEaseOut animations:^ { self.actionBar.center = CGPointMake(width / 2., height - self.actionBar.height / 2.);