From eecf3aadc92278941df2293858bcc6d205d53f18 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Mon, 18 Jul 2016 15:07:41 +0300 Subject: [PATCH] [ios] Added diminish routing state on timer. --- .../BottomMenu/MWMBottomMenuViewController.mm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm index 07a9a53cf8..e8f40d487c 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm @@ -37,9 +37,10 @@ namespace { NSString * const kCollectionCellPortrait = @"MWMBottomMenuCollectionViewPortraitCell"; NSString * const kCollectionCelllandscape = @"MWMBottomMenuCollectionViewLandscapeCell"; -} // namespace -static CGFloat const kLayoutThreshold = 420.0; +CGFloat constexpr kLayoutThreshold = 420.0; +NSTimeInterval constexpr kRoutingDiminishInterval = 5.0; +} // namespace typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) { MWMBottomMenuViewCellAddPlace, @@ -526,6 +527,17 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) { }]; } +- (void)refreshRoutingDiminishTimer +{ + SEL const diminishFunction = @selector(diminishRoutingState); + [NSObject cancelPreviousPerformRequestsWithTarget:self selector:diminishFunction object:self]; + runAsyncOnMainQueue(^{ + if (self.state == MWMBottomMenuStateRoutingExpanded) + [self performSelector:diminishFunction withObject:self afterDelay:kRoutingDiminishInterval]; + }); +} + +- (void)diminishRoutingState { self.state = MWMBottomMenuStateRouting; } #pragma mark - Properties - (SolidTouchView *)dimBackground @@ -545,6 +557,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) { - (void)setState:(MWMBottomMenuState)state { + [self refreshRoutingDiminishTimer]; MWMBottomMenuView * view = (MWMBottomMenuView *)self.view; BOOL const menuActive = (state == MWMBottomMenuStateActive || state == MWMBottomMenuStateRoutingExpanded);