From 0cc74c336de08726277751f3325fdd7b8351cb65 Mon Sep 17 00:00:00 2001 From: "v.mikhaylenko" Date: Wed, 24 Jun 2015 10:42:31 +0300 Subject: [PATCH] [ios] Fixed bug with wrong place page content inset in landscape. --- .../Classes/MWMiPhoneLandscapePlacePage.mm | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/iphone/Maps/Classes/MWMiPhoneLandscapePlacePage.mm b/iphone/Maps/Classes/MWMiPhoneLandscapePlacePage.mm index 2091c1309d..6f436d1405 100644 --- a/iphone/Maps/Classes/MWMiPhoneLandscapePlacePage.mm +++ b/iphone/Maps/Classes/MWMiPhoneLandscapePlacePage.mm @@ -38,13 +38,9 @@ typedef NS_ENUM(NSUInteger, MWMiPhoneLandscapePlacePageState) - (void)configure { [super configure]; - CGSize const size = UIScreen.mainScreen.bounds.size; - CGFloat const height = MIN(size.width, size.height); self.anchorImageView.backgroundColor = [UIColor whiteColor]; self.anchorImageView.image = nil; - CGFloat const headerViewHeight = self.basePlacePageView.height - self.basePlacePageView.featureTable.height; - CGFloat const tableContentHeight = self.basePlacePageView.featureTable.contentSize.height; - self.basePlacePageView.featureTable.contentInset = UIEdgeInsetsMake(0., 0., self.actionBar.height + (tableContentHeight - height - headerViewHeight + self.anchorImageView.height), 0.); + [self configureContentInset]; [self.extendedPlacePageView addSubview:self.actionBar]; [self.manager addSubviews:@[self.extendedPlacePageView] withNavigationController:nil]; } @@ -54,6 +50,44 @@ typedef NS_ENUM(NSUInteger, MWMiPhoneLandscapePlacePageState) self.state = MWMiPhoneLandscapePlacePageStateOpen; } +- (void)dismiss +{ + self.state = MWMiPhoneLandscapePlacePageStateClosed; +} + +- (void)configureContentInset +{ + CGFloat const height = self.extendedPlacePageView.height - self.anchorImageView.height; + CGFloat const actionBarHeight = self.actionBar.height; + UITableView * featureTable = self.basePlacePageView.featureTable; + CGFloat const tableContentHeight = featureTable.contentSize.height; + CGFloat const headerViewHeight = self.basePlacePageView.separatorView.maxY; + CGFloat const availableTableHeight = height - headerViewHeight - actionBarHeight; + CGFloat const externalHeight = tableContentHeight - availableTableHeight; + if (externalHeight > 0) + { + featureTable.contentInset = UIEdgeInsetsMake(0., 0., externalHeight, 0.); + featureTable.scrollEnabled = YES; + } + else + { + [featureTable setContentOffset:CGPointZero animated:YES]; + featureTable.scrollEnabled = NO; + } +} + +- (void)addBookmark +{ + [super addBookmark]; + [self configureContentInset]; +} + +- (void)removeBookmark +{ + [super removeBookmark]; + [self configureContentInset]; +} + - (void)updateTargetPoint { CGSize const size = UIScreen.mainScreen.bounds.size; @@ -136,6 +170,7 @@ typedef NS_ENUM(NSUInteger, MWMiPhoneLandscapePlacePageState) self.actionBar.minX = 0.0; self.actionBar.maxY = height - topBound; [self updateTargetPoint]; + [self configureContentInset]; } - (void)setTargetPoint:(CGPoint)targetPoint