From 9c67fe2ea742d0c17f3288c987da9ee46f4881db Mon Sep 17 00:00:00 2001 From: "v.mikhaylenko" Date: Tue, 23 Jun 2015 19:19:54 +0300 Subject: [PATCH] [ios] Added swipe and shadow to iPad place page. --- iphone/Maps/Classes/MWMiPadPlacePage.mm | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/iphone/Maps/Classes/MWMiPadPlacePage.mm b/iphone/Maps/Classes/MWMiPadPlacePage.mm index 4159164d07..3d14f5f43f 100644 --- a/iphone/Maps/Classes/MWMiPadPlacePage.mm +++ b/iphone/Maps/Classes/MWMiPadPlacePage.mm @@ -77,6 +77,7 @@ static CGFloat const kTopOffset = 36.; [self.navigationController.view removeFromSuperview]; [self.navigationController removeFromParentViewController]; self.navigationController = [[MWMiPadNavigationController alloc] initWithRootViewController:self.viewController]; + [self configureShadow]; CGFloat const defaultWidth = 360.; CGFloat const actionBarHeight = 58.; @@ -95,6 +96,17 @@ static CGFloat const kTopOffset = 36.; [view addSubview:self.navigationController.view]; } +- (void)configureShadow +{ + CALayer * layer = self.navigationController.view.layer; + layer.masksToBounds = NO; + layer.shadowColor = UIColor.blackColor.CGColor; + layer.shadowRadius = 4.; + layer.shadowOpacity = 0.24f; + layer.shadowOffset = CGSizeMake(0., - 2.); + layer.shouldRasterize = YES; +} + - (void)show { [UIView animateWithDuration:0.2f animations:^ @@ -168,4 +180,46 @@ static CGFloat const kTopOffset = 36.; [self.viewController.navigationController pushViewController:controller animated:YES]; } +- (IBAction)didPan:(UIPanGestureRecognizer *)sender +{ + UIView * navigationControllerView = self.navigationController.view; + UIView * superview = navigationControllerView.superview; + + navigationControllerView.minX += [sender translationInView:superview].x; + navigationControllerView.minX = MIN(navigationControllerView.minX, kLeftOffset); + [sender setTranslation:CGPointZero inView:superview]; + navigationControllerView.alpha = self.currentAlpha; + UIGestureRecognizerState const state = sender.state; + if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled) + { + if (navigationControllerView.minX < ( - navigationControllerView.width / 8.)) + { + [UIView animateWithDuration:0.2f animations:^ + { + navigationControllerView.minX = - kLeftOffset - navigationControllerView.width; + navigationControllerView.alpha = self.currentAlpha; + } + completion:^(BOOL finished) + { + [self.manager dismissPlacePage]; + }]; + } + else + { + [UIView animateWithDuration:0.2f animations:^ + { + navigationControllerView.minX = kLeftOffset; + navigationControllerView.alpha = self.currentAlpha; + }]; + } + } +} + +- (CGFloat)currentAlpha +{ + UIView * view = self.navigationController.view; + CGFloat const maxX = MAX(0., view.maxX); + return maxX / (view.width + kLeftOffset); +} + @end