diff options
Diffstat (limited to 'iphone/Maps/Classes/CustomViews/MapViewControls')
8 files changed, 90 insertions, 49 deletions
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMMapViewControlsCommon.h b/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMMapViewControlsCommon.h index 9c35e8556d..e3e3da85b3 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMMapViewControlsCommon.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMMapViewControlsCommon.h @@ -1,5 +1,4 @@ -static NSTimeInterval const kMenuViewHideFramesCount = 7.0; -static NSTimeInterval const kMenuViewMoveFramesCount = 7.0; +static NSTimeInterval const kMenuViewHideFramesCount = 4.0; static inline NSTimeInterval framesDuration(NSTimeInterval const framesCount) { diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h index d0c8aaffb7..e00eb59b85 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h @@ -12,6 +12,7 @@ @property (nonatomic) BOOL hidden; @property (nonatomic) BOOL zoomHidden; +@property (nonatomic) BOOL sideButtonsHidden; @property (nonatomic) MWMBottomMenuState menuState; @property (nonatomic, readonly) MWMNavigationDashboardState navigationState; @property (nonatomic, readonly) MWMPlacePageEntity * placePageEntity; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 53e3866dca..098b7b3b53 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -75,7 +75,7 @@ extern NSString * const kAlohalyticsTapEventKey; self.navigationManager = [[MWMNavigationDashboardManager alloc] initWithParentView:controller.view delegate:self]; self.searchManager = [[MWMSearchManager alloc] initWithParentView:controller.view delegate:self]; self.hidden = NO; - self.zoomHidden = NO; + self.sideButtonsHidden = NO; self.menuState = MWMBottomMenuStateInactive; [self configRoutePoints]; [MWMFrameworkListener addObserver:self]; @@ -587,7 +587,7 @@ extern NSString * const kAlohalyticsTapEventKey; return NO; } self.hidden = NO; - self.zoomHidden = NO; + self.sideButtonsHidden = NO; GetFramework().FollowRoute(); self.disableStandbyOnRouteFollowing = YES; [self.menuController setStreetName:@""]; @@ -714,7 +714,7 @@ extern NSString * const kAlohalyticsTapEventKey; if (_hidden == hidden) return; _hidden = hidden; - self.zoomHidden = _zoomHidden; + self.sideButtonsHidden = _sideButtonsHidden; self.menuState = _menuState; EAGLView * glView = (EAGLView *)self.ownerController.view; glView.widgetsManager.fullScreen = hidden; @@ -723,7 +723,13 @@ extern NSString * const kAlohalyticsTapEventKey; - (void)setZoomHidden:(BOOL)zoomHidden { _zoomHidden = zoomHidden; - self.sideButtons.hidden = self.hidden || zoomHidden; + self.sideButtons.zoomHidden = zoomHidden; +} + +- (void)setSideButtonsHidden:(BOOL)sideButtonsHidden +{ + _sideButtonsHidden = sideButtonsHidden; + self.sideButtons.hidden = self.hidden || sideButtonsHidden; } - (void)setMenuState:(MWMBottomMenuState)menuState diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h index a91ef52126..7ea4c78dc1 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h @@ -4,6 +4,7 @@ @interface MWMSideButtons : NSObject +@property (nonatomic) BOOL zoomHidden; @property (nonatomic) BOOL hidden; - (instancetype)init __attribute__((unavailable("init is not available"))); diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm index 5267a2642a..f81bc1a559 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm @@ -223,17 +223,24 @@ NSArray<UIImage *> * animationImages(NSString * animationTemplate, NSUInteger im return zoomButtonsEnabled; } +- (BOOL)zoomHidden +{ + return self.sideView.zoomHidden; +} + +- (void)setZoomHidden:(BOOL)zoomHidden +{ + self.sideView.zoomHidden = [self isZoomEnabled] ? zoomHidden : YES; +} + - (BOOL)hidden { - return self.isZoomEnabled ? self.sideView.hidden : YES; + return self.sideView.hidden; } - (void)setHidden:(BOOL)hidden { - if (self.isZoomEnabled) - [self.sideView setHidden:hidden animated:YES]; - else - self.sideView.hidden = YES; + [self.sideView setHidden:hidden animated:YES]; } @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.h index 9123d6c841..3364afbabd 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.h @@ -3,6 +3,8 @@ @property (nonatomic) CGFloat topBound; @property (nonatomic) CGFloat bottomBound; +@property (nonatomic) BOOL zoomHidden; + - (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/SideButtons/MWMSideButtonsView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm index 016dd57122..e66e339dd8 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm @@ -1,19 +1,33 @@ #import "Common.h" -#import "MWMSideButtonsView.h" +#import "MWMButton.h" #import "MWMMapViewControlsCommon.h" +#import "MWMSideButtonsView.h" namespace { - CGFloat const kZoomViewOffsetToTopBound = 12.0; - CGFloat const kZoomViewOffsetToBottomBound = 40.0; - CGFloat const kZoomViewOffsetToFrameBound = 294.0; - CGFloat const kZoomViewHideBoundPercent = 0.4; + CGFloat bottomBoundLimit(BOOL isPortrait) + { + if (IPAD) + return isPortrait ? 320.0 : 240.0; + else + return isPortrait ? 180.0 : 60.0; + } + + CGFloat zoom2LayoutOffset(BOOL isPortrait) + { + return IPAD || isPortrait ? 52.0 : 30; + } } // namespace @interface MWMSideButtonsView() @property (nonatomic) CGRect defaultBounds; -@property (nonatomic) BOOL show; + +@property (weak, nonatomic) IBOutlet MWMButton * zoomIn; +@property (weak, nonatomic) IBOutlet MWMButton * zoomOut; +@property (weak, nonatomic) IBOutlet MWMButton * location; + +@property (nonatomic) BOOL isPortrait; @end @@ -27,7 +41,18 @@ namespace - (void)layoutSubviews { + BOOL const isPortrait = self.superview.width < self.superview.height; + if (self.isPortrait != isPortrait && self.superview) + { + self.isPortrait = isPortrait; + self.bottomBound = self.superview.height; + self.location.minY = self.zoomOut.maxY + zoom2LayoutOffset(isPortrait); + CGSize size = self.defaultBounds.size; + size.height = self.location.maxY; + self.defaultBounds.size = size; + } self.bounds = self.defaultBounds; + [self layoutXPosition:self.hidden]; [self layoutYPosition]; [super layoutSubviews]; @@ -43,42 +68,46 @@ namespace - (void)layoutYPosition { - CGFloat const maxY = MIN(self.superview.height - kZoomViewOffsetToFrameBound, self.bottomBound - kZoomViewOffsetToBottomBound); - self.minY = MAX(maxY - self.height, self.topBound + kZoomViewOffsetToTopBound); + self.maxY = self.bottomBound; } -- (void)moveAnimated +- (void)fadeZoomButtonsShow:(BOOL)show { - if (self.hidden) - return; - [UIView animateWithDuration:framesDuration(kMenuViewMoveFramesCount) animations:^{ [self layoutYPosition]; }]; -} - -- (void)fadeAnimated -{ - [UIView animateWithDuration:framesDuration(kMenuViewHideFramesCount) animations:^{ self.alpha = self.show ? 1.0 : 0.0; }]; + CGFloat const alpha = show ? 1.0 : 0.0; + [UIView animateWithDuration:framesDuration(kMenuViewHideFramesCount) animations:^ + { + self.zoomIn.alpha = alpha; + self.zoomOut.alpha = alpha; + }]; } - (void)animate { - CGFloat const hideBound = kZoomViewHideBoundPercent * self.superview.height; - BOOL const isHidden = self.alpha == 0.0; - BOOL const willHide = (self.bottomBound < hideBound) || (self.defaultBounds.size.height > self.bottomBound - self.topBound); - if (willHide) + [self layoutYPosition]; + BOOL const isZoomHidden = self.zoomIn.alpha == 0.0; + BOOL const willZoomHide = (self.defaultBounds.size.height > self.bottomBound - self.topBound); + if (willZoomHide) { - if (!isHidden) - self.show = NO; + if (!isZoomHidden) + [self fadeZoomButtonsShow:NO]; } else { - [self moveAnimated]; - if (isHidden) - self.show = YES; + if (isZoomHidden) + [self fadeZoomButtonsShow:YES]; } } #pragma mark - Properties +- (void)setZoomHidden:(BOOL)zoomHidden +{ + _zoomHidden = zoomHidden; + CGFloat const minX = zoomHidden ? self.width + kViewControlsOffsetToBounds : 0.0; + self.zoomIn.minX = minX; + self.zoomOut.minX = minX; +} + - (void)setHidden:(BOOL)hidden animated:(BOOL)animated { if (animated) @@ -134,14 +163,7 @@ namespace if (!self.superview) return _bottomBound; BOOL const isPortrait = self.superview.width < self.superview.height; - CGFloat limit = IPAD ? 320.0 : isPortrait ? 150.0 : 80.0; - return MIN(self.superview.height - limit, _bottomBound); -} - -- (void)setShow:(BOOL)show -{ - _show = show; - [self fadeAnimated]; + return MIN(self.superview.height - bottomBoundLimit(isPortrait), _bottomBound); } @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.xib b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.xib index a4d4a3e659..a71ea0217a 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.xib +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.xib @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none"> <dependencies> <deployment identifier="iOS"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> @@ -14,7 +14,7 @@ </connections> </placeholder> <view contentMode="scaleToFill" id="ek2-ZW-pCm" customClass="MWMSideButtonsView"> - <rect key="frame" x="0.0" y="0.0" width="56" height="174"/> + <rect key="frame" x="0.0" y="0.0" width="56" height="228"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <subviews> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="NO3-Xl-Oka" userLabel="ZoomIn" customClass="MWMButton"> @@ -33,7 +33,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="hwn-8L-cFX" userLabel="ZoomOut" customClass="MWMButton"> - <rect key="frame" x="0.0" y="60" width="56" height="56"/> + <rect key="frame" x="0.0" y="64" width="56" height="56"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <state key="normal" image="btn_zoom_out_light"> <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> @@ -48,7 +48,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="fUK-2V-4ya" userLabel="Location" customClass="MWMButton"> - <rect key="frame" x="0.0" y="118" width="56" height="56"/> + <rect key="frame" x="0.0" y="172" width="56" height="56"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <state key="normal" image="btn_get_position_light"> <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/> @@ -65,6 +65,9 @@ <nil key="simulatedBottomBarMetrics"/> <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> <connections> + <outlet property="location" destination="fUK-2V-4ya" id="lgn-MB-VVy"/> + <outlet property="zoomIn" destination="NO3-Xl-Oka" id="1sc-ei-oRj"/> + <outlet property="zoomOut" destination="hwn-8L-cFX" id="htY-bc-Ugh"/> <outletCollection property="gestureRecognizers" destination="6qU-Ff-Ae5" appends="YES" id="jeT-Jr-P7T"/> </connections> <point key="canvasLocation" x="165" y="-6"/> |