[iOS] Restored map buttons offset

https://jira.mail.ru/browse/MAPSME-14016
This commit is contained in:
Alexander Boriskov 2020-06-16 15:01:04 +03:00 committed by Vladimir Byko-Ianko
parent 7e3ea1caf0
commit d5f613820f
6 changed files with 35 additions and 6 deletions

View file

@ -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;

View file

@ -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 {

View file

@ -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)

View file

@ -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

View file

@ -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)
}
}

View file

@ -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) {