diff --git a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.h b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.h index 6723839c1e..3266db43e7 100644 --- a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.h +++ b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.h @@ -12,9 +12,14 @@ @property (nonatomic) CGFloat progress; @property (nonatomic) BOOL failed; +@property (nonatomic) BOOL selected; + +- (void)setImage:(nullable UIImage *)image forState:(UIControlState)state; - (nonnull instancetype)init __attribute__((unavailable("init is not available"))); - (nonnull instancetype)initWithParentView:(nonnull UIView *)parentView delegate:(nonnull id )delegate; - (void)reset; +- (void)startSpinner; +- (void)stopSpinner; @end diff --git a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.mm b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.mm index f7a494a831..89c0ba1acf 100644 --- a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.mm +++ b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.mm @@ -33,6 +33,23 @@ self.nextProgressToAnimate = nil; } +- (void)setImage:(nullable UIImage *)image forState:(UIControlState)state +{ + [self.button setImage:image forState:state]; +} + +#pragma mark - Spinner + +- (void)startSpinner +{ + [self.rootView startSpinner]; +} + +- (void)stopSpinner +{ + [self.rootView stopSpinner]; +} + #pragma mark - Animation - (void)animationDidStop:(CABasicAnimation *)anim finished:(BOOL)flag @@ -80,4 +97,14 @@ return self.button.selected; } +- (void)setSelected:(BOOL)selected +{ + self.button.selected = selected; +} + +- (BOOL)selected +{ + return self.button.selected; +} + @end diff --git a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.xib b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.xib index 496a55a305..cc32fb0a7b 100644 --- a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.xib +++ b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgress.xib @@ -1,8 +1,8 @@ - + - + @@ -18,6 +18,7 @@ + + + + + + + diff --git a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgressView.h b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgressView.h index 232e6933f3..ac228477b1 100644 --- a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgressView.h +++ b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgressView.h @@ -11,5 +11,7 @@ - (void)refreshProgress; - (void)updatePath:(CGFloat)progress; +- (void)startSpinner; +- (void)stopSpinner; @end diff --git a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgressView.mm b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgressView.mm index fa8989b56d..339a9b58a7 100644 --- a/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgressView.mm +++ b/iphone/Maps/Classes/CustomViews/CircularProgress/MWMCircularProgressView.mm @@ -16,6 +16,7 @@ static inline CGFloat angleWithProgress(CGFloat progress) @property (nonatomic) CAShapeLayer * progressLayer; @property (weak, nonatomic) IBOutlet MWMCircularProgress * owner; +@property (weak, nonatomic) IBOutlet UIImageView * spinner; @end @@ -50,6 +51,8 @@ static inline CGFloat angleWithProgress(CGFloat progress) - (void)updatePath:(CGFloat)progress { + if (progress > 0.0) + [self stopSpinner]; CGFloat const outerRadius = self.width / 2.0; CGPoint const center = CGPointMake(outerRadius, outerRadius); CGFloat const radius = outerRadius - kLineWidth; @@ -57,6 +60,32 @@ static inline CGFloat angleWithProgress(CGFloat progress) self.progressLayer.path = path.CGPath; } +#pragma mark - Spinner + +- (void)startSpinner +{ + if (!self.spinner.hidden) + return; + self.backgroundLayer.hidden = self.progressLayer.hidden = YES; + self.spinner.hidden = NO; + NSUInteger const animationImagesCount = 12; + NSMutableArray * animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount]; + for (NSUInteger i = 0; i < animationImagesCount; ++i) + animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@", @(i+1)]]; + + self.spinner.animationImages = animationImages; + [self.spinner startAnimating]; +} + +- (void)stopSpinner +{ + if (self.spinner.hidden) + return; + self.backgroundLayer.hidden = self.progressLayer.hidden = NO; + self.spinner.hidden = YES; + [self.spinner.layer removeAllAnimations]; +} + #pragma mark - Animation - (void)animateFromValue:(CGFloat)fromValue toValue:(CGFloat)toValue diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm index 77c0305e93..f7de5bc11b 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm @@ -224,29 +224,29 @@ - (IBAction)routePreviewChange:(MWMRouteTypeButton *)sender { - if (sender.selected) - return; - sender.selected = YES; - self.activeRouteTypeButton = sender; - auto & f = GetFramework(); - routing::RouterType type; - if ([sender isEqual:self.routePreview.pedestrian]) - { - self.routePreview.vehicle.selected = NO; - type = routing::RouterType::Pedestrian; - } - else - { - self.routePreview.pedestrian.selected = NO; - type = routing::RouterType::Vehicle; - } - f.CloseRouting(); - f.SetRouter(type); - f.SetLastUsedRouter(type); - if (!self.delegate.isPossibleToBuildRoute) - return; - [sender startAnimating]; - [self.delegate buildRoute]; +// if (sender.selected) +// return; +// sender.selected = YES; +// self.activeRouteTypeButton = sender; +// auto & f = GetFramework(); +// routing::RouterType type; +// if ([sender isEqual:self.routePreview.pedestrian]) +// { +// self.routePreview.vehicle.selected = NO; +// type = routing::RouterType::Pedestrian; +// } +// else +// { +// self.routePreview.pedestrian.selected = NO; +// type = routing::RouterType::Vehicle; +// } +// f.CloseRouting(); +// f.SetRouter(type); +// f.SetLastUsedRouter(type); +// if (!self.delegate.isPossibleToBuildRoute) +// return; +// [sender startAnimating]; +// [self.delegate buildRoute]; } - (void)setRouteBuildingProgress:(CGFloat)progress @@ -324,19 +324,19 @@ - (void)setupActualRoute { - switch (GetFramework().GetRouter()) - { - case routing::RouterType::Pedestrian: - self.routePreview.pedestrian.selected = YES; - self.routePreview.vehicle.selected = NO; - self.activeRouteTypeButton = self.routePreview.pedestrian; - break; - case routing::RouterType::Vehicle: - self.routePreview.vehicle.selected = YES; - self.routePreview.pedestrian.selected = NO; - self.activeRouteTypeButton = self.routePreview.vehicle; - break; - } +// switch (GetFramework().GetRouter()) +// { +// case routing::RouterType::Pedestrian: +// self.routePreview.pedestrian.selected = YES; +// self.routePreview.vehicle.selected = NO; +// self.activeRouteTypeButton = self.routePreview.pedestrian; +// break; +// case routing::RouterType::Vehicle: +// self.routePreview.vehicle.selected = YES; +// self.routePreview.pedestrian.selected = NO; +// self.activeRouteTypeButton = self.routePreview.vehicle; +// break; +// } } #pragma mark - Properties diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h index 149a061e3e..e401706494 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.h @@ -14,8 +14,6 @@ @interface MWMRoutePreview : MWMNavigationView -@property (weak, nonatomic) IBOutlet MWMRouteTypeButton * pedestrian; -@property (weak, nonatomic) IBOutlet MWMRouteTypeButton * vehicle; @property (weak, nonatomic, readonly) IBOutlet UIButton * extendButton; @property (weak, nonatomic) id dataSource; @property (weak, nonatomic) MWMNavigationDashboardManager * dashboardManager; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm index a21767fbcc..b631b7353b 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.mm @@ -1,4 +1,5 @@ #import "Common.h" +#import "MWMCircularProgress.h" #import "MWMNavigationDashboardEntity.h" #import "MWMNavigationDashboardManager.h" #import "MWMRoutePointCell.h" @@ -14,8 +15,10 @@ static NSDictionary * const kEtaAttributes = @{NSForegroundColorAttributeName : static CGFloat const kBottomPanelHeight = 48.; static CGFloat const kAdditionalHeight = 20.; -@interface MWMRoutePreview () +@interface MWMRoutePreview () +@property (weak, nonatomic) IBOutlet UIView * pedestrian; +@property (weak, nonatomic) IBOutlet UIView * vehicle; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * planningRouteViewHeight; @property (weak, nonatomic, readwrite) IBOutlet UIButton * extendButton; @property (weak, nonatomic) IBOutlet UIButton * goButton; @@ -32,6 +35,9 @@ static CGFloat const kAdditionalHeight = 20.; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * statusBoxHeight; @property (nonatomic) UIImageView * movingCellImage; +@property (nonatomic) MWMCircularProgress * pedestrianProgressView; +@property (nonatomic) MWMCircularProgress * vehicleProgressView; + @end @implementation MWMRoutePreview @@ -44,6 +50,15 @@ static CGFloat const kAdditionalHeight = 20.; self.layer.rasterizationScale = UIScreen.mainScreen.scale; [self.collectionView registerNib:[UINib nibWithNibName:[MWMRoutePointCell className] bundle:nil] forCellWithReuseIdentifier:[MWMRoutePointCell className]]; + + self.pedestrianProgressView = [[MWMCircularProgress alloc] initWithParentView:self.pedestrian delegate:self]; + [self.pedestrianProgressView setImage:[UIImage imageNamed:@"ic_drive_off"] forState:UIControlStateNormal]; + [self.pedestrianProgressView setImage:[UIImage imageNamed:@"ic_drive_press"] forState:UIControlStateHighlighted]; + [self.pedestrianProgressView setImage:[UIImage imageNamed:@"ic_drive_on"] forState:UIControlStateSelected]; + self.vehicleProgressView = [[MWMCircularProgress alloc] initWithParentView:self.vehicle delegate:self]; + [self.vehicleProgressView setImage:[UIImage imageNamed:@"ic_walk_off"] forState:UIControlStateNormal]; + [self.vehicleProgressView setImage:[UIImage imageNamed:@"ic_walk_press"] forState:UIControlStateHighlighted]; + [self.vehicleProgressView setImage:[UIImage imageNamed:@"ic_walk_on"] forState:UIControlStateSelected]; } - (void)didMoveToSuperview @@ -172,6 +187,12 @@ static CGFloat const kAdditionalHeight = 20.; [self.delegate routePreviewDidChangeFrame:self.frame]; } +#pragma mark - MWMCircularProgressDelegate + +- (void)progressButtonPressed:(nonnull MWMCircularProgress *)progress +{ +} + #pragma mark - Properties - (CGRect)defaultFrame diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.xib b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.xib index 101178df05..bbe43e1bce 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.xib +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMRoutePreview.xib @@ -187,28 +187,18 @@ - + - - - - - - + - - - - - @@ -286,12 +276,6 @@ - - - - - - diff --git a/iphone/Maps/Classes/PlacePageBookmarkCell.xib b/iphone/Maps/Classes/PlacePageBookmarkCell.xib index f33686deda..038992183c 100644 --- a/iphone/Maps/Classes/PlacePageBookmarkCell.xib +++ b/iphone/Maps/Classes/PlacePageBookmarkCell.xib @@ -11,7 +11,7 @@ - +