diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h index c5fb5b49cd..adc10907c8 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h @@ -14,6 +14,5 @@ - (void)processMyPositionStateModeEvent:(MWMMyPositionMode)mode; + (void)updateAvailableArea:(CGRect)frame; -+ (CGRect)getAvailableArea; @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm index 1eab6ad453..f124aca68a 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm @@ -58,8 +58,6 @@ NSString * const kUDDidShowLongTapToShowSideButtonsToast = @"kUDDidShowLongTapTo + (void)updateAvailableArea:(CGRect)frame { [[self buttons].sideView updateAvailableArea:frame]; } -+ (CGRect)getAvailableArea { return [self buttons].sideView.getAvailableArea; } - - (void)zoomIn { GetFramework().Scale(Framework::SCALE_MAG, true); diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.h index aaffc37534..dee00bda0a 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.h @@ -8,6 +8,5 @@ - (void)setHidden:(BOOL)hidden animated:(BOOL)animated; - (void)updateAvailableArea:(CGRect)frame; -- (CGRect)getAvailableArea; @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm index ba8dd8ee50..bfea45c39b 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm @@ -144,10 +144,6 @@ CGFloat const kButtonsBottomOffset = 6; [self setNeedsLayout]; } -- (CGRect)getAvailableArea { - return self.availableArea; -} - - (CGFloat)availableHeight { return self.availableArea.size.height - kButtonsTopOffset - kButtonsBottomOffset; } diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm index 007a7c9949..9a0db02670 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm @@ -195,6 +195,8 @@ NSArray *imagesWithName(NSString *name) { if (CGRectEqualToRect(controller.availableArea, frame)) return; controller.availableArea = frame; + BOOL isHidden = frame.origin.y + frame.size.height < controller.view.origin.y + controller.view.height + kTopOffset; + [MapViewController.sharedController.controlsManager setTrafficButtonHidden:isHidden]; [controller refreshLayout]; } diff --git a/iphone/Maps/Classes/MapViewController.h b/iphone/Maps/Classes/MapViewController.h index 4bfe8abfcc..4926421070 100644 --- a/iphone/Maps/Classes/MapViewController.h +++ b/iphone/Maps/Classes/MapViewController.h @@ -7,6 +7,11 @@ @class MWMMapDownloadDialog; @class BookmarksCoordinator; @class SearchOnMapManager; +@class SideButtonsArea; +@class WidgetsArea; +@class TrafficButtonArea; +@class PlacePageArea; + @protocol MWMLocationModeListener; @interface MapViewController : MWMViewController @@ -54,4 +59,9 @@ @property(strong, nonatomic) IBOutlet UIView * _Nonnull controlsView; @property(nonatomic) UIView * _Nonnull searchContainer; +@property (weak, nonatomic) IBOutlet SideButtonsArea * sideButtonsArea; +@property (weak, nonatomic) IBOutlet WidgetsArea * widgetsArea; +@property (weak, nonatomic) IBOutlet TrafficButtonArea * trafficButtonArea; +@property (weak, nonatomic) IBOutlet PlacePageArea * placePageArea; + @end diff --git a/iphone/Maps/UI/AvailableArea/AvailableArea.swift b/iphone/Maps/UI/AvailableArea/AvailableArea.swift index 3e17cd5318..5da56ce68d 100644 --- a/iphone/Maps/UI/AvailableArea/AvailableArea.swift +++ b/iphone/Maps/UI/AvailableArea/AvailableArea.swift @@ -101,7 +101,10 @@ class AvailableArea: UIView { } func addConstraints(otherView: UIView, directions: MWMAvailableAreaAffectDirections) { - precondition(!directions.isEmpty) + guard !directions.isEmpty else { + LOG(.warning, "Attempt to add empty affecting directions from \(otherView) to \(self)") + return + } let add = { (sa: NSLayoutConstraint.Attribute, oa: NSLayoutConstraint.Attribute, rel: NSLayoutConstraint.Relation) in let c = NSLayoutConstraint(item: self, attribute: sa, relatedBy: rel, toItem: otherView, attribute: oa, multiplier: 1, constant: 0) c.priority = UILayoutPriority.defaultHigh diff --git a/iphone/Maps/UI/Search/SearchOnMap/Presentation/SearchOnMapPresentationController.swift b/iphone/Maps/UI/Search/SearchOnMap/Presentation/SearchOnMapPresentationController.swift index 5952710f87..2381216c57 100644 --- a/iphone/Maps/UI/Search/SearchOnMap/Presentation/SearchOnMapPresentationController.swift +++ b/iphone/Maps/UI/Search/SearchOnMap/Presentation/SearchOnMapPresentationController.swift @@ -32,11 +32,14 @@ final class SearchOnMapPresentationController: NSObject { private weak var presentedViewController: SearchOnMapViewController? private weak var parentViewController: UIViewController? private weak var containerView: UIView? + private let affectedAreas: [Weak] init(parentViewController: UIViewController, - containerView: UIView) { + containerView: UIView, + affectedAreas: Set = []) { self.parentViewController = parentViewController self.containerView = containerView + self.affectedAreas = affectedAreas.map { Weak(value: $0) } } func setViewController(_ viewController: SearchOnMapViewController) { @@ -47,6 +50,8 @@ final class SearchOnMapPresentationController: NSObject { viewController.view.frame = frameOfPresentedViewInContainerView viewController.didMove(toParent: parentViewController) + affectedAreas.forEach { $0.value?.addAffectingView(viewController.view) } + iPhoneSpecific { let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:))) panGestureRecognizer.delegate = self @@ -90,13 +95,6 @@ final class SearchOnMapPresentationController: NSObject { maxAvailableFrameOfPresentedView = ModalScreenPresentationStep.fullScreen.frame() } - private func updateSideButtonsAvailableArea(_ newY: CGFloat) { - guard presentedViewController?.traitCollection.verticalSizeClass != .compact else { return } - var sideButtonsAvailableArea = MWMSideButtons.getAvailableArea() - sideButtonsAvailableArea.size.height = newY - sideButtonsAvailableArea.origin.y - MWMSideButtons.updateAvailableArea(sideButtonsAvailableArea) - } - // MARK: - Pan gesture handling @objc private func handlePan(_ gesture: UIPanGestureRecognizer) { guard let presentedViewController, let presentedView = presentedViewController.view else { return } @@ -182,7 +180,6 @@ extension SearchOnMapPresentationController: ModallyPresentedViewController { func translationYDidUpdate(_ translationY: CGFloat) { iPhoneSpecific { presentedViewController?.translationYDidUpdate(translationY) - updateSideButtonsAvailableArea(translationY) } } } diff --git a/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapManager.swift b/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapManager.swift index 386e566b1a..b436555e1e 100644 --- a/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapManager.swift +++ b/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapManager.swift @@ -83,7 +83,11 @@ private struct SearchOnMapViewControllerBuilder { static func build(isRouting: Bool, didChangeState: @escaping ((SearchOnMapState) -> Void)) -> SearchOnMapViewController { let mapViewController = MapViewController.shared()! let presentationController = SearchOnMapPresentationController(parentViewController: mapViewController, - containerView: mapViewController.searchContainer) + containerView: mapViewController.searchContainer, + affectedAreas: [ + mapViewController.sideButtonsArea, + mapViewController.trafficButtonArea, + ]) let viewController = SearchOnMapViewController(presentationController: presentationController) let presenter = SearchOnMapPresenter(isRouting: isRouting, didChangeState: didChangeState) diff --git a/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapViewController.swift b/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapViewController.swift index 5d3a85b07f..95be2ece5a 100644 --- a/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapViewController.swift +++ b/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapViewController.swift @@ -48,6 +48,10 @@ final class SearchOnMapViewController: UIViewController { } // MARK: - Lifecycle + override func loadView() { + view = SearchOnMapAreaView() + } + override func viewDidLoad() { super.viewDidLoad() setupViews() @@ -357,3 +361,12 @@ extension SearchOnMapViewController: SearchTabViewControllerDelegate { } } +private class SearchOnMapAreaView: UIView { + override var sideButtonsAreaAffectDirections: MWMAvailableAreaAffectDirections { + alternative(iPhone: .bottom, iPad: []) + } + + override var trafficButtonAreaAffectDirections: MWMAvailableAreaAffectDirections { + alternative(iPhone: .bottom, iPad: []) + } +} diff --git a/iphone/Maps/UI/Storyboard/Main.storyboard b/iphone/Maps/UI/Storyboard/Main.storyboard index c1605e6180..c8cd3a0764 100644 --- a/iphone/Maps/UI/Storyboard/Main.storyboard +++ b/iphone/Maps/UI/Storyboard/Main.storyboard @@ -194,11 +194,15 @@ + + + +