diff --git a/iphone/Maps/Classes/MWMPlacePage.h b/iphone/Maps/Classes/MWMPlacePage.h index 544f2c2a3e..aa8b898470 100644 --- a/iphone/Maps/Classes/MWMPlacePage.h +++ b/iphone/Maps/Classes/MWMPlacePage.h @@ -19,6 +19,7 @@ @property (weak, nonatomic, readonly) MWMPlacePageViewManager * manager; @property (nonatomic) MWMPlacePageActionBar * actionBar; @property (nonatomic) CGFloat topBound; +@property (nonatomic) CGFloat parentViewHeight; - (instancetype)initWithManager:(MWMPlacePageViewManager *)manager; - (void)show; diff --git a/iphone/Maps/Classes/MWMPlacePageViewManager.mm b/iphone/Maps/Classes/MWMPlacePageViewManager.mm index bca0128f79..a74df319b5 100644 --- a/iphone/Maps/Classes/MWMPlacePageViewManager.mm +++ b/iphone/Maps/Classes/MWMPlacePageViewManager.mm @@ -85,12 +85,20 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState) - (void)layoutPlacePageToOrientation:(UIInterfaceOrientation)orientation { - if (IPAD || !self.placePage) + if (!self.placePage) return; - [self.placePage dismiss]; - [self setPlacePageForiPhoneWithOrientation:orientation]; - [self configPlacePage]; + if (IPAD) + { + self.placePage.parentViewHeight = self.ownerViewController.view.width; + [(MWMiPadPlacePage *)self.placePage updatePlacePageLayout]; + } + else + { + [self.placePage dismiss]; + [self setPlacePageForiPhoneWithOrientation:orientation]; + [self configPlacePage]; + } } - (void)configPlacePage @@ -101,6 +109,7 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState) self.entity.category = [[MapsAppDelegate theApp].m_locationManager formattedSpeedAndAltitude:hasSpeed]; } self.placePage.topBound = self.topBound; + self.placePage.parentViewHeight = self.ownerViewController.view.height; [self.placePage configure]; [self refreshPlacePage]; } diff --git a/iphone/Maps/Classes/MWMiPadPlacePage.h b/iphone/Maps/Classes/MWMiPadPlacePage.h index d1a94a5170..b0e4510b83 100644 --- a/iphone/Maps/Classes/MWMiPadPlacePage.h +++ b/iphone/Maps/Classes/MWMiPadPlacePage.h @@ -10,4 +10,6 @@ @interface MWMiPadPlacePage : MWMPlacePage +- (void)updatePlacePageLayout; + @end diff --git a/iphone/Maps/Classes/MWMiPadPlacePage.mm b/iphone/Maps/Classes/MWMiPadPlacePage.mm index e2f8fd3e5a..02eeefaf60 100644 --- a/iphone/Maps/Classes/MWMiPadPlacePage.mm +++ b/iphone/Maps/Classes/MWMiPadPlacePage.mm @@ -19,6 +19,7 @@ extern CGFloat kBookmarkCellHeight; static CGFloat const kLeftOffset = 12.; static CGFloat const kTopOffset = 36.; +static CGFloat const kBottomOffset = 12.; @interface MWMiPadPlacePageViewController : UIViewController @@ -87,6 +88,7 @@ static CGFloat const kTopOffset = 36.; @interface MWMiPadPlacePage () @property (strong, nonatomic) MWMiPadNavigationController * navigationController; +@property (nonatomic) CGFloat height; @end @@ -97,16 +99,14 @@ static CGFloat const kTopOffset = 36.; [super configure]; CGFloat const defaultWidth = 360.; - CGFloat const actionBarHeight = 58.; - CGFloat const defaultHeight = self.basePlacePageView.height + self.anchorImageView.height + actionBarHeight - 1; + [self updatePlacePageLayout]; [self.manager addSubviews:@[self.navigationController.view] withNavigationController:self.navigationController]; - self.navigationController.view.frame = CGRectMake( -defaultWidth, self.topBound + kTopOffset, defaultWidth, defaultHeight); - self.extendedPlacePageView.frame = CGRectMake(0., 0., defaultWidth, defaultHeight); + self.navigationController.view.frame = CGRectMake( -defaultWidth, self.topBound + kTopOffset, defaultWidth, self.height); + self.extendedPlacePageView.frame = CGRectMake(0., 0., defaultWidth, self.height); self.anchorImageView.image = nil; self.anchorImageView.backgroundColor = [UIColor whiteColor]; self.actionBar.width = defaultWidth; - self.actionBar.origin = CGPointMake(0., defaultHeight - actionBarHeight); } - (void)show @@ -139,25 +139,20 @@ static CGFloat const kTopOffset = 36.; - (void)willFinishEditingBookmarkTitle:(NSString *)title { [super willFinishEditingBookmarkTitle:title]; - CGFloat const actionBarHeight = self.actionBar.height; - CGFloat const defaultHeight = self.basePlacePageView.height + self.anchorImageView.height + actionBarHeight - 1; - self.actionBar.origin = CGPointMake(0., defaultHeight - actionBarHeight); - self.navigationController.view.height = defaultHeight; + [self updatePlacePageLayout]; } - (void)addBookmark { [super addBookmark]; - self.navigationController.view.height += kBookmarkCellHeight; - self.extendedPlacePageView.height += kBookmarkCellHeight; + self.height += kBookmarkCellHeight; self.actionBar.minY += kBookmarkCellHeight; } - (void)removeBookmark { [super removeBookmark]; - self.navigationController.view.height -= kBookmarkCellHeight; - self.extendedPlacePageView.height -= kBookmarkCellHeight; + self.height -= kBookmarkCellHeight; self.actionBar.minY -= kBookmarkCellHeight; } @@ -204,8 +199,22 @@ static CGFloat const kTopOffset = 36.; } } +- (void)updatePlacePageLayout +{ + CGFloat const actionBarHeight = self.actionBar.height; + self.height = self.basePlacePageView.height + self.anchorImageView.height + actionBarHeight - 1; + self.actionBar.origin = CGPointMake(0., self.height - actionBarHeight); +} + #pragma mark - Properties +- (void)setHeight:(CGFloat)height +{ + _height = MIN(height, self.parentViewHeight - kTopOffset - kBottomOffset); + self.navigationController.view.height = _height; + self.extendedPlacePageView.height = _height; +} + - (MWMiPadNavigationController *)navigationController { if (!_navigationController)