diff --git a/iphone/Maps/Classes/MapViewController.h b/iphone/Maps/Classes/MapViewController.h index cb92d474e8..6c5d031ea8 100644 --- a/iphone/Maps/Classes/MapViewController.h +++ b/iphone/Maps/Classes/MapViewController.h @@ -38,7 +38,7 @@ - (void)openDrivingOptions; - (void)showRemoveAds; -- (void)setPlacePageTopBound:(CGFloat)bound; +- (void)setPlacePageTopBound:(CGFloat)bound duration:(double)duration; + (void)setViewport:(double)lat lon:(double)lon zoomLevel:(int)zoomlevel; diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 34cb904f2c..180efdfb74 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -155,6 +155,7 @@ NSString *const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing"; [self.view layoutIfNeeded]; self.guidesCollectionContainer.alpha = 1; }]; + [self setPlacePageTopBound:self.view.height - self.guidesCollectionContainer.minY duration:kDefaultAnimationDuration]; } - (void)showPlacePage { @@ -180,6 +181,7 @@ NSString *const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing"; [self.placePageVC removeFromParentViewController]; self.placePageVC = nil; self.placePageContainer.hidden = YES; + [self setPlacePageTopBound:0 duration:0]; } - (void)hideGuidesGallery { @@ -197,6 +199,7 @@ NSString *const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing"; self.guidesCollectionContainer.hidden = YES; self.guidesVisibleConstraint.constant = 48; }]; + [self setPlacePageTopBound:0 duration:kDefaultAnimationDuration]; } - (void)hidePlacePage { @@ -863,9 +866,12 @@ NSString *const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing"; return _downloadDialog; } -- (void)setPlacePageTopBound:(CGFloat)bound { +- (void)setPlacePageTopBound:(CGFloat)bound duration:(double)duration { self.visibleAreaBottom.constant = bound; self.sideButtonsAreaBottom.constant = bound; + [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ + [self.view layoutIfNeeded]; + } completion:nil]; } + (void)setViewport:(double)lat lon:(double)lon zoomLevel:(int)zoomLevel { diff --git a/iphone/Maps/UI/PlacePage/PlacePageBuilder.swift b/iphone/Maps/UI/PlacePage/PlacePageBuilder.swift index 5333b5ac64..d8fbf84e8c 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageBuilder.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageBuilder.swift @@ -6,7 +6,9 @@ } let data = PlacePageData(localizationProvider: OpeinigHoursLocalization()) viewController.isPreviewPlus = data.isPreviewPlus - let interactor = PlacePageInteractor(viewController: viewController, data: data) + let interactor = PlacePageInteractor(viewController: viewController, + data: data, + mapViewController: MapViewController.shared()) let layout:IPlacePageLayout if data.elevationProfileData != nil { layout = PlacePageElevationLayout(interactor: interactor, storyboard: storyboard, data: data) diff --git a/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift b/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift index 413ffe11c7..2a21375bbe 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift @@ -1,21 +1,25 @@ protocol PlacePageInteractorProtocol: class { - + func updateTopBound(_ bound: CGFloat, duration: TimeInterval) } class PlacePageInteractor { weak var presenter: PlacePagePresenterProtocol? weak var viewController: UIViewController? + weak var mapViewController: MapViewController? private var placePageData: PlacePageData - init (viewController: UIViewController, data: PlacePageData) { + init (viewController: UIViewController, data: PlacePageData, mapViewController: MapViewController) { self.placePageData = data self.viewController = viewController + self.mapViewController = mapViewController } } extension PlacePageInteractor: PlacePageInteractorProtocol { - + func updateTopBound(_ bound: CGFloat, duration: TimeInterval) { + mapViewController?.setPlacePageTopBound(bound, duration: duration) + } } // MARK: - PlacePagePreviewViewControllerDelegate diff --git a/iphone/Maps/UI/PlacePage/PlacePagePresenter.swift b/iphone/Maps/UI/PlacePage/PlacePagePresenter.swift index 2c43f90fa6..2682cd1133 100644 --- a/iphone/Maps/UI/PlacePage/PlacePagePresenter.swift +++ b/iphone/Maps/UI/PlacePage/PlacePagePresenter.swift @@ -3,6 +3,7 @@ protocol PlacePagePresenterProtocol: class { func layoutIfNeeded() func showNextStop() func closeAnimated() + func updateTopBound(_ bound: CGFloat, duration: TimeInterval) } class PlacePagePresenter: NSObject { @@ -38,4 +39,8 @@ extension PlacePagePresenter: PlacePagePresenterProtocol { func closeAnimated() { view.closeAnimated() } + + func updateTopBound(_ bound: CGFloat, duration: TimeInterval) { + interactor.updateTopBound(bound, duration: duration) + } } diff --git a/iphone/Maps/UI/PlacePage/PlacePageViewController.swift b/iphone/Maps/UI/PlacePage/PlacePageViewController.swift index 8da3c17fb1..cb95071fa0 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageViewController.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageViewController.swift @@ -166,6 +166,13 @@ final class PlacePageScrollView: UIScrollView { } } } + + func updateTopBound(_ bound: CGFloat, duration:TimeInterval) { + alternativeSizeClass(iPhone: { + let isLandscape = UIDevice.current.orientation == .landscapeLeft || UIDevice.current.orientation == .landscapeRight + presenter.updateTopBound(isLandscape ? 0 : bound , duration: duration) + }, iPad: {}) + } } extension PlacePageViewController: PlacePageViewProtocol { @@ -222,7 +229,9 @@ extension PlacePageViewController: PlacePageViewProtocol { beginDragging = true } let scrollPosition = CGPoint(x: point.x, y: min((scrollView.contentSize.height - scrollView.height), point.y)) + let bound = self.view.height + scrollPosition.y if animated { + updateTopBound(bound, duration: kDefaultAnimationDuration) UIView.animate(withDuration: kDefaultAnimationDuration, animations: { [weak scrollView] in scrollView?.contentOffset = scrollPosition self.layoutIfNeeded() @@ -275,6 +284,9 @@ extension PlacePageViewController: UIScrollViewDelegate { rootViewController.dismissPlacePage() } onOffsetChanged(scrollView.contentOffset.y) + + let bound = self.view.height + scrollView.contentOffset.y + updateTopBound(bound, duration: 0) } func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {