diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h index 1a325c25b8..28d7963528 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h @@ -6,6 +6,7 @@ @class MapViewController; @class BottomTabBarViewController; @class TrackRecordingViewController; + @protocol MWMFeatureHolder; @interface MWMMapViewControlsManager : NSObject @@ -47,7 +48,6 @@ - (void)actionDownloadMaps:(MWMMapDownloaderMode)mode; - (BOOL)searchText:(NSString *)text forInputLocale:(NSString *)locale; - (void)searchTextOnMap:(NSString *)text forInputLocale:(NSString *)locale; -- (void)hideSearch; #pragma mark - MWMFeatureHolder diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 8944fc2075..8357f5e63e 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -5,7 +5,6 @@ #import "MWMNetworkPolicy+UI.h" #import "MWMPlacePageManager.h" #import "MWMPlacePageProtocol.h" -#import "MWMSearchManager.h" #import "MWMSideButtons.h" #import "MWMTrafficButtonViewController.h" #import "MWMMapWidgetsHelper.h" @@ -27,8 +26,7 @@ namespace { NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; } // namespace -@interface MWMMapViewControlsManager () +@interface MWMMapViewControlsManager () @property(nonatomic) MWMSideButtons *sideButtons; @property(nonatomic) MWMTrafficButtonViewController *trafficButton; @@ -36,7 +34,7 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; @property(nonatomic) UIViewController *menuController; @property(nonatomic) id placePageManager; @property(nonatomic) MWMNavigationDashboardManager *navigationManager; -@property(nonatomic) MWMSearchManager *searchManager; +@property(nonatomic) SearchOnMapManager *searchManager; @property(weak, nonatomic) MapViewController *ownerController; @@ -50,6 +48,7 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; + (MWMMapViewControlsManager *)manager { return [MapViewController sharedController].controlsManager; } + - (instancetype)initWithParentController:(MapViewController *)controller { if (!controller) return nil; @@ -67,6 +66,7 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; [TrackRecordingManager.shared addObserver:self recordingIsActiveDidChangeHandler:^(TrackRecordingState state, TrackInfo * trackInfo) { [self setTrackRecordingButtonHidden:state == TrackRecordingStateInactive]; }]; + self.searchManager = controller.searchManager; return self; } @@ -75,7 +75,6 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; } - (UIStatusBarStyle)preferredStatusBarStyle { - BOOL const isSearchUnderStatusBar = (self.searchManager.state != MWMSearchManagerStateHidden); BOOL const isNavigationUnderStatusBar = self.navigationManager.state != MWMNavigationDashboardStateHidden && self.navigationManager.state != MWMNavigationDashboardStateNavigation; BOOL const isMenuViewUnderStatusBar = self.menuState == MWMBottomMenuStateActive; @@ -83,7 +82,7 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; BOOL const isAddPlaceUnderStatusBar = [self.ownerController.view hasSubviewWithViewClass:[MWMAddPlaceNavigationBar class]]; BOOL const isNightMode = [UIColor isNightMode]; - BOOL const isSomethingUnderStatusBar = isSearchUnderStatusBar || isNavigationUnderStatusBar || + BOOL const isSomethingUnderStatusBar = isNavigationUnderStatusBar || isDirectionViewUnderStatusBar || isMenuViewUnderStatusBar || isAddPlaceUnderStatusBar; @@ -101,7 +100,6 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; [self.trafficButton viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [self.trackRecordingButton viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; [self.tabBarController viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; - [self.searchManager viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; } #pragma mark - MWMPlacePageViewManager @@ -110,24 +108,19 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; if (![self searchText:text forInputLocale:locale]) return; - self.searchManager.state = MWMSearchManagerStateMapSearch; + [self.searchManager startSearchingWithIsRouting:NO]; } - (BOOL)searchText:(NSString *)text forInputLocale:(NSString *)locale { if (text.length == 0) return NO; - self.searchManager.state = MWMSearchManagerStateTableSearch; - [self.searchManager searchText:text forInputLocale:locale withCategory:NO]; + [self.searchManager startSearchingWithIsRouting:NO]; + [self.searchManager searchText:text locale:locale isCategory:NO]; return YES; } -- (void)hideSearch { - self.searchManager.state = MWMSearchManagerStateHidden; -} - -#pragma mark - BottomMenuDelegate - +#pragma mark - BottomMenu - (void)actionDownloadMaps:(MWMMapDownloaderMode)mode { [self.ownerController openMapsDownloader:mode]; } @@ -146,7 +139,7 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; MapViewController *ownerController = self.ownerController; self.isAddingPlace = YES; - self.searchManager.state = MWMSearchManagerStateHidden; + [self.searchManager close]; self.menuState = MWMBottomMenuStateHidden; self.trafficButtonHidden = YES; @@ -181,15 +174,6 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; [[MapsAppDelegate theApp] enableStandby]; } -#pragma mark - MWMSearchManagerObserver - -- (void)onSearchManagerStateChanged { - auto state = [MWMSearchManager manager].state; - if (!IPAD && state == MWMSearchManagerStateHidden) { - self.hidden = NO; - } -} - #pragma mark - Routing - (void)onRoutePrepare { @@ -201,16 +185,12 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; } - (void)onRouteRebuild { - if (IPAD) - self.searchManager.state = MWMSearchManagerStateHidden; - [self.ownerController.bookmarksCoordinator close]; [self.navigationManager onRoutePlanning]; self.promoButton.hidden = YES; } - (void)onRouteReady:(BOOL)hasWarnings { - self.searchManager.state = MWMSearchManagerStateHidden; [self.navigationManager onRouteReady:hasWarnings]; self.promoButton.hidden = YES; } @@ -226,7 +206,6 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; } - (void)onRouteStop { - self.searchManager.state = MWMSearchManagerStateHidden; self.sideButtons.zoomHidden = self.zoomHidden; [self.navigationManager onRouteStop]; self.disableStandbyOnRouteFollowing = NO; @@ -236,17 +215,6 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; #pragma mark - Properties -/* -- (UIButton *)promoButton { - if (!_promoButton) { - PromoCoordinator *coordinator = [[PromoCoordinator alloc] initWithViewController:self.ownerController - campaign:_promoDiscoveryCampaign]; - _promoButton = [[PromoButton alloc] initWithCoordinator:coordinator]; - } - return _promoButton; -} -*/ - - (MWMSideButtons *)sideButtons { if (!_sideButtons) _sideButtons = [[MWMSideButtons alloc] initWithParentView:self.ownerController.controlsView]; @@ -283,14 +251,6 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue"; return _navigationManager; } -- (MWMSearchManager *)searchManager { - if (!_searchManager) { - _searchManager = [[MWMSearchManager alloc] init]; - [MWMSearchManager addObserver:self]; - } - return _searchManager; -} - @synthesize menuState = _menuState; - (void)setHidden:(BOOL)hidden { diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm index 43c06fb061..21cf2af84c 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm @@ -19,7 +19,7 @@ NSString *const kNavigationControlViewXibName = @"NavigationControlView"; @end -@interface MWMNavigationDashboardManager () +@interface MWMNavigationDashboardManager () @property(copy, nonatomic) NSDictionary *etaAttributes; @property(copy, nonatomic) NSDictionary *etaSecondaryAttributes; @@ -52,6 +52,10 @@ NSString *const kNavigationControlViewXibName = @"NavigationControlView"; return self; } +- (SearchOnMapManager *)searchManager { + return [[MapViewController sharedController] searchManager]; +} + - (void)loadPreviewWithStatusBoxes { [NSBundle.mainBundle loadNibNamed:kRoutePreviewIPhoneXibName owner:self options:nil]; auto ownerView = self.ownerView; @@ -236,14 +240,20 @@ NSString *const kNavigationControlViewXibName = @"NavigationControlView"; - (IBAction)stopRoutingButtonAction { [MWMSearch clear]; [MWMRouter stopRouting]; + [self.searchManager close]; } -#pragma mark - MWMSearchManagerObserver +#pragma mark - SearchOnMapManagerObserver -- (void)onSearchManagerStateChanged { - auto state = [MWMSearchManager manager].state; - if (state == MWMSearchManagerStateMapSearch) - [self setMapSearch]; +- (void)searchManagerWithDidChangeState:(SearchOnMapState)state { + switch (state) { + case SearchOnMapStateClosed: + [self.navigationInfoView setSearchState:NavigationSearchState::MinimizedNormal animated:YES]; + break; + case SearchOnMapStateHidden: + case SearchOnMapStateSearching: + [self setMapSearch]; + } } #pragma mark - Available area @@ -259,9 +269,9 @@ NSString *const kNavigationControlViewXibName = @"NavigationControlView"; - (void)setState:(MWMNavigationDashboardState)state { if (state == MWMNavigationDashboardStateHidden) - [MWMSearchManager removeObserver:self]; + [self.searchManager removeObserver:self]; else - [MWMSearchManager addObserver:self]; + [self.searchManager addObserver:self]; switch (state) { case MWMNavigationDashboardStateHidden: [self stateHidden]; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.h index 694ab2f5cc..5ea9e94c79 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.h @@ -25,6 +25,8 @@ typedef NS_ENUM(NSUInteger, MWMNavigationInfoViewState) { @property(weak, nonatomic) UIView * ownerView; @property(nonatomic) CGRect availableArea; +- (void)setSearchState:(NavigationSearchState)searchState animated:(BOOL)animated; + - (void)onNavigationInfoUpdated:(MWMNavigationDashboardEntity *)info; - (void)setMapSearch; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.mm index 749a915818..34acbed972 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/MWMNavigationInfoView.mm @@ -6,7 +6,6 @@ #import "MWMLocationObserver.h" #import "MWMMapViewControlsCommon.h" #import "MWMSearch.h" -#import "MWMSearchManager.h" #import "MapViewController.h" #import "SwiftBridge.h" #import "UIImageView+Coloring.h" @@ -143,13 +142,16 @@ BOOL defaultOrientation(CGSize const &size) { [toastView configWithIsStart:YES withLocationButton:NO]; } +- (SearchOnMapManager *)searchManager { + return [MapViewController sharedController].searchManager; +} + - (IBAction)openSearch { BOOL const isStart = self.toastView.isStart; - auto searchManager = [MWMSearchManager manager]; - searchManager.routingTooltipSearch = - isStart ? MWMSearchManagerRoutingTooltipSearchStart : MWMSearchManagerRoutingTooltipSearchFinish; - searchManager.state = MWMSearchManagerStateDefault; + [self.searchManager setRoutingTooltip: + isStart ? SearchOnMapRoutingTooltipSearchStart : SearchOnMapRoutingTooltipSearchFinish ]; + [self.searchManager startSearchingWithIsRouting:YES]; } - (IBAction)addLocationRoutePoint { @@ -166,12 +168,12 @@ BOOL defaultOrientation(CGSize const &size) { - (IBAction)searchMainButtonTouchUpInside { switch (self.searchState) { case NavigationSearchState::Maximized: - [MWMSearchManager manager].state = MWMSearchManagerStateDefault; + [self.searchManager startSearchingWithIsRouting:YES]; [self setSearchState:NavigationSearchState::MinimizedNormal animated:YES]; break; case NavigationSearchState::MinimizedNormal: if (self.state == MWMNavigationInfoViewStatePrepare) { - [MWMSearchManager manager].state = MWMSearchManagerStateDefault; + [self.searchManager startSearchingWithIsRouting:YES]; } else { [self setSearchState:NavigationSearchState::Maximized animated:YES]; } @@ -183,7 +185,7 @@ BOOL defaultOrientation(CGSize const &size) { case NavigationSearchState::MinimizedFood: case NavigationSearchState::MinimizedATM: [MWMSearch clear]; - [MWMSearchManager manager].state = MWMSearchManagerStateHidden; + [self.searchManager hide]; [self setSearchState:NavigationSearchState::MinimizedNormal animated:YES]; break; } diff --git a/iphone/Maps/Classes/MapViewController.h b/iphone/Maps/Classes/MapViewController.h index f47edd744d..c6c1a3e3d5 100644 --- a/iphone/Maps/Classes/MapViewController.h +++ b/iphone/Maps/Classes/MapViewController.h @@ -6,6 +6,7 @@ @class EAGLView; @class MWMMapDownloadDialog; @class BookmarksCoordinator; +@class SearchOnMapManager; @protocol MWMLocationModeListener; @interface MapViewController : MWMViewController @@ -46,11 +47,10 @@ @property(nonatomic, readonly) MWMMapViewControlsManager * _Nonnull controlsManager; @property(nonatomic, readonly) MWMMapDownloadDialog * _Nonnull downloadDialog; @property(nonatomic, readonly) BookmarksCoordinator * _Nonnull bookmarksCoordinator; +@property(nonatomic, readonly) SearchOnMapManager * _Nonnull searchManager; @property(nonatomic) MWMMyPositionMode currentPositionMode; @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/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index f91e1d560b..93fc70cb37 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -30,6 +30,9 @@ extern NSString *const kMap2FBLoginSegue = @"Map2FBLogin"; extern NSString *const kMap2GoogleLoginSegue = @"Map2GoogleLogin"; +static CGFloat kPlacePageCompactWidth = 350; +static CGFloat kPlacePageLeadingOffset = IPAD ? 20 : 0; + typedef NS_ENUM(NSUInteger, UserTouchesAction) { UserTouchesActionNone, UserTouchesActionDrag, UserTouchesActionScale }; namespace { @@ -72,6 +75,7 @@ NSString *const kSettingsSegue = @"Map2Settings"; UIGestureRecognizerDelegate> @property(nonatomic, readwrite) MWMMapViewControlsManager *controlsManager; +@property(nonatomic, readwrite) SearchOnMapManager *searchManager; @property(nonatomic) BOOL disableStandbyOnLocationStateMode; @@ -97,7 +101,11 @@ NSString *const kSettingsSegue = @"Map2Settings"; @property(nonatomic) BOOL needDeferFocusNotification; @property(nonatomic) BOOL deferredFocusValue; @property(nonatomic) PlacePageViewController *placePageVC; -@property(nonatomic) IBOutlet UIView *placePageContainer; +@property(nonatomic) UIView *placePageContainer; + +@property(nonatomic) NSLayoutConstraint *placePageWidthConstraint; +@property(nonatomic) NSLayoutConstraint *placePageLeadingConstraint; +@property(nonatomic) NSLayoutConstraint *placePageTrailingConstraint; @end @@ -111,6 +119,9 @@ NSString *const kSettingsSegue = @"Map2Settings"; #pragma mark - Map Navigation - (void)showOrUpdatePlacePage:(PlacePageData *)data { + if (self.searchManager.isSearching) + [self.searchManager setPlaceOnMapSelected:YES]; + self.controlsManager.trafficButtonHidden = YES; if (self.placePageVC != nil) { [PlacePageBuilder update:(PlacePageViewController *)self.placePageVC with:data]; @@ -120,19 +131,58 @@ NSString *const kSettingsSegue = @"Map2Settings"; } - (void)showPlacePageFor:(PlacePageData *)data { - self.placePageVC = [PlacePageBuilder buildFor:data]; self.placePageContainer.hidden = NO; - self.placePageVC.view.translatesAutoresizingMaskIntoConstraints = NO; + self.placePageVC = [PlacePageBuilder buildFor:data]; [self.placePageContainer addSubview:self.placePageVC.view]; - [self.view bringSubviewToFront:self.placePageContainer]; - [NSLayoutConstraint activateConstraints:@[ - [self.placePageVC.view.topAnchor constraintEqualToAnchor:self.placePageContainer.safeAreaLayoutGuide.topAnchor], - [self.placePageVC.view.leftAnchor constraintEqualToAnchor:self.placePageContainer.leftAnchor], - [self.placePageVC.view.bottomAnchor constraintEqualToAnchor:self.placePageContainer.bottomAnchor], - [self.placePageVC.view.rightAnchor constraintEqualToAnchor:self.placePageContainer.rightAnchor] - ]]; [self addChildViewController:self.placePageVC]; [self.placePageVC didMoveToParentViewController:self]; + self.placePageVC.view.translatesAutoresizingMaskIntoConstraints = NO; + [NSLayoutConstraint activateConstraints:@[ + [self.placePageVC.view.topAnchor constraintEqualToAnchor:self.placePageContainer.topAnchor], + [self.placePageVC.view.leadingAnchor constraintEqualToAnchor:self.placePageContainer.leadingAnchor], + [self.placePageVC.view.bottomAnchor constraintEqualToAnchor:self.placePageContainer.bottomAnchor], + [self.placePageVC.view.trailingAnchor constraintEqualToAnchor:self.placePageContainer.trailingAnchor] + ]]; + [self updatePlacePageContainerConstraints]; +} + +- (void)setupPlacePageContainer { + self.placePageContainer = [[TouchTransparentView alloc] initWithFrame:self.view.bounds]; + [self.view addSubview:self.placePageContainer]; + [self.view bringSubviewToFront:self.placePageContainer]; + + self.placePageContainer.translatesAutoresizingMaskIntoConstraints = NO; + self.placePageLeadingConstraint = [self.placePageContainer.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor constant:kPlacePageLeadingOffset]; + self.placePageLeadingConstraint.active = YES; + + self.placePageWidthConstraint = [self.placePageContainer.widthAnchor constraintEqualToConstant:0]; + self.placePageTrailingConstraint = [self.placePageContainer.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor]; + + [self.placePageContainer.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES; + if (IPAD) { + self.placePageLeadingConstraint.priority = UILayoutPriorityDefaultLow; + [self.placePageContainer.bottomAnchor constraintLessThanOrEqualToAnchor:self.view.bottomAnchor].active = YES; + } + else { + [self.placePageContainer.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES; + } + + [self updatePlacePageContainerConstraints]; +} + +- (void)updatePlacePageContainerConstraints { + const BOOL isLimitedWidth = IPAD || self.traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact; + [self.placePageWidthConstraint setConstant:kPlacePageCompactWidth]; + + if (IPAD && self.searchViewContainer != nil) { + NSLayoutConstraint * leadingToSearchConstraint = [self.placePageContainer.leadingAnchor constraintEqualToAnchor:self.searchViewContainer.trailingAnchor constant:kPlacePageLeadingOffset]; + leadingToSearchConstraint.priority = UILayoutPriorityDefaultHigh; + leadingToSearchConstraint.active = isLimitedWidth; + } + + [self.placePageWidthConstraint setActive:isLimitedWidth]; + [self.placePageTrailingConstraint setActive:!isLimitedWidth]; + [self.view layoutIfNeeded]; } - (void)dismissPlacePage { @@ -160,16 +210,10 @@ NSString *const kSettingsSegue = @"Map2Settings"; - (void)onMapObjectDeselected { [self hidePlacePage]; - MWMSearchManager * searchManager = MWMSearchManager.manager; - BOOL const isSearchResult = searchManager.state == MWMSearchManagerStateResult; + BOOL const isSearching = self.searchManager.isSearching; BOOL const isNavigationDashboardHidden = [MWMNavigationDashboardManager sharedManager].state == MWMNavigationDashboardStateHidden; - if (isSearchResult) { - if (isNavigationDashboardHidden) { - searchManager.state = MWMSearchManagerStateMapSearch; - } else { - searchManager.state = MWMSearchManagerStateHidden; - } - } + if (isSearching) + [self.searchManager setPlaceOnMapSelected:!isNavigationDashboardHidden]; // Always show the controls during the navigation or planning mode. if (!isNavigationDashboardHidden) self.controlsManager.hidden = NO; @@ -177,8 +221,7 @@ NSString *const kSettingsSegue = @"Map2Settings"; - (void)onSwitchFullScreen { BOOL const isNavigationDashboardHidden = MWMNavigationDashboardManager.sharedManager.state == MWMNavigationDashboardStateHidden; - BOOL const isSearchHidden = MWMSearchManager.manager.state == MWMSearchManagerStateHidden; - if (isSearchHidden && isNavigationDashboardHidden) { + if (!self.searchManager.isSearching && isNavigationDashboardHidden) { if (!self.controlsManager.hidden) [self dismissPlacePage]; self.controlsManager.hidden = !self.controlsManager.hidden; @@ -215,6 +258,10 @@ NSString *const kSettingsSegue = @"Map2Settings"; if ([MWMCarPlayService shared].isCarplayActivated) { return; } + + if (self.searchManager.isSearching && type == df::TouchEvent::TOUCH_MOVE) + [self.searchManager setMapIsDragging]; + NSArray *allTouches = [[event allTouches] allObjects]; if ([allTouches count] < 1) return; @@ -287,6 +334,12 @@ NSString *const kSettingsSegue = @"Map2Settings"; [self.controlsManager viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; } +- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { + [super traitCollectionDidChange:previousTraitCollection]; + if (self.traitCollection.verticalSizeClass != previousTraitCollection.verticalSizeClass) + [self updatePlacePageContainerConstraints]; +} + - (void)didReceiveMemoryWarning { GetFramework().MemoryWarning(); [super didReceiveMemoryWarning]; @@ -305,8 +358,7 @@ NSString *const kSettingsSegue = @"Map2Settings"; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - if ([MWMNavigationDashboardManager sharedManager].state == MWMNavigationDashboardStateHidden && - [MWMSearchManager manager].state == MWMSearchManagerStateHidden) + if ([MWMNavigationDashboardManager sharedManager].state == MWMNavigationDashboardStateHidden) self.controlsManager.menuState = self.controlsManager.menuRestoreState; [self updateStatusBarStyle]; @@ -319,6 +371,7 @@ NSString *const kSettingsSegue = @"Map2Settings"; - (void)viewDidLoad { [super viewDidLoad]; + [self setupPlacePageContainer]; if (@available(iOS 14.0, *)) [self setupTrackPadGestureRecognizers]; @@ -441,8 +494,7 @@ NSString *const kSettingsSegue = @"Map2Settings"; - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - if ([MWMNavigationDashboardManager sharedManager].state == MWMNavigationDashboardStateHidden && - [MWMSearchManager manager].state == MWMSearchManagerStateHidden) + if ([MWMNavigationDashboardManager sharedManager].state == MWMNavigationDashboardStateHidden) self.controlsManager.menuRestoreState = self.controlsManager.menuState; GetFramework().SetRenderingDisabled(false); } @@ -605,15 +657,13 @@ NSString *const kSettingsSegue = @"Map2Settings"; - (void)performAction:(NSString *)action { [self.navigationController popToRootViewControllerAnimated:NO]; if (self.isViewLoaded) { - auto searchState = MWMSearchManagerStateHidden; [MWMRouter stopRouting]; if ([action isEqualToString:@"app.organicmaps.3daction.bookmarks"]) [self.bookmarksCoordinator open]; else if ([action isEqualToString:@"app.organicmaps.3daction.search"]) - searchState = MWMSearchManagerStateDefault; + [self.searchManager startSearchingWithIsRouting:NO]; else if ([action isEqualToString:@"app.organicmaps.3daction.route"]) [self.controlsManager onRoutePrepare]; - [MWMSearchManager manager].state = searchState; } else { dispatch_async(dispatch_get_main_queue(), ^{ [self performAction:action]; @@ -674,9 +724,20 @@ NSString *const kSettingsSegue = @"Map2Settings"; return _controlsManager; } +- (SearchOnMapManager *)searchManager { + if (!_searchManager) + _searchManager = [[SearchOnMapManager alloc] initWithNavigationController:self.navigationController]; + return _searchManager; +} + +- (UIView * _Nullable)searchViewContainer { + return self.searchManager.viewController.view; +} + - (BOOL)hasNavigationBar { return NO; } + - (MWMMapDownloadDialog *)downloadDialog { if (!_downloadDialog) _downloadDialog = [MWMMapDownloadDialog dialogForController:self]; diff --git a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarInteractor.swift b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarInteractor.swift index 24daa10607..6a88a62e44 100644 --- a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarInteractor.swift +++ b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarInteractor.swift @@ -11,22 +11,19 @@ class BottomTabBarInteractor { private weak var viewController: UIViewController? private weak var mapViewController: MapViewController? private weak var controlsManager: MWMMapViewControlsManager? - private weak var searchManager = MWMSearchManager.manager() - + private let searchManager: SearchOnMapManager + init(viewController: UIViewController, mapViewController: MapViewController, controlsManager: MWMMapViewControlsManager) { self.viewController = viewController self.mapViewController = mapViewController self.controlsManager = controlsManager + self.searchManager = mapViewController.searchManager } } extension BottomTabBarInteractor: BottomTabBarInteractorProtocol { func openSearch() { - if searchManager?.state == .hidden { - searchManager?.state = .default - } else { - searchManager?.state = .hidden - } + searchManager.isSearching ? searchManager.close() : searchManager.startSearching(isRouting: false) } func openHelp() { diff --git a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift index af3da08ffa..05d3bc8d3b 100644 --- a/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift +++ b/iphone/Maps/UI/BottomMenu/TabBar/BottomTabBarViewController.swift @@ -32,8 +32,6 @@ class BottomTabBarViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() presenter.configure() - - MWMSearchManager.add(self) } override func viewWillAppear(_ animated: Bool) { @@ -45,10 +43,6 @@ class BottomTabBarViewController: UIViewController { updateBadge() } - deinit { - MWMSearchManager.remove(self) - } - static func updateAvailableArea(_ frame: CGRect) { BottomTabBarViewController.controller?.updateAvailableArea(frame) } @@ -119,11 +113,3 @@ private extension BottomTabBarViewController { UserDefaults.standard.set(true, forKey: kUDDidShowFirstTimeRoutingEducationalHint) } } - -// MARK: - MWMSearchManagerObserver -extension BottomTabBarViewController: MWMSearchManagerObserver { - func onSearchManagerStateChanged() { - let state = MWMSearchManager.manager().state; - self.searchButton.isSelected = state != .hidden - } -} diff --git a/iphone/Maps/UI/Search/MWMSearchManager.mm b/iphone/Maps/UI/Search/MWMSearchManager.mm index 691e79c5ec..29cd6c6e24 100644 --- a/iphone/Maps/UI/Search/MWMSearchManager.mm +++ b/iphone/Maps/UI/Search/MWMSearchManager.mm @@ -61,8 +61,14 @@ const CGFloat kWidthForiPad = 320; @implementation MWMSearchManager + (MWMSearchManager *)manager { - return [MWMMapViewControlsManager manager].searchManager; + static MWMSearchManager * manager; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + manager = [[MWMSearchManager alloc] init]; + }); + return manager; } + - (nullable instancetype)init { self = [super init]; if (self) { @@ -243,7 +249,6 @@ const CGFloat kWidthForiPad = 320; controlsManager.menuState = controlsManager.menuRestoreState; } [self viewHidden:NO]; - [MWMSearch setSearchOnMap:NO]; [self.tableViewController reloadData]; if (![self.navigationController.viewControllers containsObject:self.tableViewController]) @@ -265,7 +270,6 @@ const CGFloat kWidthForiPad = 320; [self viewHidden:navigationManagerState != MWMNavigationDashboardStateHidden]; self.controlsManager.menuState = MWMBottomMenuStateHidden; GetFramework().DeactivateMapSelection(); - [MWMSearch setSearchOnMap:YES]; [self.tableViewController reloadData]; [self.searchTextField resignFirstResponder]; @@ -523,10 +527,12 @@ const CGFloat kWidthForiPad = 320; return [MapViewController sharedController]; } - (UIView *)searchViewContainer { - return [MapViewController sharedController].searchViewContainer; +// return [MapViewController sharedController].searchViewContainer; + return nil; } - (NSLayoutConstraint *)searchViewContainerLeadingConstraint { - return [MapViewController sharedController].searchViewContainerLeadingConstraint; +// return [MapViewController sharedController].searchViewContainerLeadingConstraint; + return nil; } - (UIView *)actionBarContainer { return [MapViewController sharedController].controlsView; diff --git a/iphone/Maps/UI/Storyboard/Main.storyboard b/iphone/Maps/UI/Storyboard/Main.storyboard index a78cd06513..c1605e6180 100644 --- a/iphone/Maps/UI/Storyboard/Main.storyboard +++ b/iphone/Maps/UI/Storyboard/Main.storyboard @@ -1,9 +1,9 @@ - - + + - + @@ -14,26 +14,26 @@ - + - + - + - + @@ -98,64 +98,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -171,14 +115,11 @@ - - - @@ -187,8 +128,6 @@ - - @@ -196,13 +135,11 @@ - - @@ -217,18 +154,14 @@ - - - - @@ -240,10 +173,6 @@ - - - - @@ -252,7 +181,6 @@ - @@ -260,34 +188,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -295,9 +195,6 @@ - - - @@ -342,7 +239,7 @@ - + @@ -362,7 +259,7 @@ - + @@ -378,7 +275,7 @@ - + @@ -404,11 +301,11 @@ - + - + @@ -419,10 +316,10 @@ - + - + @@ -439,7 +336,7 @@ - + @@ -448,7 +345,7 @@ - + @@ -457,7 +354,7 @@ - + @@ -466,7 +363,7 @@ - + @@ -475,13 +372,13 @@ - + - + - + @@ -501,7 +398,7 @@ - + @@ -510,7 +407,7 @@ - + @@ -611,7 +508,7 @@ - + @@ -679,26 +576,26 @@ - + - + - + - + @@ -768,7 +665,7 @@ - + @@ -813,11 +710,11 @@ - + - + @@ -828,7 +725,7 @@ - + @@ -839,7 +736,7 @@ - + @@ -883,11 +780,11 @@ - + - + @@ -899,13 +796,13 @@ - + @@ -948,20 +845,20 @@ - + - + - + - +