diff options
author | v.mikhaylenko <v.mikhaylenko@corp.mail.ru> | 2015-06-23 19:19:54 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:52:50 +0300 |
commit | 9c67fe2ea742d0c17f3288c987da9ee46f4881db (patch) | |
tree | 9d42c0a2952e8be9b6e6e5af850cc8a4efef6134 /iphone/Maps/Classes/MWMiPadPlacePage.mm | |
parent | b54c8ccacbf77edf4b9d3db59ce18866a2dfeda7 (diff) |
[ios] Added swipe and shadow to iPad place page.
Diffstat (limited to 'iphone/Maps/Classes/MWMiPadPlacePage.mm')
-rw-r--r-- | iphone/Maps/Classes/MWMiPadPlacePage.mm | 54 |
1 files changed, 54 insertions, 0 deletions
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 |