From ac591be49343af3c9b69684d1485073f1b845133 Mon Sep 17 00:00:00 2001 From: Kiryl Kaveryn Date: Tue, 21 Nov 2023 21:08:28 +0400 Subject: [PATCH] [ios] fix: pin the PlacePage view to the Search view on iPad Signed-off-by: Kiryl Kaveryn --- iphone/Maps/Classes/MapViewController.h | 1 + .../Maps/UI/Search/MWMSearchManager+Layout.m | 1 - iphone/Maps/UI/Search/MWMSearchManager.h | 2 + iphone/Maps/UI/Search/MWMSearchManager.mm | 23 ++- iphone/Maps/UI/Storyboard/Main.storyboard | 155 ++++++++++-------- 5 files changed, 106 insertions(+), 76 deletions(-) diff --git a/iphone/Maps/Classes/MapViewController.h b/iphone/Maps/Classes/MapViewController.h index b07986b47f..94865f1f11 100644 --- a/iphone/Maps/Classes/MapViewController.h +++ b/iphone/Maps/Classes/MapViewController.h @@ -47,5 +47,6 @@ @property(strong, nonatomic) IBOutlet EAGLView * _Nonnull mapView; @property(strong, nonatomic) IBOutlet UIView * _Nonnull controlsView; @property(strong, nonatomic) IBOutlet UIView * _Nonnull searchViewContainer; +@property(strong, nonatomic) IBOutlet NSLayoutConstraint * _Nonnull searchViewContainerLeadingConstraint; @end diff --git a/iphone/Maps/UI/Search/MWMSearchManager+Layout.m b/iphone/Maps/UI/Search/MWMSearchManager+Layout.m index f5ed87b18f..2220e61943 100644 --- a/iphone/Maps/UI/Search/MWMSearchManager+Layout.m +++ b/iphone/Maps/UI/Search/MWMSearchManager+Layout.m @@ -2,7 +2,6 @@ #import "MWMSearchManager+Layout.h" #import "MapViewController.h" -static CGFloat const kWidthForiPad = 320.0; static CGFloat const changeModeViewOffsetNormal = -24; static CGFloat const changeModeViewOffsetKeyboard = -12; diff --git a/iphone/Maps/UI/Search/MWMSearchManager.h b/iphone/Maps/UI/Search/MWMSearchManager.h index 7b5ed4346e..8c3309dd73 100644 --- a/iphone/Maps/UI/Search/MWMSearchManager.h +++ b/iphone/Maps/UI/Search/MWMSearchManager.h @@ -11,6 +11,8 @@ typedef NS_ENUM(NSInteger, MWMSearchManagerRoutingTooltipSearch) { @interface MWMSearchManager : NSObject +extern const CGFloat kWidthForiPad; + + (nonnull MWMSearchManager *)manager NS_SWIFT_NAME(manager()); + (void)addObserver:(nonnull id)observer; + (void)removeObserver:(nonnull id)observer; diff --git a/iphone/Maps/UI/Search/MWMSearchManager.mm b/iphone/Maps/UI/Search/MWMSearchManager.mm index afabe94d26..73e33deb90 100644 --- a/iphone/Maps/UI/Search/MWMSearchManager.mm +++ b/iphone/Maps/UI/Search/MWMSearchManager.mm @@ -20,6 +20,8 @@ using Observer = id; using Observers = NSHashTable; } // namespace +const CGFloat kWidthForiPad = 320; + @interface MWMMapViewControlsManager () @property(nonatomic) MWMSearchManager *searchManager; @@ -471,13 +473,23 @@ using Observers = NSHashTable; [parentView addSubview:contentView]; [parentView addSubview:actionBarView]; [self layoutTopViews]; + // Set Search controller default hidden state for iPad before it will be shown. + if (IPAD) { + self.searchViewContainerLeadingConstraint.constant = -kWidthForiPad; + [parentView.superview layoutIfNeeded]; + } } [UIView animateWithDuration:kDefaultAnimationDuration animations:^{ - CGFloat const alpha = hidden ? 0 : 1; - contentView.alpha = alpha; - actionBarView.alpha = alpha; - searchBarView.alpha = alpha; + if (IPAD) { + self.searchViewContainerLeadingConstraint.constant = hidden ? -kWidthForiPad : 0; + [parentView.superview layoutIfNeeded]; + } else { + CGFloat const alpha = hidden ? 0 : 1; + contentView.alpha = alpha; + actionBarView.alpha = alpha; + searchBarView.alpha = alpha; + } } completion:^(BOOL finished) { if (!hidden) @@ -509,6 +521,9 @@ using Observers = NSHashTable; - (UIView *)searchViewContainer { return [MapViewController sharedController].searchViewContainer; } +- (NSLayoutConstraint *)searchViewContainerLeadingConstraint { + return [MapViewController sharedController].searchViewContainerLeadingConstraint; +} - (UIView *)actionBarContainer { return [MapViewController sharedController].controlsView; } diff --git a/iphone/Maps/UI/Storyboard/Main.storyboard b/iphone/Maps/UI/Storyboard/Main.storyboard index 88e673ee1f..220bcba5fb 100644 --- a/iphone/Maps/UI/Storyboard/Main.storyboard +++ b/iphone/Maps/UI/Storyboard/Main.storyboard @@ -1,9 +1,9 @@ - - + + - + @@ -13,29 +13,29 @@ - + - + - + @@ -97,10 +97,12 @@ - + - + + + @@ -124,7 +126,7 @@ - + @@ -183,17 +185,18 @@ + - + - + @@ -232,6 +235,8 @@ + + @@ -240,6 +245,7 @@ + @@ -247,6 +253,11 @@ + + + + + @@ -263,10 +274,11 @@ - + + @@ -278,6 +290,7 @@ + @@ -324,7 +337,7 @@ - + @@ -344,7 +357,7 @@ - + @@ -360,7 +373,7 @@ - + @@ -386,11 +399,11 @@ - + - + @@ -401,10 +414,10 @@ - + - + @@ -421,7 +434,7 @@ - + @@ -430,7 +443,7 @@ - + @@ -439,7 +452,7 @@ - + @@ -448,7 +461,7 @@ - + @@ -457,13 +470,13 @@ - + - + - + @@ -483,7 +496,7 @@ - + @@ -492,7 +505,7 @@ - + @@ -589,7 +602,7 @@ - + @@ -657,26 +670,26 @@ - + - + - + - + @@ -746,7 +759,7 @@ - + @@ -791,11 +804,11 @@ - + - + @@ -806,7 +819,7 @@ - + @@ -817,7 +830,7 @@ - + @@ -861,11 +874,11 @@ - + - + @@ -877,13 +890,13 @@ - + @@ -928,20 +941,20 @@ - + - + - + - +