Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Grechuhin <i.grechuhin@mapswithme.com>2015-05-29 15:28:16 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:49:21 +0300
commitcf600dfd9bdbd3dcb226972540d6492bda45b32d (patch)
tree19016aee2b9690d4f5b1edfe37dc0f173a8d965b
parentdabc7d0665015ce1aa50e867e2874a6f47080f88 (diff)
[ios] Move zoom buttons.
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h9
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm17
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMMapViewControlsCommon.h1
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.h2
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.mm10
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.h3
-rw-r--r--iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.m65
-rw-r--r--iphone/Maps/Classes/MapViewController.mm16
-rw-r--r--iphone/Maps/Classes/PlacePageView.h2
-rw-r--r--iphone/Maps/Classes/PlacePageView.mm1
-rw-r--r--iphone/Maps/Classes/RouteView.h2
-rw-r--r--iphone/Maps/Classes/RouteView.m1
12 files changed, 122 insertions, 7 deletions
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h
index e35f0341de..f27034ef0d 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h
@@ -8,6 +8,13 @@
#import <Foundation/Foundation.h>
+typedef NS_ENUM(NSUInteger, MWMMapViewControlsButton)
+{
+ MWMMapViewControlsButtonZoom,
+ MWMMapViewControlsButtonMenu,
+ MWMMapViewControlsButtonLocation
+};
+
@class MapViewController;
@interface MWMMapViewControlsManager : NSObject
@@ -19,5 +26,7 @@
- (instancetype)initWithParentController:(MapViewController *)controller;
- (void)resetZoomButtonsVisibility;
+- (void)moveButton:(MWMMapViewControlsButton)button toDefaultPosition:(BOOL)defaultPosition;
+- (void)setBottomBound:(CGFloat)bound;
@end
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm
index 68593894fe..a328c92b0e 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm
@@ -42,6 +42,23 @@
[self.zoomButtons resetVisibility];
}
+- (void)moveButton:(MWMMapViewControlsButton)button toDefaultPosition:(BOOL)defaultPosition
+{
+ switch (button)
+ {
+ case MWMMapViewControlsButtonZoom:
+ [self.zoomButtons moveToDefaultPosition:defaultPosition];
+ break;
+ default:
+ break;
+ }
+}
+
+- (void)setBottomBound:(CGFloat)bound
+{
+ [self.zoomButtons setBottomBound:bound];
+}
+
#pragma mark - Properties
- (void)setHidden:(BOOL)hidden
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMMapViewControlsCommon.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMMapViewControlsCommon.h
index 7f815a2fcb..fdd7e88b5a 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMMapViewControlsCommon.h
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMMapViewControlsCommon.h
@@ -7,6 +7,7 @@
//
static NSTimeInterval const kMenuViewHideFramesCount = 7.0;
+static NSTimeInterval const kMenuViewMoveFramesCount = 7.0;
static inline NSTimeInterval framesDuration(NSTimeInterval const framesCount)
{
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.h b/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.h
index 403ae6cc94..cd76bae868 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.h
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.h
@@ -14,5 +14,7 @@
- (instancetype)initWithParentView:(UIView *)view;
- (void)resetVisibility;
+- (void)moveToDefaultPosition:(BOOL)defaultPosition;
+- (void)setBottomBound:(CGFloat)bound;
@end
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.mm
index 68af4fe817..86b6386b34 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.mm
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtons.mm
@@ -51,6 +51,16 @@ extern NSString * const kAlohalyticsTapEventKey;
self.zoomView.hidden = !zoomButtonsEnabled;
}
+- (void)moveToDefaultPosition:(BOOL)defaultPosition
+{
+ self.zoomView.defaultPosition = defaultPosition;
+}
+
+- (void)setBottomBound:(CGFloat)bound
+{
+ self.zoomView.bottomBound = bound;
+}
+
- (void)zoom:(CGFloat)scale
{
GetFramework().Scale(scale);
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.h b/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.h
index 283313a2be..50e9b20899 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.h
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.h
@@ -10,6 +10,9 @@
@interface MWMZoomButtonsView : UIView
+@property (nonatomic) BOOL defaultPosition;
+@property (nonatomic) CGFloat bottomBound;
+
- (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available")));
- (instancetype)init __attribute__((unavailable("init is not available")));
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.m b/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.m
index bca3ddfb24..9f481c8bb3 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.m
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/ZoomButtons/MWMZoomButtonsView.m
@@ -10,8 +10,11 @@
#import "MWMMapViewControlsCommon.h"
#import "UIKitCategories.h"
-static CGFloat const kZoomViewOffsetToTopBound = 12.0;
-static CGFloat const kZoomViewOffsetToBottomBound = 294.0;
+static CGFloat const kZoomViewOffsetToTopBoundDefault = 12.0;
+static CGFloat const kZoomViewOffsetToTopBoundMoved = 66.0;
+static CGFloat const kZoomViewOffsetToBottomBound = 40.0;
+static CGFloat const kZoomViewOffsetToFrameBound = 294.0;
+static CGFloat const kZoomViewHideBoundPercent = 0.4;
@interface MWMZoomButtonsView()
@@ -28,6 +31,8 @@ static CGFloat const kZoomViewOffsetToBottomBound = 294.0;
{
self.defaultBounds = self.bounds;
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ self.defaultPosition = YES;
+ self.bottomBound = 0.0;
}
return self;
}
@@ -37,8 +42,7 @@ static CGFloat const kZoomViewOffsetToBottomBound = 294.0;
[super layoutSubviews];
self.bounds = self.defaultBounds;
[self layoutXPosition:self.hidden];
- self.maxY = self.superview.height - kZoomViewOffsetToBottomBound;
- self.minY = MAX(self.minY, kZoomViewOffsetToTopBound);
+ [self layoutYPosition:self.defaultPosition];
}
- (void)layoutXPosition:(BOOL)hidden
@@ -49,10 +53,37 @@ static CGFloat const kZoomViewOffsetToBottomBound = 294.0;
self.maxX = self.superview.width - kViewControlsOffsetToBounds;
}
+- (void)layoutYPosition:(BOOL)defaultPosition
+{
+ if (self.bottomBound > 0.0)
+ self.maxY = self.bottomBound - kZoomViewOffsetToBottomBound;
+ else
+ self.maxY = self.superview.height - kZoomViewOffsetToFrameBound;
+ self.minY = MAX(self.minY, defaultPosition ? kZoomViewOffsetToTopBoundDefault : kZoomViewOffsetToTopBoundMoved);
+}
+
+- (void)moveAnimated
+{
+ [UIView animateWithDuration:framesDuration(kMenuViewMoveFramesCount) animations:^
+ {
+ [self layoutYPosition:self.defaultPosition];
+ }];
+}
+
+- (void)fadeAnimatedIn:(BOOL)show
+{
+ [UIView animateWithDuration:framesDuration(kMenuViewHideFramesCount) animations:^
+ {
+ self.alpha = show ? 1.0 : 0.0;
+ }];
+}
+
#pragma mark - Properties
- (void)setHidden:(BOOL)hidden
{
+ if (super.hidden == hidden)
+ return;
if (!hidden)
super.hidden = NO;
[self layoutXPosition:!hidden];
@@ -67,4 +98,30 @@ static CGFloat const kZoomViewOffsetToBottomBound = 294.0;
}];
}
+- (void)setDefaultPosition:(BOOL)defaultPosition
+{
+ _defaultPosition = defaultPosition;
+ [self moveAnimated];
+}
+
+- (void)setBottomBound:(CGFloat)bottomBound
+{
+ CGFloat const hideBound = kZoomViewHideBoundPercent * self.superview.height;
+ BOOL const isHidden = _bottomBound < hideBound;
+ BOOL const willHide = bottomBound < hideBound;
+ _bottomBound = bottomBound;
+
+ if (willHide)
+ {
+ if (!isHidden)
+ [self fadeAnimatedIn:NO];
+ }
+ else
+ {
+ [self moveAnimated];
+ if (isHidden)
+ [self fadeAnimatedIn:YES];
+ }
+}
+
@end
diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm
index 4ad9df99be..59e5759e39 100644
--- a/iphone/Maps/Classes/MapViewController.mm
+++ b/iphone/Maps/Classes/MapViewController.mm
@@ -560,15 +560,15 @@ extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
[super viewDidLoad];
self.view.clipsToBounds = YES;
-
- self.controlsManager = [[MWMMapViewControlsManager alloc] initWithParentController:self];
[self.view addSubview:self.routeViewWrapper];
[self.view addSubview:self.searchView];
[self.view addSubview:self.containerView];
-
+
+ self.controlsManager = [[MWMMapViewControlsManager alloc] initWithParentController:self];
+
[self showRoutingFeatureDialog];
}
@@ -914,6 +914,11 @@ extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
[self dismissRouting];
}
+- (void)routeViewWillEnterState:(RouteViewState)state
+{
+ [self.controlsManager moveButton:MWMMapViewControlsButtonZoom toDefaultPosition:(state == RouteViewStateHidden)];
+}
+
- (void)dismissRouting
{
GetFramework().CloseRouting();
@@ -990,6 +995,11 @@ extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}
+- (void)placePageViewWillEnterState:(PlacePageState)state
+{
+ [self.controlsManager moveButton:MWMMapViewControlsButtonZoom toDefaultPosition:(state == PlacePageStateHidden)];
+}
+
#pragma mark - UIKitViews delegates
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
diff --git a/iphone/Maps/Classes/PlacePageView.h b/iphone/Maps/Classes/PlacePageView.h
index 495aafb6de..536aa16138 100644
--- a/iphone/Maps/Classes/PlacePageView.h
+++ b/iphone/Maps/Classes/PlacePageView.h
@@ -21,6 +21,8 @@ typedef NS_ENUM(NSUInteger, PlacePageState) {
- (void)placePageViewDidStartRouting:(PlacePageView *)placePage;
+- (void)placePageViewWillEnterState:(PlacePageState)state;
+
@end
diff --git a/iphone/Maps/Classes/PlacePageView.mm b/iphone/Maps/Classes/PlacePageView.mm
index 76294e0232..89e4e34dad 100644
--- a/iphone/Maps/Classes/PlacePageView.mm
+++ b/iphone/Maps/Classes/PlacePageView.mm
@@ -424,6 +424,7 @@ typedef NS_ENUM(NSUInteger, CellRow)
- (void)applyState:(PlacePageState)state animated:(BOOL)animated
{
+ [self.delegate placePageViewWillEnterState:state];
_state = state;
[self updateBookmarkStateAnimated:NO];
[self updateBookmarkViewsAlpha:animated];
diff --git a/iphone/Maps/Classes/RouteView.h b/iphone/Maps/Classes/RouteView.h
index a87549e287..ff7dae982c 100644
--- a/iphone/Maps/Classes/RouteView.h
+++ b/iphone/Maps/Classes/RouteView.h
@@ -14,6 +14,8 @@ typedef NS_ENUM(NSUInteger, RouteViewState) {
- (void)routeViewDidCancelRouting:(RouteView *)routeView;
- (void)routeViewDidStartFollowing:(RouteView *)routeView;
+- (void)routeViewWillEnterState:(RouteViewState)state;
+
@end
@interface RouteView : UIView
diff --git a/iphone/Maps/Classes/RouteView.m b/iphone/Maps/Classes/RouteView.m
index 93f064e756..94f10d34d4 100644
--- a/iphone/Maps/Classes/RouteView.m
+++ b/iphone/Maps/Classes/RouteView.m
@@ -151,6 +151,7 @@ extern NSString * const kAlohalyticsTapEventKey;
- (void)setState:(RouteViewState)state animated:(BOOL)animated
{
+ [self.delegate routeViewWillEnterState:state];
_state = state;
[UIView animateWithDuration:(animated ? 0.5 : 0) delay:0 damping:0.83 initialVelocity:0 options:UIViewAnimationOptionCurveEaseInOut animations:^ {