diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm index ebe4d51099..6e53c6f3a7 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm @@ -691,7 +691,6 @@ CGFloat constexpr kTimeWidthRegular = 128; self.progressView.hidden = YES; self.routingView.hidden = NO; self.routingAdditionalView.hidden = YES; - self.estimateLabel.text = [MWMRouter isTaxi] ? L(@"taxi_not_found") : L(@"routing_planning_error"); break; case MWMBottomMenuStateRouting: self.menuButton.hidden = NO; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.h b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.h index 0bb426ed0f..78f5fdd509 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.h @@ -28,5 +28,6 @@ - (void)mwm_refreshUI; - (void)refreshLayout; - (MWMTaxiCollectionView *)taxiCollectionView; +- (void)setRoutingErrorMessage:(NSString *)routingErrorMessage; @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm index f31b4b52d3..a0913dfa49 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm @@ -71,6 +71,8 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) { @property(weak, nonatomic) MWMNavigationDashboardEntity * navigationInfo; +@property(copy, nonatomic) NSString * routingErrorMessage; + @property(weak, nonatomic) IBOutlet UILabel * speedLabel; @property(weak, nonatomic) IBOutlet UILabel * timeLabel; @property(weak, nonatomic) IBOutlet UILabel * distanceLabel; @@ -140,6 +142,9 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) { - (void)updateNavigationInfo:(MWMNavigationDashboardEntity *)info { + if ([MWMRouter isTaxi]) + return; + NSDictionary * routingNumberAttributes = @{ NSForegroundColorAttributeName : [UIColor blackPrimaryText], NSFontAttributeName : [UIFont bold24] @@ -532,6 +537,9 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) { self.restoreState = state; else view.state = state; + + if (state == MWMBottomMenuStateRoutingError) + self.estimateLabel.text = self.routingErrorMessage; } - (MWMBottomMenuState)state { return ((MWMBottomMenuView *)self.view).state; } diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index d018df6039..2c84f37d4f 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -510,6 +510,11 @@ extern NSString * const kAlohalyticsTapEventKey; self.menuController.state = self.hidden ? MWMBottomMenuStateHidden : menuState; } +- (void)setRoutingErrorMessage:(NSString *)message +{ + [self.menuController setRoutingErrorMessage:message]; +} + - (MWMBottomMenuState)menuState { MWMBottomMenuState const state = self.menuController.state; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h index 852befd74c..c74acb562e 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h @@ -24,6 +24,7 @@ typedef NS_ENUM(NSUInteger, MWMNavigationDashboardState) { - (void)didStartEditingRoutePoint:(BOOL)isSource; - (void)setMenuState:(MWMBottomMenuState)menuState; - (void)setMenuRestoreState:(MWMBottomMenuState)menuState; +- (void)setRoutingErrorMessage:(NSString *)errorMessage; - (MWMTaxiCollectionView *)taxiCollectionView; @end diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm index ec7586181f..a4817c4c82 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm @@ -13,6 +13,8 @@ #import "MapsAppDelegate.h" #import "Statistics.h" +#include "platform/platform.hpp" + namespace { NSString * const kRoutePreviewXibName = @"MWMRoutePreview"; @@ -155,22 +157,33 @@ using TInfoDisplays = NSHashTable<__kindof TInfoDisplay>; if (![MWMRouter isTaxi]) return; + auto showError = ^(NSString * errorMessage) + { + [self.routePreview stateError]; + [self.routePreview router:routing::RouterType::Taxi setState:MWMCircularProgressStateFailed]; + [self setMenuErrorStateWithErrorMessage:errorMessage]; + }; + auto r = [MWMRouter router]; auto const & start = r.startPoint; auto const & finish = r.finishPoint; if (start.IsValid() && finish.IsValid()) { + if (!Platform::IsConnected()) + { + [[MapViewController controller].alertController presentNoConnectionAlert]; + showError(L(@"dialog_taxi_offline")); + return; + } [self.taxiDataSource requestTaxiFrom:start to:finish completion:^ { [self setMenuState:MWMBottomMenuStateGo]; [self.routePreview stateReady]; [self setRouteBuilderProgress:100.]; } - failure:^ + failure:^(NSString * errorMessage) { - [self.routePreview stateError]; - [self.routePreview router:routing::RouterType::Taxi setState:MWMCircularProgressStateFailed]; - [self setMenuState:MWMBottomMenuStateRoutingError]; + showError(errorMessage); }]; } } @@ -200,6 +213,12 @@ using TInfoDisplays = NSHashTable<__kindof TInfoDisplay>; [startButton setTitle:t forState:UIControlStateDisabled]; } +- (void)setMenuErrorStateWithErrorMessage:(NSString *)message +{ + [self.delegate setRoutingErrorMessage:message]; + [self setMenuState:MWMBottomMenuStateRoutingError]; +} + - (void)setMenuState:(MWMBottomMenuState)menuState { id delegate = self.delegate; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.h index 6e33ec04a8..12f8bdded8 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.h @@ -14,7 +14,7 @@ class MWMRoutePoint; - (void)requestTaxiFrom:(MWMRoutePoint const &)from to:(MWMRoutePoint const &)to completion:(TMWMVoidBlock)completion - failure:(TMWMVoidBlock)failure; + failure:(MWMStringBlock)failure; - (NSURL *)taxiURL; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.mm index 1fadf43776..b3ec86fe33 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.mm @@ -89,7 +89,7 @@ using namespace uber; - (void)requestTaxiFrom:(MWMRoutePoint const &)from to:(MWMRoutePoint const &)to completion:(TMWMVoidBlock)completion - failure:(TMWMVoidBlock)failure + failure:(MWMStringBlock)failure { NSAssert(completion && failure, @"Completion and failure blocks must be not nil!"); m_products.clear(); @@ -98,23 +98,15 @@ using namespace uber; auto cv = self.collectionView; cv.hidden = YES; cv.pageControl.hidden = YES; - - auto const errorCallback = [](uber::ErrorCode const code, uint64_t const requestId) {}; - - m_requestId = m_api.GetAvailableProducts(m_from, m_to, [self, completion, failure](vector const & products, + + m_requestId = m_api.GetAvailableProducts(m_from, m_to, [self, completion](vector const & products, uint64_t const requestId) { - dispatch_async(dispatch_get_main_queue(), [products, requestId, self, completion, failure] + dispatch_async(dispatch_get_main_queue(), [products, requestId, self, completion] { if (self->m_requestId != requestId) return; - if (products.empty()) - { - failure(); - return; - } - self->m_products = products; auto cv = self.collectionView; cv.hidden = NO; @@ -125,7 +117,25 @@ using namespace uber; cv.currentPage = 0; completion(); }); - }, errorCallback); + }, + [self, failure](uber::ErrorCode const code, uint64_t const requestId) + { + dispatch_async(dispatch_get_main_queue(), ^ + { + if (self->m_requestId != requestId) + return; + + switch (code) + { + case uber::ErrorCode::NoProducts: + failure(L(@"taxi_not_found")); + break; + case uber::ErrorCode::RemoteError: + failure(L(@"dialog_taxi_error")); + break; + } + }); + }); } - (BOOL)isTaxiInstalled diff --git a/iphone/Maps/Classes/Routing/MWMRouter.mm b/iphone/Maps/Classes/Routing/MWMRouter.mm index d2142b43b7..ae6b5504bf 100644 --- a/iphone/Maps/Classes/Routing/MWMRouter.mm +++ b/iphone/Maps/Classes/Routing/MWMRouter.mm @@ -374,7 +374,9 @@ bool isMarkerPoint(MWMRoutePoint const & point) { return point.IsValid() && !poi else [[MWMMapViewControlsManager manager] onRouteReady]; [self updateFollowingInfo]; - [[MWMNavigationDashboardManager manager] setRouteBuilderProgress:100]; + if (![MWMRouter isTaxi]) + [[MWMNavigationDashboardManager manager] setRouteBuilderProgress:100]; + [MWMMapViewControlsManager manager].searchHidden = YES; break; } diff --git a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/Contents.json b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/Contents.json index 50aa27d473..3c1bd37ef3 100644 --- a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/Contents.json +++ b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/Contents.json @@ -2,17 +2,17 @@ "images" : [ { "idiom" : "universal", - "filename" : "ic_route_type_taxi.png", + "filename" : "ic_taxi.png", "scale" : "1x" }, { "idiom" : "universal", - "filename" : "ic_route_type_taxi@2x.png", + "filename" : "ic_taxi@2x.png", "scale" : "2x" }, { "idiom" : "universal", - "filename" : "ic_route_type_taxi@3x.png", + "filename" : "ic_taxi@3x.png", "scale" : "3x" } ], diff --git a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_route_type_taxi.png b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_route_type_taxi.png deleted file mode 100644 index 22c41aa1dd..0000000000 Binary files a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_route_type_taxi.png and /dev/null differ diff --git a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_route_type_taxi@2x.png b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_route_type_taxi@2x.png deleted file mode 100644 index ec76b7a124..0000000000 Binary files a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_route_type_taxi@2x.png and /dev/null differ diff --git a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_route_type_taxi@3x.png b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_route_type_taxi@3x.png deleted file mode 100644 index def9121674..0000000000 Binary files a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_route_type_taxi@3x.png and /dev/null differ diff --git a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_taxi.png b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_taxi.png new file mode 100644 index 0000000000..2c3d3cd6ad Binary files /dev/null and b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_taxi.png differ diff --git a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_taxi@2x.png b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_taxi@2x.png new file mode 100644 index 0000000000..33cf0023d0 Binary files /dev/null and b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_taxi@2x.png differ diff --git a/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_taxi@3x.png b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_taxi@3x.png new file mode 100644 index 0000000000..720c53b8cc Binary files /dev/null and b/iphone/Maps/Images.xcassets/NavigationDashboard/ic_taxi.imageset/ic_taxi@3x.png differ