diff --git a/iphone/Maps/Bridging-Header.h b/iphone/Maps/Bridging-Header.h index 999cfa9f0e..749e6d5f3c 100644 --- a/iphone/Maps/Bridging-Header.h +++ b/iphone/Maps/Bridging-Header.h @@ -58,6 +58,7 @@ #import "MWMRoutePreviewTaxiCellType.h" #import "MWMRouter.h" #import "MWMRouterTransitStepInfo.h" +#import "MWMRoutingOptions.h" #import "MWMSearchItemType.h" #import "MWMSearchNoResults.h" #import "MWMSearchFrameworkHelper.h" diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.h b/iphone/Maps/Categories/UIColor+MapsMeColor.h index 3db34ff5a1..c95ee9366b 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.h +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.h @@ -4,6 +4,7 @@ + (UIColor *)primaryDark; + (UIColor *)primary; ++ (UIColor *)secondary; + (UIColor *)primaryLight; + (UIColor *)fadeBackground; + (UIColor *)menuBackground; diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.mm b/iphone/Maps/Categories/UIColor+MapsMeColor.mm index 2f7dffc20a..db8868fd8f 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.mm +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.mm @@ -9,6 +9,7 @@ NSDictionary * night = @{ @"primaryDark": [UIColor colorWithRed:scaled(25.) green:scaled(30) blue:scaled(35.) alpha:alpha100], @"primary": [UIColor colorWithRed:scaled(45.) green:scaled(50.) blue:scaled(55.) alpha:alpha100], + @"secondary": [UIColor colorWithRed:scaled(0x25) green:scaled(0x28) blue:scaled(0x2b) alpha:alpha100], // Light green color @"primaryLight": [UIColor colorWithRed:scaled(65.) green:scaled(70.) blue:scaled(75.) alpha:alpha100], @@ -59,6 +60,7 @@ NSDictionary * day = @{ [UIColor colorWithRed:scaled(24.) green:scaled(128) blue:scaled(68.) alpha:alpha100], @"primary" : [UIColor colorWithRed:scaled(32.) green:scaled(152.) blue:scaled(82.) alpha:alpha100], + @"secondary" : [UIColor colorWithRed:scaled(45) green:scaled(137) blue:scaled(83) alpha:alpha100], // Light green color @"primaryLight" : [UIColor colorWithRed:scaled(36.) green:scaled(180.) blue:scaled(98.) alpha:alpha100], @@ -140,6 +142,11 @@ UIColor * color(SEL cmd) return color(_cmd); } ++ (UIColor *)secondary +{ + return color(_cmd); +} + // Light green color + (UIColor *)primaryLight { diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h index 86d67218fc..45b2434ad2 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h @@ -51,7 +51,7 @@ class Info; - (void)onRoutePrepare; - (void)onRouteRebuild; -- (void)onRouteReady; +- (void)onRouteReady:(BOOL)hasWarnings; - (void)onRouteStart; - (void)onRouteStop; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 91d1306931..230024cffb 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -258,10 +258,10 @@ extern NSString * const kAlohalyticsTapEventKey; [self.navigationManager onRoutePlanning]; } -- (void)onRouteReady +- (void)onRouteReady:(BOOL)hasWarnings { self.searchManager.state = MWMSearchManagerStateHidden; - [self.navigationManager onRouteReady]; + [self.navigationManager onRouteReady:hasWarnings]; } - (void)onRouteStart diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h index 6a31a4cee2..2c20d5376e 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h @@ -28,7 +28,7 @@ typedef NS_ENUM(NSUInteger, MWMNavigationDashboardState) { - (void)onRoutePrepare; - (void)onRoutePlanning; - (void)onRouteError:(NSString *)error; -- (void)onRouteReady; +- (void)onRouteReady:(BOOL)hasWarnings; - (void)onRouteStart; - (void)onRouteStop; - (void)onRoutePointsUpdated; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm index 3055611f0b..2d635c8186 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm @@ -5,12 +5,8 @@ #import "MWMSearch.h" #import "MapViewController.h" -#import -#import #import "SwiftBridge.h" -#include "platform/platform.hpp" - extern NSString * const kAlohalyticsTapEventKey; namespace @@ -30,7 +26,7 @@ using Observers = NSHashTable; @end -@interface MWMNavigationDashboardManager () +@interface MWMNavigationDashboardManager () @property(copy, nonatomic) NSDictionary * etaAttributes; @property(copy, nonatomic) NSDictionary * etaSecondaryAttributes; @@ -128,18 +124,33 @@ using Observers = NSHashTable; #pragma mark - On route updates -- (void)onRoutePrepare { self.state = MWMNavigationDashboardStatePrepare; } -- (void)onRoutePlanning { self.state = MWMNavigationDashboardStatePlanning; } +- (void)onRoutePrepare { + self.state = MWMNavigationDashboardStatePrepare; + self.routePreview.drivingOptionsState = MWMDrivingOptionsStateNone; +} + +- (void)onRoutePlanning { + self.state = MWMNavigationDashboardStatePlanning; + self.routePreview.drivingOptionsState = MWMDrivingOptionsStateNone; +} + - (void)onRouteError:(NSString *)error { self.errorMessage = error; self.state = MWMNavigationDashboardStateError; + self.routePreview.drivingOptionsState = [MWMRouter hasActiveDrivingOptions] ? + MWMDrivingOptionsStateChange : MWMDrivingOptionsStateNone; } -- (void)onRouteReady +- (void)onRouteReady:(BOOL)hasWarnings { if (self.state != MWMNavigationDashboardStateNavigation && ![MWMRouter isTaxi]) self.state = MWMNavigationDashboardStateReady; + if ([MWMRouter hasActiveDrivingOptions]) { + self.routePreview.drivingOptionsState = MWMDrivingOptionsStateChange; + } else { + self.routePreview.drivingOptionsState = hasWarnings ? MWMDrivingOptionsStateDefine : MWMDrivingOptionsStateNone; + } } - (void)onRoutePointsUpdated @@ -412,6 +423,7 @@ using Observers = NSHashTable; return; [_routePreview remove]; _routePreview = routePreview; + _routePreview.delegate = self; } - (MWMBaseRoutePreviewStatus *)baseRoutePreviewStatus @@ -461,4 +473,10 @@ using Observers = NSHashTable; [_navigationInfoView setMapSearch]; } +#pragma mark - MWMRoutePreviewDelegate + +- (void)routePreviewDidPressDrivingOptions:(MWMRoutePreview *)routePreview { + [[MapViewController sharedController] openDrivingOptions]; +} + @end diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h index 5ab706ce71..507c3ba149 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h @@ -1,12 +1,28 @@ #import "MWMCircularProgressState.h" #import "MWMRouterType.h" +typedef NS_ENUM(NSInteger, MWMDrivingOptionsState) { + MWMDrivingOptionsStateNone, + MWMDrivingOptionsStateDefine, + MWMDrivingOptionsStateChange +}; + @class MWMNavigationDashboardEntity; @class MWMNavigationDashboardManager; @class MWMTaxiCollectionView; +@class MWMRoutePreview; + +@protocol MWMRoutePreviewDelegate + +- (void)routePreviewDidPressDrivingOptions:(MWMRoutePreview *)routePreview; + +@end @interface MWMRoutePreview : UIView +@property(nonatomic) MWMDrivingOptionsState drivingOptionsState; +@property(weak, nonatomic) id delegate; + - (void)addToView:(UIView *)superview; - (void)remove; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm index bb7a93f567..455acf93bb 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm @@ -13,6 +13,8 @@ #include "platform/platform.hpp" +static CGFloat const kDrivingOptionsHeight = 48; + @interface MWMRoutePreview () @property(nonatomic) BOOL isVisible; @@ -23,6 +25,8 @@ @property(weak, nonatomic) IBOutlet UIView * publicTransport; @property(weak, nonatomic) IBOutlet UIView * taxi; @property(weak, nonatomic) IBOutlet UIView * vehicle; +@property(strong, nonatomic) IBOutlet NSLayoutConstraint * drivingOptionHeightConstraint; +@property(strong, nonatomic) IBOutlet UIButton * drivingOptionsButton; @end @@ -37,6 +41,7 @@ self.translatesAutoresizingMaskIntoConstraints = NO; [self setupProgresses]; [self.backButton matchInterfaceOrientation]; + self.drivingOptionHeightConstraint.constant = -kDrivingOptionsHeight; } - (void)setupProgresses @@ -101,6 +106,10 @@ m_progresses[routerType].progress = progress; } +- (IBAction)onDrivingOptions:(UIButton *)sender { + [self.delegate routePreviewDidPressDrivingOptions:self]; +} + #pragma mark - MWMCircularProgressProtocol - (void)progressButtonPressed:(nonnull MWMCircularProgress *)progress @@ -155,6 +164,24 @@ [self.vehicle setNeedsLayout]; } +- (void)setDrivingOptionsState:(MWMDrivingOptionsState)state { + _drivingOptionsState = state; + [self layoutIfNeeded]; + self.drivingOptionHeightConstraint.constant = + (state == MWMDrivingOptionsStateNone) ? -kDrivingOptionsHeight : 0; + [UIView animateWithDuration:kDefaultAnimationDuration animations:^{ + [self layoutIfNeeded]; + }]; + + if (state == MWMDrivingOptionsStateDefine) { + [self.drivingOptionsButton setTitle:L(@"define_to_avoid_btn").uppercaseString + forState:UIControlStateNormal]; + } else if (state == MWMDrivingOptionsStateChange) { + [self.drivingOptionsButton setTitle:L(@"change_driving_options_btn").uppercaseString + forState:UIControlStateNormal]; + } +} + #pragma mark - Properties - (void)setIsVisible:(BOOL)isVisible diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiCollectionLayout.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiCollectionLayout.m similarity index 78% rename from iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiCollectionLayout.mm rename to iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiCollectionLayout.m index d6ae6b2552..4c5c383043 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiCollectionLayout.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiCollectionLayout.m @@ -9,7 +9,7 @@ - (UICollectionViewScrollDirection)scrollDirection { return UICollectionViewScrollDirectionHorizontal; } - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { - auto const size = self.collectionView.bounds.size; + CGSize size = self.collectionView.bounds.size; if (newBounds.size.height == 0) return NO; @@ -17,8 +17,8 @@ { dispatch_async(dispatch_get_main_queue(), ^{ [self invalidateLayout]; - auto cv = static_cast(self.collectionView); - cv.contentOffset = {}; + MWMTaxiCollectionView * cv = (MWMTaxiCollectionView *)self.collectionView; + self.collectionView.contentOffset = CGPointZero; cv.currentPage = 0; }); } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.m similarity index 94% rename from iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.mm rename to iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.m index 20386a7167..cb2ff5d2b8 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.m @@ -1,6 +1,6 @@ #import "MWMiPadRoutePreview.h" #import "MWMRouter.h" -#import "SwiftBridge.h" +#import "MWMAvailableAreaAffectDirection.h" @interface MWMRoutePreview () @@ -16,7 +16,8 @@ - (void)setupConstraints { - if (auto sv = self.superview) + UIView * sv = self.superview; + if (sv) { [self.topAnchor constraintEqualToAnchor:sv.topAnchor].active = YES; [self.bottomAnchor constraintEqualToAnchor:sv.bottomAnchor].active = YES; @@ -28,7 +29,8 @@ - (void)setIsVisible:(BOOL)isVisible { self.horizontalConstraint.active = NO; - if (auto sv = self.superview) + UIView * sv = self.superview; + if (sv) { NSLayoutXAxisAnchor * selfAnchor = isVisible ? self.leadingAnchor : self.trailingAnchor; self.horizontalConstraint = [selfAnchor constraintEqualToAnchor:sv.leadingAnchor]; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.xib b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.xib index 65cdca2340..84ecdf7808 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.xib +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPadRoutePreview.xib @@ -1,21 +1,14 @@ - + - - + - - - HelveticaNeue - HelveticaNeue-Medium - - @@ -29,7 +22,7 @@ - + @@ -43,6 +36,30 @@ + + + + + + + + + + + + + + + + + + @@ -141,7 +158,7 @@ - + @@ -203,7 +220,7 @@ - + - + diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.m similarity index 94% rename from iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.mm rename to iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.m index 4bdb9eeb0a..7f5710fc5d 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.m @@ -1,6 +1,6 @@ #import "MWMiPhoneRoutePreview.h" +#import "MWMAvailableAreaAffectDirection.h" #import "MWMCommon.h" -#import "SwiftBridge.h" @interface MWMRoutePreview () @@ -17,7 +17,7 @@ - (void)setupConstraints { - auto sv = self.superview; + UIView * sv = self.superview; [self.leadingAnchor constraintEqualToAnchor:sv.leadingAnchor].active = YES; [self.trailingAnchor constraintEqualToAnchor:sv.trailingAnchor].active = YES; self.verticalConstraint = [self.bottomAnchor constraintEqualToAnchor:sv.topAnchor]; @@ -33,7 +33,7 @@ - (void)setIsVisible:(BOOL)isVisible { - auto sv = self.superview; + UIView * sv = self.superview; if (!sv) return; self.verticalConstraint.active = NO; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.xib b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.xib index 7f1ad6c19e..5277673c05 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.xib +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMiPhoneRoutePreview.xib @@ -1,20 +1,14 @@ - + - - + - - - HelveticaNeue - - @@ -27,8 +21,8 @@ - - + + @@ -41,6 +35,29 @@ + + + + + + + + + + + + + + + + + @@ -154,12 +171,15 @@ - + + + + @@ -169,14 +189,16 @@ + + - + - + @@ -441,7 +463,7 @@ - + diff --git a/iphone/Maps/Classes/MWMSegue.mm b/iphone/Maps/Classes/MWMSegue.m similarity index 100% rename from iphone/Maps/Classes/MWMSegue.mm rename to iphone/Maps/Classes/MWMSegue.m diff --git a/iphone/Maps/Classes/MapViewController.h b/iphone/Maps/Classes/MapViewController.h index 4dcf5be546..0bbabab6f3 100644 --- a/iphone/Maps/Classes/MapViewController.h +++ b/iphone/Maps/Classes/MapViewController.h @@ -30,6 +30,7 @@ - (void)openCatalogAnimated:(BOOL)animated; - (void)openCatalogDeeplink:(NSURL * _Nullable)deeplinkUrl animated:(BOOL)animated; - (void)searchText:(NSString *)text; +- (void)openDrivingOptions; - (void)showRemoveAds; - (void)setPlacePageTopBound:(CGFloat)bound; diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 9cccc16a3d..df30ed0f9e 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -253,6 +253,7 @@ BOOL gIsFirstMyPositionMode = YES; GetFramework().InvalidateRendering(); [self showViralAlertIfNeeded]; [self checkAuthorization]; + [MWMRouter updateRoute]; } - (void)viewDidLoad @@ -509,6 +510,13 @@ BOOL gIsFirstMyPositionMode = YES; [self.controlsManager searchText:text forInputLocale:[[AppInfo sharedInfo] languageId]]; } +- (void)openDrivingOptions +{ + UIStoryboard *sb = [UIStoryboard instance:MWMStoryboardDrivingOptions];// [UIStoryboard storyboardWithName:@"DrivingOptions" bundle:nil]; + UIViewController * vc = [sb instantiateInitialViewController]; + [self.navigationController pushViewController:vc animated:YES]; +} + - (void)showRemoveAds { auto removeAds = [[RemoveAdsViewController alloc] init]; diff --git a/iphone/Maps/Core/Routing/MWMRouter.h b/iphone/Maps/Core/Routing/MWMRouter.h index 793a05e3f8..4684f778b3 100644 --- a/iphone/Maps/Core/Routing/MWMRouter.h +++ b/iphone/Maps/Core/Routing/MWMRouter.h @@ -1,6 +1,13 @@ #import "MWMRoutePoint.h" #import "MWMRouterType.h" +typedef NS_ENUM(NSInteger, MWMRoadType) { + MWMRoadTypeToll, + MWMRoadTypeDirty, + MWMRoadTypeFerry, + MWMRoadTypeMotorway +}; + typedef void (^MWMImageHeightBlock)(UIImage *, NSString *); @interface MWMRouter : NSObject @@ -54,6 +61,10 @@ typedef void (^MWMImageHeightBlock)(UIImage *, NSString *); + (void)restoreRouteIfNeeded; + (BOOL)hasSavedRoute; ++ (void)updateRoute; ++ (BOOL)hasActiveDrivingOptions; ++ (void)avoidRoadTypeAndRebuild:(MWMRoadType)type; + @end @interface MWMRouter (RouteManager) diff --git a/iphone/Maps/Core/Routing/MWMRouter.mm b/iphone/Maps/Core/Routing/MWMRouter.mm index 362d0dff1e..afa950b45a 100644 --- a/iphone/Maps/Core/Routing/MWMRouter.mm +++ b/iphone/Maps/Core/Routing/MWMRouter.mm @@ -38,6 +38,7 @@ using namespace routing; @property(nonatomic) uint32_t routeManagerTransactionId; @property(nonatomic) BOOL canAutoAddLastLocation; @property(nonatomic) BOOL isAPICall; +@property(strong, nonatomic) MWMRoutingOptions * routingOptions; + (MWMRouter *)router; @@ -172,6 +173,7 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType) + (BOOL)isRouteFinished { return GetFramework().GetRoutingManager().IsRouteFinished(); } + (BOOL)isRouteRebuildingOnly { return GetFramework().GetRoutingManager().IsRouteRebuildingOnly(); } + (BOOL)isOnRoute { return GetFramework().GetRoutingManager().IsRoutingFollowing(); } ++ (BOOL)IsRouteValid { return GetFramework().GetRoutingManager().IsRouteValid(); } + (NSArray *)points { NSMutableArray * points = [@[] mutableCopy]; @@ -227,6 +229,7 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType) [MWMLocationManager addObserver:self]; [MWMFrameworkListener addObserver:self]; _canAutoAddLastLocation = YES; + _routingOptions = [MWMRoutingOptions new]; } return self; } @@ -620,6 +623,23 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType) #pragma mark - MWMFrameworkRouteBuilderObserver +- (void)onRouteReady:(BOOL)hasWarnings +{ + self.routingOptions = [MWMRoutingOptions new]; + GetFramework().DeactivateMapSelection(true); + + auto startPoint = [MWMRouter startPoint]; + if (!startPoint || !startPoint.isMyPosition) + { + dispatch_async(dispatch_get_main_queue(), ^{ + [MWMRouter disableFollowMode]; + }); + } + + [[MWMMapViewControlsManager manager] onRouteReady:hasWarnings]; + [self updateFollowingInfo]; +} + - (void)processRouteBuilderEvent:(routing::RouterResultCode)code countries:(storage::CountriesVec const &)absentCountries { @@ -627,22 +647,11 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType) switch (code) { case routing::RouterResultCode::NoError: - case routing::RouterResultCode::HasWarnings: - { - GetFramework().DeactivateMapSelection(true); - - auto startPoint = [MWMRouter startPoint]; - if (!startPoint || !startPoint.isMyPosition) - { - dispatch_async(dispatch_get_main_queue(), ^{ - [MWMRouter disableFollowMode]; - }); - } - - [mapViewControlsManager onRouteReady]; - [self updateFollowingInfo]; + [self onRouteReady:NO]; + break; + case routing::RouterResultCode::HasWarnings: + [self onRouteReady:YES]; break; - } case routing::RouterResultCode::RouteFileNotExist: case routing::RouterResultCode::InconsistentMWMandRoute: case routing::RouterResultCode::NeedMoreMaps: @@ -650,6 +659,7 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType) case routing::RouterResultCode::RouteNotFound: if ([MWMRouter isTaxi]) return; + self.routingOptions = [MWMRoutingOptions new]; [self presentDownloaderAlert:code countries:absentCountries]; [[MWMNavigationDashboardManager manager] onRouteError:L(@"routing_planning_error")]; break; @@ -721,6 +731,16 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType) [MWMRouter rebuildWithBestRouter:NO]; }]; } + else if ([MWMRouter hasActiveDrivingOptions]) + { + [activeAlertController presentDefaultAlertWithTitle:L(@"unable_to_calc_alert_title") + message:L(@"unable_to_calc_alert_subtitle") + rightButtonTitle:L(@"settings") + leftButtonTitle:L(@"cancel") + rightButtonAction:^{ + [[MapViewController sharedController] openDrivingOptions]; + }]; + } else { [activeAlertController presentAlert:code]; @@ -763,4 +783,36 @@ void logPointEvent(MWMRoutePoint * point, NSString * eventType) return GetFramework().GetRoutingManager().HasSavedRoutePoints(); } ++ (void)updateRoute { + MWMRoutingOptions *newOptions = [MWMRoutingOptions new]; + if ((self.isRouteBuilt || !self.IsRouteValid) + && ![newOptions isEqual:[self router].routingOptions]) { + [self rebuildWithBestRouter:YES]; + } +} + ++ (BOOL)hasActiveDrivingOptions { + return [MWMRoutingOptions new].hasOptions; +} + ++ (void)avoidRoadTypeAndRebuild:(MWMRoadType)type { + MWMRoutingOptions *options = [MWMRoutingOptions new]; + switch(type) { + case MWMRoadTypeToll: + options.avoidToll = YES; + break; + case MWMRoadTypeDirty: + options.avoidDirty = YES; + break; + case MWMRoadTypeFerry: + options.avoidFerry = YES; + break; + case MWMRoadTypeMotorway: + options.avoidMotorway = YES; + break; + } + [options save]; + [self rebuildWithBestRouter:YES]; +} + @end diff --git a/iphone/Maps/Core/Settings/MWMRoutingOptions.h b/iphone/Maps/Core/Settings/MWMRoutingOptions.h new file mode 100644 index 0000000000..664ff976ef --- /dev/null +++ b/iphone/Maps/Core/Settings/MWMRoutingOptions.h @@ -0,0 +1,17 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MWMRoutingOptions : NSObject + +@property(nonatomic) BOOL avoidToll; +@property(nonatomic) BOOL avoidDirty; +@property(nonatomic) BOOL avoidFerry; +@property(nonatomic) BOOL avoidMotorway; +@property(nonatomic, readonly) BOOL hasOptions; + +- (void)save; + +@end + +NS_ASSUME_NONNULL_END diff --git a/iphone/Maps/Core/Settings/MWMRoutingOptions.mm b/iphone/Maps/Core/Settings/MWMRoutingOptions.mm new file mode 100644 index 0000000000..2906b6cb01 --- /dev/null +++ b/iphone/Maps/Core/Settings/MWMRoutingOptions.mm @@ -0,0 +1,79 @@ +#import "MWMRoutingOptions.h" + +#include "routing/routing_options.hpp" + +@interface MWMRoutingOptions() { + routing::RoutingOptions _options; +} + +@end + +@implementation MWMRoutingOptions + +- (instancetype)init { + self = [super init]; + if (self) { + _options = routing::RoutingOptions::LoadCarOptionsFromSettings(); + } + + return self; +} + +- (BOOL)avoidToll { + return _options.Has(routing::RoutingOptions::Road::Toll); +} + +- (void)setAvoidToll:(BOOL)avoid { + [self setOption:(routing::RoutingOptions::Road::Toll) enabled:avoid]; +} + +- (BOOL)avoidDirty { + return _options.Has(routing::RoutingOptions::Road::Dirty); +} + +- (void)setAvoidDirty:(BOOL)avoid { + [self setOption:(routing::RoutingOptions::Road::Dirty) enabled:avoid]; +} + +- (BOOL)avoidFerry { + return _options.Has(routing::RoutingOptions::Road::Ferry); +} + +- (void)setAvoidFerry:(BOOL)avoid { + [self setOption:(routing::RoutingOptions::Road::Ferry) enabled:avoid]; +} + +- (BOOL)avoidMotorway { + return _options.Has(routing::RoutingOptions::Road::Motorway); +} + +- (void)setAvoidMotorway:(BOOL)avoid { + [self setOption:(routing::RoutingOptions::Road::Motorway) enabled:avoid]; +} + +- (BOOL)hasOptions { + return self.avoidToll || self.avoidDirty || self.avoidFerry || self.avoidMotorway; +} + +- (void)save { + routing::RoutingOptions::SaveCarOptionsToSettings(_options); +} + +- (void)setOption:(routing::RoutingOptions::Road)option enabled:(BOOL)enabled { + if (enabled) { + _options.Add(option); + } else { + _options.Remove(option); + } +} + +- (BOOL)isEqual:(id)object { + if (![object isMemberOfClass:self.class]) { + return NO; + } + MWMRoutingOptions *another = (MWMRoutingOptions *)object; + return another.avoidToll == self.avoidToll && another.avoidDirty == self.avoidDirty && + another.avoidFerry == self.avoidFerry && another.avoidMotorway == self.avoidMotorway; +} + +@end diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_avoid_dirty.imageset/Contents.json b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_dirty.imageset/Contents.json new file mode 100644 index 0000000000..6012d12116 --- /dev/null +++ b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_dirty.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "icAvoidTolls.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_avoid_dirty.imageset/icAvoidTolls.pdf b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_dirty.imageset/icAvoidTolls.pdf new file mode 100644 index 0000000000..40229ca90b Binary files /dev/null and b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_dirty.imageset/icAvoidTolls.pdf differ diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_avoid_ferry.imageset/Contents.json b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_ferry.imageset/Contents.json new file mode 100644 index 0000000000..b0055dab1f --- /dev/null +++ b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_ferry.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "icAvoidTolls-2.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_avoid_ferry.imageset/icAvoidTolls-2.pdf b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_ferry.imageset/icAvoidTolls-2.pdf new file mode 100644 index 0000000000..538ad769aa Binary files /dev/null and b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_ferry.imageset/icAvoidTolls-2.pdf differ diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_avoid_tolls.imageset/Contents.json b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_tolls.imageset/Contents.json new file mode 100644 index 0000000000..cb8547141e --- /dev/null +++ b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_tolls.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "icAvoidTolls-3.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Place Page/ic_avoid_tolls.imageset/icAvoidTolls-3.pdf b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_tolls.imageset/icAvoidTolls-3.pdf new file mode 100644 index 0000000000..9f3684f453 Binary files /dev/null and b/iphone/Maps/Images.xcassets/Place Page/ic_avoid_tolls.imageset/icAvoidTolls-3.pdf differ diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 7ad52ded72..c0c1e3896a 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -216,8 +216,8 @@ 34AB660E1FC5AA320078E451 /* NavigationControlView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34AB65CD1FC5AA320078E451 /* NavigationControlView.xib */; }; 34AB66111FC5AA320078E451 /* NavigationTurnsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65CE1FC5AA320078E451 /* NavigationTurnsView.swift */; }; 34AB66141FC5AA320078E451 /* MWMNavigationInfoView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34AB65D01FC5AA320078E451 /* MWMNavigationInfoView.xib */; }; - 34AB66171FC5AA320078E451 /* MWMiPhoneRoutePreview.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65D21FC5AA320078E451 /* MWMiPhoneRoutePreview.mm */; }; - 34AB661A1FC5AA330078E451 /* MWMTaxiCollectionLayout.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65D31FC5AA320078E451 /* MWMTaxiCollectionLayout.mm */; }; + 34AB66171FC5AA320078E451 /* MWMiPhoneRoutePreview.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65D21FC5AA320078E451 /* MWMiPhoneRoutePreview.m */; }; + 34AB661A1FC5AA330078E451 /* MWMTaxiCollectionLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65D31FC5AA320078E451 /* MWMTaxiCollectionLayout.m */; }; 34AB661D1FC5AA330078E451 /* MWMTaxiPreviewDataSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65D41FC5AA320078E451 /* MWMTaxiPreviewDataSource.mm */; }; 34AB66201FC5AA330078E451 /* RouteStartButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65D51FC5AA320078E451 /* RouteStartButton.swift */; }; 34AB66231FC5AA330078E451 /* MWMiPadRoutePreview.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34AB65D61FC5AA320078E451 /* MWMiPadRoutePreview.xib */; }; @@ -236,7 +236,7 @@ 34AB664A1FC5AA330078E451 /* RouteManageriPadPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65E51FC5AA320078E451 /* RouteManageriPadPresentationController.swift */; }; 34AB664D1FC5AA330078E451 /* RouteManagerFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65E61FC5AA320078E451 /* RouteManagerFooterView.swift */; }; 34AB66501FC5AA330078E451 /* RoutePreviewTaxiCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65E81FC5AA320078E451 /* RoutePreviewTaxiCell.swift */; }; - 34AB66531FC5AA330078E451 /* MWMiPadRoutePreview.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65E91FC5AA320078E451 /* MWMiPadRoutePreview.mm */; }; + 34AB66531FC5AA330078E451 /* MWMiPadRoutePreview.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65E91FC5AA320078E451 /* MWMiPadRoutePreview.m */; }; 34AB66561FC5AA330078E451 /* TransportTransitPedestrian.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65EE1FC5AA320078E451 /* TransportTransitPedestrian.swift */; }; 34AB66591FC5AA330078E451 /* TransportTransitFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AB65EF1FC5AA320078E451 /* TransportTransitFlowLayout.swift */; }; 34AB665C1FC5AA330078E451 /* TransportTransitIntermediatePoint.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34AB65F01FC5AA320078E451 /* TransportTransitIntermediatePoint.xib */; }; @@ -322,7 +322,7 @@ 34E776141F14B17F003040B3 /* AvailableArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34E776121F14B17F003040B3 /* AvailableArea.swift */; }; 34E7761F1F14DB48003040B3 /* PlacePageArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34E7761D1F14DB48003040B3 /* PlacePageArea.swift */; }; 34E776331F15FAC2003040B3 /* MWMPlacePageManagerHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34E776311F15FAC2003040B3 /* MWMPlacePageManagerHelper.mm */; }; - 34EF94291C05A6F30050B714 /* MWMSegue.mm in Sources */ = {isa = PBXBuildFile; fileRef = F607C18D1C047FDC00B53A87 /* MWMSegue.mm */; }; + 34EF94291C05A6F30050B714 /* MWMSegue.m in Sources */ = {isa = PBXBuildFile; fileRef = F607C18D1C047FDC00B53A87 /* MWMSegue.m */; }; 34F1ADD31F6BC09E001CE79D /* PPPReview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34F1ADD11F6BC09E001CE79D /* PPPReview.swift */; }; 34F4072C1E9E1AFF00E57AC0 /* Banner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34F4071D1E9E1AFF00E57AC0 /* Banner.swift */; }; 34F4072F1E9E1AFF00E57AC0 /* BannersCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34F4071E1E9E1AFF00E57AC0 /* BannersCache.swift */; }; @@ -391,6 +391,7 @@ 4767CDC120B477BA00BD8166 /* WelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4767CDC020B477BA00BD8166 /* WelcomeViewController.swift */; }; 47699A0821F08E37009E6585 /* NSDate+TimeDistance.m in Sources */ = {isa = PBXBuildFile; fileRef = 47699A0721F08E37009E6585 /* NSDate+TimeDistance.m */; }; 47699A0A21F0C4C8009E6585 /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47699A0921F0C4C8009E6585 /* NotificationManager.swift */; }; + 477219052243E79500E5B227 /* DrivingOptionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 477219042243E79500E5B227 /* DrivingOptionsViewController.swift */; }; 477D7AC7218F1515007EE2CB /* IPaidRoutePurchase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 477D7AC6218F1515007EE2CB /* IPaidRoutePurchase.swift */; }; 47800D1D20BEEE2E00072F42 /* TermsOfUseController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47800D1C20BEEE2E00072F42 /* TermsOfUseController.swift */; }; 47800D2520C05E3200072F42 /* libFlurry_8.6.1.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 47800D2420C05E3200072F42 /* libFlurry_8.6.1.a */; }; @@ -414,6 +415,8 @@ 47C7F9732191E15A00C2760C /* InAppBilling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C7F9722191E15A00C2760C /* InAppBilling.swift */; }; 47C7F97521930F5300C2760C /* IInAppBilling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C7F97421930F5300C2760C /* IInAppBilling.swift */; }; 47D0026721999DA900F651A2 /* PendingTransactionsHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47D0026621999DA900F651A2 /* PendingTransactionsHandler.swift */; }; + 47DF72B922520CE20004AB10 /* MWMRoutingOptions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 474902D9224A54EC008D71E0 /* MWMRoutingOptions.mm */; }; + 47DF72BB225356BF0004AB10 /* DrivingOptions.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 47DF72BA225356BF0004AB10 /* DrivingOptions.storyboard */; }; 47E3C72121108E9F008B3B27 /* BookmarksLoadedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47E3C71F21108E9F008B3B27 /* BookmarksLoadedViewController.swift */; }; 47E3C72221108E9F008B3B27 /* BookmarksLoadedViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 47E3C72021108E9F008B3B27 /* BookmarksLoadedViewController.xib */; }; 47E3C7252111E41B008B3B27 /* DimmedModalPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47E3C7242111E41B008B3B27 /* DimmedModalPresentationController.swift */; }; @@ -1126,8 +1129,8 @@ 34AB65CE1FC5AA320078E451 /* NavigationTurnsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationTurnsView.swift; sourceTree = ""; }; 34AB65CF1FC5AA320078E451 /* MWMNavigationInfoView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMNavigationInfoView.h; sourceTree = ""; }; 34AB65D01FC5AA320078E451 /* MWMNavigationInfoView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMNavigationInfoView.xib; sourceTree = ""; }; - 34AB65D21FC5AA320078E451 /* MWMiPhoneRoutePreview.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMiPhoneRoutePreview.mm; sourceTree = ""; }; - 34AB65D31FC5AA320078E451 /* MWMTaxiCollectionLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMTaxiCollectionLayout.mm; sourceTree = ""; }; + 34AB65D21FC5AA320078E451 /* MWMiPhoneRoutePreview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMiPhoneRoutePreview.m; sourceTree = ""; }; + 34AB65D31FC5AA320078E451 /* MWMTaxiCollectionLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMTaxiCollectionLayout.m; sourceTree = ""; }; 34AB65D41FC5AA320078E451 /* MWMTaxiPreviewDataSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMTaxiPreviewDataSource.mm; sourceTree = ""; }; 34AB65D51FC5AA320078E451 /* RouteStartButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RouteStartButton.swift; sourceTree = ""; }; 34AB65D61FC5AA320078E451 /* MWMiPadRoutePreview.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMiPadRoutePreview.xib; sourceTree = ""; }; @@ -1148,7 +1151,7 @@ 34AB65E61FC5AA320078E451 /* RouteManagerFooterView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RouteManagerFooterView.swift; sourceTree = ""; }; 34AB65E71FC5AA320078E451 /* MWMRoutePreviewTaxiCellType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMRoutePreviewTaxiCellType.h; sourceTree = ""; }; 34AB65E81FC5AA320078E451 /* RoutePreviewTaxiCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoutePreviewTaxiCell.swift; sourceTree = ""; }; - 34AB65E91FC5AA320078E451 /* MWMiPadRoutePreview.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMiPadRoutePreview.mm; sourceTree = ""; }; + 34AB65E91FC5AA320078E451 /* MWMiPadRoutePreview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMiPadRoutePreview.m; sourceTree = ""; }; 34AB65EA1FC5AA320078E451 /* MWMiPadRoutePreview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMiPadRoutePreview.h; sourceTree = ""; }; 34AB65EB1FC5AA320078E451 /* MWMTaxiPreviewDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMTaxiPreviewDataSource.h; sourceTree = ""; }; 34AB65EE1FC5AA320078E451 /* TransportTransitPedestrian.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransportTransitPedestrian.swift; sourceTree = ""; }; @@ -1410,6 +1413,8 @@ 473464A5218B0BC000D6AF5B /* MWMPurchaseValidation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMPurchaseValidation.h; sourceTree = ""; }; 473464A6218B0BC000D6AF5B /* MWMPurchaseValidation.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMPurchaseValidation.mm; sourceTree = ""; }; 473CBF9A2164DD470059BD54 /* SettingsTableViewSelectableProgressCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsTableViewSelectableProgressCell.swift; sourceTree = ""; }; + 474902D8224A54EC008D71E0 /* MWMRoutingOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMRoutingOptions.h; sourceTree = ""; }; + 474902D9224A54EC008D71E0 /* MWMRoutingOptions.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMRoutingOptions.mm; sourceTree = ""; }; 474AC76A2139E4F2002F9BF9 /* RemoveAdsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoveAdsViewController.swift; sourceTree = ""; }; 474AC76B2139E4F2002F9BF9 /* RemoveAdsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RemoveAdsViewController.xib; sourceTree = ""; }; 474C9F59213FF75800369009 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; }; @@ -1423,6 +1428,7 @@ 47699A0621F08E37009E6585 /* NSDate+TimeDistance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSDate+TimeDistance.h"; sourceTree = ""; }; 47699A0721F08E37009E6585 /* NSDate+TimeDistance.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSDate+TimeDistance.m"; sourceTree = ""; }; 47699A0921F0C4C8009E6585 /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = ""; }; + 477219042243E79500E5B227 /* DrivingOptionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrivingOptionsViewController.swift; sourceTree = ""; }; 477D7AC6218F1515007EE2CB /* IPaidRoutePurchase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPaidRoutePurchase.swift; sourceTree = ""; }; 47800D1C20BEEE2E00072F42 /* TermsOfUseController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfUseController.swift; sourceTree = ""; }; 47800D2420C05E3200072F42 /* libFlurry_8.6.1.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libFlurry_8.6.1.a; sourceTree = ""; }; @@ -1456,6 +1462,7 @@ 47C7F97421930F5300C2760C /* IInAppBilling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IInAppBilling.swift; sourceTree = ""; }; 47C7F976219310D800C2760C /* IMWMPurchaseValidation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMWMPurchaseValidation.h; sourceTree = ""; }; 47D0026621999DA900F651A2 /* PendingTransactionsHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PendingTransactionsHandler.swift; sourceTree = ""; }; + 47DF72BA225356BF0004AB10 /* DrivingOptions.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = DrivingOptions.storyboard; sourceTree = ""; }; 47E3C71F21108E9F008B3B27 /* BookmarksLoadedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksLoadedViewController.swift; sourceTree = ""; }; 47E3C72021108E9F008B3B27 /* BookmarksLoadedViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BookmarksLoadedViewController.xib; sourceTree = ""; }; 47E3C7242111E41B008B3B27 /* DimmedModalPresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DimmedModalPresentationController.swift; sourceTree = ""; }; @@ -1613,7 +1620,7 @@ F607C1831C032A8800B53A87 /* resources-hdpi_clear */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "resources-hdpi_clear"; path = "../../data/resources-hdpi_clear"; sourceTree = ""; }; F607C1841C032A8800B53A87 /* resources-hdpi_dark */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "resources-hdpi_dark"; path = "../../data/resources-hdpi_dark"; sourceTree = ""; }; F607C18C1C047FDC00B53A87 /* MWMSegue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSegue.h; sourceTree = ""; }; - F607C18D1C047FDC00B53A87 /* MWMSegue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSegue.mm; sourceTree = ""; }; + F607C18D1C047FDC00B53A87 /* MWMSegue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMSegue.m; sourceTree = ""; }; F60C8BED1FCED15900DCF5FB /* DiscoverySearchCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DiscoverySearchCell.xib; sourceTree = ""; }; F61579321AC2CE9A0032D8E9 /* MWMRateAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMRateAlert.h; sourceTree = ""; }; F61579331AC2CE9A0032D8E9 /* MWMRateAlert.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = MWMRateAlert.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; @@ -2445,6 +2452,8 @@ 340475401E081A4600C92850 /* MWMSettings.h */, 340475411E081A4600C92850 /* MWMSettings.mm */, 34FB47581E3B928D00D94ED8 /* MWMCoreUnits.h */, + 474902D8224A54EC008D71E0 /* MWMRoutingOptions.h */, + 474902D9224A54EC008D71E0 /* MWMRoutingOptions.mm */, ); path = Settings; sourceTree = ""; @@ -3055,16 +3064,16 @@ isa = PBXGroup; children = ( 34AB65EA1FC5AA320078E451 /* MWMiPadRoutePreview.h */, - 34AB65E91FC5AA320078E451 /* MWMiPadRoutePreview.mm */, + 34AB65E91FC5AA320078E451 /* MWMiPadRoutePreview.m */, 34AB65D61FC5AA320078E451 /* MWMiPadRoutePreview.xib */, 34AB65FC1FC5AA320078E451 /* MWMiPhoneRoutePreview.h */, - 34AB65D21FC5AA320078E451 /* MWMiPhoneRoutePreview.mm */, + 34AB65D21FC5AA320078E451 /* MWMiPhoneRoutePreview.m */, 34AB65FE1FC5AA320078E451 /* MWMiPhoneRoutePreview.xib */, 34AB65FF1FC5AA320078E451 /* MWMRoutePreview.h */, 34AB65FD1FC5AA320078E451 /* MWMRoutePreview.mm */, 34AB65E71FC5AA320078E451 /* MWMRoutePreviewTaxiCellType.h */, 34AB65FB1FC5AA320078E451 /* MWMTaxiCollectionLayout.h */, - 34AB65D31FC5AA320078E451 /* MWMTaxiCollectionLayout.mm */, + 34AB65D31FC5AA320078E451 /* MWMTaxiCollectionLayout.m */, 34AB65EB1FC5AA320078E451 /* MWMTaxiPreviewDataSource.h */, 34AB65D41FC5AA320078E451 /* MWMTaxiPreviewDataSource.mm */, 34AB65D71FC5AA320078E451 /* RouteManager */, @@ -3516,7 +3525,7 @@ isa = PBXGroup; children = ( F607C18C1C047FDC00B53A87 /* MWMSegue.h */, - F607C18D1C047FDC00B53A87 /* MWMSegue.mm */, + F607C18D1C047FDC00B53A87 /* MWMSegue.m */, ); name = Segue; sourceTree = ""; @@ -4290,6 +4299,8 @@ F6E2FD4D1E097BA00083EBEC /* MWMUnitsController.mm */, 3DEE1AE921F72CD300054A91 /* MWMPowerManagmentViewController.h */, 3DEE1AEA21F72CD300054A91 /* MWMPowerManagmentViewController.mm */, + 477219042243E79500E5B227 /* DrivingOptionsViewController.swift */, + 47DF72BA225356BF0004AB10 /* DrivingOptions.storyboard */, ); path = Settings; sourceTree = ""; @@ -4693,6 +4704,7 @@ 34AB66711FC5AA330078E451 /* TransportTransitTrain.xib in Resources */, 33046836219C5A4E0041F3A8 /* CategorySettings.storyboard in Resources */, 34BBD6471F82649D0070CA50 /* GoogleSignIn.bundle in Resources */, + 47DF72BB225356BF0004AB10 /* DrivingOptions.storyboard in Resources */, F6E2FE851E097BA00083EBEC /* MWMPlacePageOpeningHoursWeekDayView.xib in Resources */, F6E2FE941E097BA00083EBEC /* PlacePageTaxiCell.xib in Resources */, 47289E5B2212DFFF002ABFC0 /* EditOnWebAlertViewController.xib in Resources */, @@ -4940,6 +4952,7 @@ 34AB666B1FC5AA330078E451 /* TransportTransitCell.swift in Sources */, 3404163C1E7BDFE000E2B6D6 /* PhotosViewController.swift in Sources */, 34AB66471FC5AA330078E451 /* RouteManagerTableView.swift in Sources */, + 47DF72B922520CE20004AB10 /* MWMRoutingOptions.mm in Sources */, F6E2FE611E097BA00083EBEC /* MWMBookmarkCell.mm in Sources */, F6E2FEA31E097BA00083EBEC /* MWMPPView.mm in Sources */, 3D15ACEE2155117000F725D5 /* MWMObjectsCategorySelectorDataSource.mm in Sources */, @@ -5070,7 +5083,7 @@ F6E2FD561E097BA00083EBEC /* MWMMapDownloaderButtonTableViewCell.mm in Sources */, 3462258F1DDC5DBA001E8752 /* MWMSearchNoResultsAlert.mm in Sources */, 470F5A7D2189BB2F00754295 /* PaidRoutePurchase.swift in Sources */, - 34AB66171FC5AA320078E451 /* MWMiPhoneRoutePreview.mm in Sources */, + 34AB66171FC5AA320078E451 /* MWMiPhoneRoutePreview.m in Sources */, 6741A9E71BF340DE002C974C /* MWMCircularProgressView.mm in Sources */, 34AC8FDB1EFC07FE00E7F910 /* UILabel+NumberOfVisibleLines.swift in Sources */, 4767CD9F20AAD48A00BD8166 /* Checkmark.swift in Sources */, @@ -5130,6 +5143,7 @@ F6E2FF361E097BA00083EBEC /* MWMSearchSuggestionCell.mm in Sources */, F6E2FE3A1E097BA00083EBEC /* MWMMigrationView.mm in Sources */, 3472B5CF200F4A2B00DC6CD5 /* BackgroundFetchTask.swift in Sources */, + 477219052243E79500E5B227 /* DrivingOptionsViewController.swift in Sources */, F6E2FF3C1E097BA00083EBEC /* MWMSearchTableView.mm in Sources */, F6E2FF661E097BA00083EBEC /* MWMTTSSettingsViewController.mm in Sources */, 3472B5EB200F8CFF00DC6CD5 /* MWMUGCHelper.mm in Sources */, @@ -5234,7 +5248,7 @@ F63AF5061EA6162400A1DB98 /* FilterTypeCell.swift in Sources */, 347752881F725002000D46A3 /* UGCAddReviewRatingCell.swift in Sources */, 47E3C7332111F4D8008B3B27 /* CoverVerticalDismissalAnimator.swift in Sources */, - 34AB661A1FC5AA330078E451 /* MWMTaxiCollectionLayout.mm in Sources */, + 34AB661A1FC5AA330078E451 /* MWMTaxiCollectionLayout.m in Sources */, 345C2F8A1F86361B009DB8B4 /* MWMUGCViewModel.mm in Sources */, 33F8BA4E2199AB9500ECA8EE /* TagsDataSource.swift in Sources */, 47F67D1521CAB21B0069754E /* MWMImageCoder.m in Sources */, @@ -5278,7 +5292,7 @@ 33B19C65218B46C100B323A7 /* SharingTagsViewController.swift in Sources */, 3404754D1E081A4600C92850 /* MWMKeyboard.mm in Sources */, 3457C4261F680F1900028233 /* String+BoundingRect.swift in Sources */, - 34EF94291C05A6F30050B714 /* MWMSegue.mm in Sources */, + 34EF94291C05A6F30050B714 /* MWMSegue.m in Sources */, 3430291D1F87BF4400D0A07C /* ReviewsViewController.swift in Sources */, F6E2FE731E097BA00083EBEC /* MWMOpeningHours.mm in Sources */, 47E3C7312111F4C2008B3B27 /* CoverVerticalPresentationAnimator.swift in Sources */, @@ -5324,7 +5338,7 @@ 349FC54B1F680DAE00968C9F /* ExpandableReviewSettings.swift in Sources */, F6E2FE0A1E097BA00083EBEC /* MWMOpeningHoursDeleteScheduleTableViewCell.mm in Sources */, 3454D7DA1E07F045004AF2AD /* UILabel+RuntimeAttributes.mm in Sources */, - 34AB66531FC5AA330078E451 /* MWMiPadRoutePreview.mm in Sources */, + 34AB66531FC5AA330078E451 /* MWMiPadRoutePreview.m in Sources */, 3454D7E31E07F045004AF2AD /* UITextView+RuntimeAttributes.mm in Sources */, F6A2184A1CA3F26800BE2CC6 /* MWMEditorViralActivityItem.mm in Sources */, F6E2FED61E097BA00083EBEC /* MWMSearchChangeModeView.mm in Sources */, diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h index 9c0f872c32..9cf9107be4 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h @@ -139,7 +139,7 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d @protocol MWMBanner; /// ViewModel for place page. -@interface MWMPlacePageData : NSObject +@interface MWMPlacePageData : NSObject @property(copy, nonatomic) MWMVoidBlock refreshPreviewCallback; @property(copy, nonatomic) place_page::NewSectionsAreReady sectionsAreReadyCallback; @@ -252,6 +252,7 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d - (BOOL)isHTMLDescription; - (BOOL)isMyPosition; - (BOOL)isRoutePoint; +- (RoadWarningMarkType)roadType; - (BOOL)isPreviewExtended; - (BOOL)isPartnerAppInstalled; diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm index cf3f5d473e..839d2df610 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm @@ -792,6 +792,7 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS"; - (BOOL)isMyPosition { return m_info.IsMyPosition(); } - (BOOL)isHTMLDescription { return strings::IsHTML(GetPreferredBookmarkStr(m_info.GetBookmarkData().m_description)); } - (BOOL)isRoutePoint { return m_info.IsRoutePoint(); } +- (RoadWarningMarkType)roadType { return m_info.GetRoadType(); } - (BOOL)isPreviewExtended { return m_info.IsPreviewExtended(); } - (BOOL)isPartnerAppInstalled { diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index 123b422c8e..28562bd149 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -543,6 +543,30 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page: [UIApplication.sharedApplication openURL:url options:@{} completionHandler:nil]; } +- (void)avoidDirty { + [MWMRouter avoidRoadTypeAndRebuild:MWMRoadTypeDirty]; + [self closePlacePage]; +} + + +- (void)avoidFerry { + [MWMRouter avoidRoadTypeAndRebuild:MWMRoadTypeFerry]; + [self closePlacePage]; +} + + +- (void)avoidMotorway { + [MWMRouter avoidRoadTypeAndRebuild:MWMRoadTypeMotorway]; + [self closePlacePage]; +} + + +- (void)avoidToll { + [MWMRouter avoidRoadTypeAndRebuild:MWMRoadTypeToll]; + [self closePlacePage]; +} + + - (void)showPhotoAtIndex:(NSInteger)index referenceView:(UIView *)referenceView referenceViewWhenDismissingHandler: diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h b/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h index 4f9ec0bea2..f790cc32cf 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h @@ -20,9 +20,11 @@ - (void)searchBookingHotels; - (void)openPartner; - -- (void)apiBack; - (void)downloadSelectedArea; +- (void)avoidToll; +- (void)avoidDirty; +- (void)avoidFerry; +- (void)avoidMotorway; @end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.h index b4e77e4c34..e48fd0d29e 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.h +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.h @@ -12,7 +12,11 @@ enum class EButton // Required button's order RouteFrom, RouteRemoveStop, RouteTo, - Share + Share, + AvoidToll, + AvoidDirty, + AvoidFerry, + AvoidMotorway }; NSString * titleForButton(EButton type, int partnerIndex, BOOL isSelected); diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.mm index 3784399f3a..f7f9ab20b5 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMActionBarButton.mm @@ -27,6 +27,10 @@ NSString * titleForButton(EButton type, int partnerIndex, BOOL isSelected) case EButton::More: return L(@"placepage_more_button"); case EButton::RouteAddStop: return L(@"placepage_add_stop"); case EButton::RouteRemoveStop: return L(@"placepage_remove_stop"); + case EButton::AvoidToll: return L(@"avoid_tolls"); + case EButton::AvoidDirty: return L(@"avoid_unpaved"); + case EButton::AvoidFerry: return L(@"avoid_ferry"); + case EButton::AvoidMotorway: return L(@"avoid_motorways"); case EButton::Partner: return titleForPartner(partnerIndex); } } @@ -156,6 +160,22 @@ UIColor * backgroundColorForPartner(int partnerIndex) self.label.textColor = textColorForPartner(self.partnerIndex); self.backgroundColor = backgroundColorForPartner(self.partnerIndex); break; + case EButton::AvoidToll: + [self.button setImage:[UIImage imageNamed:@"ic_avoid_tolls"] + forState:UIControlStateNormal]; + break; + case EButton::AvoidDirty: + [self.button setImage:[UIImage imageNamed:@"ic_avoid_dirty"] + forState:UIControlStateNormal]; + break; + case EButton::AvoidFerry: + [self.button setImage:[UIImage imageNamed:@"ic_avoid_ferry"] + forState:UIControlStateNormal]; + break; + case EButton::AvoidMotorway: + [self.button setImage:[UIImage imageNamed:@"ic_remove_route_point"] + forState:UIControlStateNormal]; + break; } self.button.enabled = !isDisabled; } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.h b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.h index bca53be71a..0b48ffd723 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.h +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.h @@ -2,31 +2,12 @@ @class MWMPlacePageData; -@protocol MWMActionBarSharedData - -- (BOOL)isBookmark; -- (BOOL)isBookmarkEditable; -- (BOOL)isOpentable; -- (BOOL)isPartner; -- (BOOL)isBooking; -- (BOOL)isBookingSearch; -- (BOOL)isApi; -- (BOOL)isMyPosition; -- (BOOL)isRoutePoint; -- (NSString *)title; -- (NSString *)subtitle; -- (NSString *)phoneNumber; -- (int)partnerIndex; -- (NSURL *)sponsoredURL; - -@end - @protocol MWMActionBarProtocol; @interface MWMPlacePageActionBar : SolidTouchView + (MWMPlacePageActionBar *)actionBarWithDelegate:(id)delegate; -- (void)configureWithData:(id)data; +- (void)configureWithData:(MWMPlacePageData *)data; @property(nonatomic) BOOL isAreaNotDownloaded; diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.mm index 55b874f07b..cab5bf4247 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.mm @@ -6,6 +6,7 @@ #import "MWMPlacePageProtocol.h" #import "MWMRouter.h" #import "MapViewController.h" +#import "MWMPlacePageData.h" @interface MWMPlacePageActionBar () { @@ -16,7 +17,7 @@ @property(nonatomic) NSLayoutConstraint * visibleConstraint; @property(weak, nonatomic) IBOutlet UIStackView * barButtons; @property(weak, nonatomic) id delegate; -@property(weak, nonatomic) id data; +@property(weak, nonatomic) MWMPlacePageData * data; @end @@ -31,7 +32,7 @@ return bar; } -- (void)configureWithData:(id)data +- (void)configureWithData:(MWMPlacePageData *)data { self.data = data; [self configureButtons]; @@ -46,7 +47,7 @@ [self.barButtons.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; } -- (void)setFirstButton:(id)data +- (void)setFirstButton:(MWMPlacePageData *)data { vector buttons; @@ -90,7 +91,7 @@ std::copy(begin, buttons.end(), std::back_inserter(m_additionalButtons)); } -- (void)setSecondButton:(id)data +- (void)setSecondButton:(MWMPlacePageData *)data { vector buttons; BOOL const isCanAddIntermediatePoint = [MWMRouter canAddIntermediatePoint]; @@ -122,7 +123,7 @@ } } -- (void)addButtons2UI:(id)data +- (void)addButtons2UI:(MWMPlacePageData *)data { BOOL const isPartner = [data isPartner] && [data sponsoredURL] != nil; int const partnerIndex = isPartner ? [data partnerIndex] : -1; @@ -142,12 +143,26 @@ - (void)setSingleButton { m_visibleButtons.push_back(EButton::RouteRemoveStop); } -- (void)setButtons:(id)data +- (void)setButtons:(MWMPlacePageData *)data { - BOOL const isRoutePoint = [data isRoutePoint]; - if (isRoutePoint) + RoadWarningMarkType roadType = [data roadType]; + if ([data isRoutePoint]) { [self setSingleButton]; + } else if (roadType != RoadWarningMarkType::Count) { + switch (roadType) { + case RoadWarningMarkType::Toll: + m_visibleButtons.push_back(EButton::AvoidToll); + break; + case RoadWarningMarkType::Ferry: + m_visibleButtons.push_back(EButton::AvoidFerry); + break; + case RoadWarningMarkType::Dirty: + m_visibleButtons.push_back(EButton::AvoidDirty); + break; + default: + break; + } } else { @@ -227,6 +242,10 @@ case EButton::More: [self showActionSheet]; break; case EButton::RouteAddStop: [delegate routeAddStop]; break; case EButton::RouteRemoveStop: [delegate routeRemoveStop]; break; + case EButton::AvoidToll: [delegate avoidToll]; break; + case EButton::AvoidDirty: [delegate avoidDirty]; break; + case EButton::AvoidFerry: [delegate avoidFerry]; break; + case EButton::AvoidMotorway: [delegate avoidMotorway]; break; case EButton::Partner: [delegate openPartner]; break; } } diff --git a/iphone/Maps/UI/Settings/Cells/SettingsTableViewSwitchCell.swift b/iphone/Maps/UI/Settings/Cells/SettingsTableViewSwitchCell.swift index 4aad8e8947..7a2896a42c 100644 --- a/iphone/Maps/UI/Settings/Cells/SettingsTableViewSwitchCell.swift +++ b/iphone/Maps/UI/Settings/Cells/SettingsTableViewSwitchCell.swift @@ -12,7 +12,7 @@ final class SettingsTableViewSwitchCell: MWMTableViewCell { } } - weak var delegate: SettingsTableViewSwitchCellDelegate? + @IBOutlet weak var delegate: SettingsTableViewSwitchCellDelegate? @objc var isEnabled = true { diff --git a/iphone/Maps/UI/Settings/DrivingOptions.storyboard b/iphone/Maps/UI/Settings/DrivingOptions.storyboard new file mode 100644 index 0000000000..8fe1ebba8a --- /dev/null +++ b/iphone/Maps/UI/Settings/DrivingOptions.storyboard @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iphone/Maps/UI/Settings/DrivingOptionsViewController.swift b/iphone/Maps/UI/Settings/DrivingOptionsViewController.swift new file mode 100644 index 0000000000..9a7496818a --- /dev/null +++ b/iphone/Maps/UI/Settings/DrivingOptionsViewController.swift @@ -0,0 +1,38 @@ +import UIKit + +class DrivingOptionsViewController: MWMTableViewController { + let options = MWMRoutingOptions() + @IBOutlet var tollRoadsCell: SettingsTableViewSwitchCell! + @IBOutlet var unpavedRoadsCell: SettingsTableViewSwitchCell! + @IBOutlet var ferryCrossingsCell: SettingsTableViewSwitchCell! + @IBOutlet var motorwaysCell: SettingsTableViewSwitchCell! + + override func viewDidLoad() { + super.viewDidLoad() + title = L("driving_options_title") + tollRoadsCell.isOn = options.avoidToll + unpavedRoadsCell.isOn = options.avoidDirty + ferryCrossingsCell.isOn = options.avoidFerry + motorwaysCell.isOn = options.avoidMotorway + } + + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return L("driving_options_subheader") + } +} + +extension DrivingOptionsViewController: SettingsTableViewSwitchCellDelegate { + func switchCell(_ cell: SettingsTableViewSwitchCell, didChangeValue value: Bool) { + if cell == tollRoadsCell { + options.avoidToll = cell.isOn + } else if cell == unpavedRoadsCell { + options.avoidDirty = cell.isOn + } else if cell == ferryCrossingsCell { + options.avoidFerry = cell.isOn + } else if cell == motorwaysCell { + options.avoidMotorway = cell.isOn + } + + options.save() + } +} diff --git a/iphone/Maps/UI/Settings/MWMSettingsViewController.mm b/iphone/Maps/UI/Settings/MWMSettingsViewController.mm index dbef215740..c1f9394e8c 100644 --- a/iphone/Maps/UI/Settings/MWMSettingsViewController.mm +++ b/iphone/Maps/UI/Settings/MWMSettingsViewController.mm @@ -44,6 +44,7 @@ using namespace power_management; @property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * perspectiveViewCell; @property(weak, nonatomic) IBOutlet SettingsTableViewSwitchCell * autoZoomCell; @property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * voiceInstructionsCell; +@property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * drivingOptionsCell; @property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * helpCell; @property(weak, nonatomic) IBOutlet SettingsTableViewLinkCell * aboutCell; @@ -349,6 +350,10 @@ using namespace power_management; withParameters:@{kStatAction : kStatChangeLanguage}]; [self performSegueWithIdentifier:@"SettingsToTTSSegue" sender:nil]; } + else if (cell == self.drivingOptionsCell) + { + [self performSegueWithIdentifier:@"settingsToDrivingOptionsSegue" sender:nil]; + } else if (cell == self.helpCell) { [Statistics logEvent:kStatSettingsOpenSection withParameters:@{kStatName : kStatHelp}]; diff --git a/iphone/Maps/UI/Storyboard/Settings.storyboard b/iphone/Maps/UI/Storyboard/Settings.storyboard index c00671cd6c..d97c282c4d 100644 --- a/iphone/Maps/UI/Storyboard/Settings.storyboard +++ b/iphone/Maps/UI/Storyboard/Settings.storyboard @@ -1,11 +1,11 @@ - + - + @@ -722,12 +722,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -762,7 +800,7 @@ - + @@ -817,6 +855,7 @@ + @@ -843,11 +882,12 @@ + - + @@ -1902,6 +1942,14 @@ + + + + + + + + diff --git a/iphone/Maps/UI/Storyboard/Storyboard.swift b/iphone/Maps/UI/Storyboard/Storyboard.swift index bbecdf2485..07ca84ea15 100644 --- a/iphone/Maps/UI/Storyboard/Storyboard.swift +++ b/iphone/Maps/UI/Storyboard/Storyboard.swift @@ -2,7 +2,6 @@ import UIKit @objc(MWMStoryboard) enum Storyboard: Int { - case authorization case launchScreen case main @@ -11,6 +10,7 @@ enum Storyboard: Int { case welcome case sharing case categorySettings + case drivingOptions } extension UIStoryboard { @@ -25,6 +25,7 @@ extension UIStoryboard { case .welcome: name = "Welcome" case .sharing: name = "BookmarksSharingFlow" case .categorySettings: name = "CategorySettings" + case .drivingOptions: name = "DrivingOptions" } return UIStoryboard(name: name, bundle: nil) } diff --git a/map/routing_manager.hpp b/map/routing_manager.hpp index 15ddc06558..20c4f543cd 100644 --- a/map/routing_manager.hpp +++ b/map/routing_manager.hpp @@ -131,6 +131,7 @@ public: bool IsRouteFinished() const { return m_routingSession.IsFinished(); } bool IsOnRoute() const { return m_routingSession.IsOnRoute(); } bool IsRoutingFollowing() const { return m_routingSession.IsFollowing(); } + bool IsRouteValid() const { return m_routingSession.IsRouteValid(); } void BuildRoute(uint32_t timeoutSec); void SetUserCurrentPosition(m2::PointD const & position); void ResetRoutingSession() { m_routingSession.Reset(); }