From 7aa868f2827ca96f7783e036f78da2924d1573f1 Mon Sep 17 00:00:00 2001 From: "v.mikhaylenko" Date: Wed, 9 Sep 2015 18:01:45 +0300 Subject: [PATCH] Review fixes. --- .../MWMMapViewControlsManager.mm | 2 +- .../MWMNavigationDashboardEntity.h | 2 +- .../MWMNavigationDashboardEntity.mm | 4 +- .../MWMNavigationDashboardManager.mm | 88 +++++++------- .../MWMLandscapeNavigationDashboard.xib | 6 +- .../Views/Dashboard/MWMNavigationDashboard.mm | 2 +- .../NavigationDashboard/Views/MWMLanesPanel.h | 2 +- .../Views/MWMLanesPanel.mm | 89 ++++++-------- .../Views/MWMRouteHelperPanel.mm | 32 ++++- .../Views/MWMRouteHelperPanelsDrawer.h | 6 +- .../Views/MWMRouteHelperPanelsDrawer.mm | 109 +++++++++--------- .../Maps/Classes/MWMPlacePageViewManager.mm | 2 +- 12 files changed, 173 insertions(+), 171 deletions(-) diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index ece7e01e80..0941588639 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -79,7 +79,7 @@ - (void)showPlacePageWithUserMark:(unique_ptr)userMark { - [self.placePageManager showPlacePageWithUserMark:std::move(userMark)]; + [self.placePageManager showPlacePageWithUserMark:move(userMark)]; if (UIInterfaceOrientationIsLandscape(self.ownerController.interfaceOrientation)) [self.navigationManager hideHelperPanels]; } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.h index 9cc8c05116..e17fa44ec6 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.h @@ -20,7 +20,7 @@ @property (nonatomic, readonly) NSUInteger roundExitNumber; @property (nonatomic, readonly) NSUInteger timeToTarget; @property (nonatomic, readonly) CGFloat progress; -@property (nonatomic, readonly) std::vector lanes; +//@property (nonatomic, readonly) vector lanes; @property (nonatomic, readonly) BOOL isPedestrian; - (void)updateWithFollowingInfo:(location::FollowingInfo const &)info; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.mm index 20e7fed1c4..d606aba4bb 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.mm @@ -45,7 +45,7 @@ _distanceToTurn = @(dist.c_str()); _turnUnits = @(units.c_str()); _streetName = @""; - _lanes = {}; +// _lanes = {}; } else { @@ -53,7 +53,7 @@ _distanceToTurn = @(info.m_distToTurn.c_str()); _turnUnits = @(info.m_turnUnitsSuffix.c_str()); _streetName = @(info.m_targetName.c_str()); - _lanes = info.m_lanes; +// _lanes = info.m_lanes; _nextTurnImage = image(info.m_nextTurn, true); } _turnImage = image(info.m_turn, false); diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm index 598d0843fa..600de8fdd8 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm @@ -20,9 +20,6 @@ #import "UIKitCategories.h" @interface MWMNavigationDashboardManager () -{ - vector helperPanels; -} @property (nonatomic) IBOutlet MWMRoutePreview * routePreviewLandscape; @property (nonatomic) IBOutlet MWMRoutePreview * routePreviewPortrait; @@ -40,6 +37,7 @@ //@property (nonatomic) MWMLanesPanel * lanesPanel; @property (nonatomic) MWMNextTurnPanel * nextTurnPanel; @property (nonatomic) MWMRouteHelperPanelsDrawer * drawer; +@property (nonatomic) NSMutableArray * helperPanels; @end @@ -72,6 +70,7 @@ self.navigationDashboardPortrait.delegate = self.navigationDashboardLandscape.delegate = delegate; } self.tts = [[MWMTextToSpeech alloc] init]; + self.helperPanels = [NSMutableArray array]; } return self; } @@ -80,8 +79,6 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { - if (IPAD) - return; BOOL const isPortrait = UIInterfaceOrientationIsPortrait(orientation); MWMRoutePreview * routePreview = isPortrait ? self.routePreviewPortrait : self.routePreviewLandscape; if (self.routePreview.isVisible && ![routePreview isEqual:self.routePreview]) @@ -90,6 +87,8 @@ [routePreview addToView:self.ownerView]; } self.routePreview = routePreview; + if (IPAD) + return; MWMNavigationDashboard * navigationDashboard = isPortrait ? self.navigationDashboardPortrait : self.navigationDashboardLandscape; @@ -99,18 +98,18 @@ [navigationDashboard addToView:self.ownerView]; } self.navigationDashboard = navigationDashboard; - [self.drawer invalidateTopBounds:helperPanels forOrientation:orientation]; + [self.drawer invalidateTopBounds:self.helperPanels.copy forOrientation:orientation]; } - (void)hideHelperPanels { - for (auto p : helperPanels) + for (MWMRouteHelperPanel * p in self.helperPanels) [UIView animateWithDuration:kDefaultAnimationDuration animations:^{ p.alpha = 0.; }]; } - (void)showHelperPanels { - for (auto p : helperPanels) + for (MWMRouteHelperPanel * p in self.helperPanels) [UIView animateWithDuration:kDefaultAnimationDuration animations:^{ p.alpha = 1.; }]; } @@ -164,38 +163,46 @@ { [self removePanel:self.nextTurnPanel]; } - [self.drawer drawPanels:helperPanels]; + [self.drawer drawPanels:self.helperPanels.copy]; } - (void)addPanel:(MWMRouteHelperPanel *)panel { - if (helperPanels.empty()) + switch (self.helperPanels.count) { - helperPanels.push_back(panel); - return; - } - if (helperPanels.size() == 1) - { - if (![helperPanels.front() isKindOfClass:panel.class]) - { - helperPanels.push_back(panel); + case 0: + [self.helperPanels addObject:panel]; return; - } - } - for (auto p : helperPanels) - { - if ([p isEqual:panel]) - continue; + case 1: + if (![self.helperPanels.firstObject isKindOfClass:panel.class]) + { + [self.helperPanels addObject:panel]; + return; + } + return; + case 2: + for (MWMRouteHelperPanel * p in self.helperPanels) + { + if ([p isEqual:panel]) + continue; - if ([p isKindOfClass:panel.class]) - replace(helperPanels.begin(), helperPanels.end(), p, panel); + if ([p isKindOfClass:panel.class]) + { + NSUInteger const index = [self.helperPanels indexOfObject:p]; + self.helperPanels[index] = panel; + } + } + return; + default: + NSAssert(false, @"Incorrect array size!"); + break; } } - (void)removePanel:(MWMRouteHelperPanel *)panel { - if (find(helperPanels.begin(), helperPanels.end(), panel) != helperPanels.end()) - helperPanels.erase(remove(helperPanels.begin(), helperPanels.end(), panel)); + if ([self.helperPanels containsObject:panel]) + [self.helperPanels removeObject:panel]; panel.hidden = YES; } @@ -235,7 +242,7 @@ self.state = MWMNavigationDashboardStateHidden; [self removePanel:self.nextTurnPanel]; // [self removePanel:self.lanesPanel]; - helperPanels.clear(); + self.helperPanels = [NSMutableArray array]; [self.delegate didCancelRouting]; } @@ -263,6 +270,8 @@ [self.routePreview addToView:self.ownerView]; [self.routePreviewLandscape statePlaning]; [self.routePreviewPortrait statePlaning]; + [self removePanel:self.nextTurnPanel]; +// [self removePanel:self.lanesPanel]; auto const state = GetFramework().GetRouter(); switch (state) { @@ -303,36 +312,21 @@ - (MWMRouteHelperPanelsDrawer *)drawer { if (!_drawer) - { - if (IPAD) - _drawer = [[MWMRouteHelperPanelsDrawer alloc] initWithView:self.navigationDashboard]; - else - _drawer = [[MWMRouteHelperPanelsDrawer alloc] initWithView:self.ownerView]; - } + _drawer = [[MWMRouteHelperPanelsDrawer alloc] initWithView:IPAD ? self.navigationDashboard : self.ownerView]; return _drawer; } //- (MWMLanesPanel *)lanesPanel //{ // if (!_lanesPanel) -// { -// if (IPAD) -// _lanesPanel = [[MWMLanesPanel alloc] initWithParentView:self.navigationDashboard]; -// else -// _lanesPanel = [[MWMLanesPanel alloc] initWithParentView:self.ownerView]; -// } +// _lanesPanel = [[MWMLanesPanel alloc] initWithParentView:IPAD ? self.navigationDashboard : self.ownerView]; // return _lanesPanel; //} - (MWMNextTurnPanel *)nextTurnPanel { if (!_nextTurnPanel) - { - if (IPAD) - _nextTurnPanel = [MWMNextTurnPanel turnPanelWithOwnerView:self.navigationDashboard]; - else - _nextTurnPanel = [MWMNextTurnPanel turnPanelWithOwnerView:self.ownerView]; - } + _nextTurnPanel = [MWMNextTurnPanel turnPanelWithOwnerView:IPAD ? self.navigationDashboard : self.ownerView]; return _nextTurnPanel; } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/Dashboard/MWMLandscapeNavigationDashboard.xib b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/Dashboard/MWMLandscapeNavigationDashboard.xib index c74cdf7dbc..048f63fdf6 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/Dashboard/MWMLandscapeNavigationDashboard.xib +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/Dashboard/MWMLandscapeNavigationDashboard.xib @@ -25,7 +25,7 @@