forked from organicmaps/organicmaps
[ios] Added double tap handling to menu button.
This commit is contained in:
parent
fd38640009
commit
19cf4cdc46
6 changed files with 60 additions and 9 deletions
|
@ -6,12 +6,13 @@
|
|||
// Copyright (c) 2015 MapsWithMe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "MWMSideMenuButtonDelegate.h"
|
||||
#import "MWMSideMenuDelegate.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MWMSideMenuButton : UIButton
|
||||
|
||||
@property (weak, nonatomic) id<MWMSideMenuInformationDisplayProtocol> delegate;
|
||||
@property (weak, nonatomic) id<MWMSideMenuInformationDisplayProtocol, MWMSideMenuTapProtocol> delegate;
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available")));
|
||||
- (instancetype)init __attribute__((unavailable("init is not available")));
|
||||
|
|
|
@ -75,6 +75,32 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)handleSingleTap
|
||||
{
|
||||
[self.delegate handleSingleTap];
|
||||
}
|
||||
|
||||
- (void)handleDoubleTap
|
||||
{
|
||||
[self.delegate handleDoubleTap];
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
UITouch * touch = [touches anyObject];
|
||||
if (touch.tapCount > 1)
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
UITouch * touch = [touches anyObject];
|
||||
if (touch.tapCount == 1)
|
||||
[self performSelector:@selector(handleSingleTap) withObject:nil afterDelay:0.1];
|
||||
else
|
||||
[self handleDoubleTap];
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (void)setHidden:(BOOL)hidden animated:(BOOL)animated
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// MWMSideMenuButtonDelegate.h
|
||||
// Maps
|
||||
//
|
||||
// Created by Ilya Grechuhin on 25.06.15.
|
||||
// Copyright (c) 2015 MapsWithMe. All rights reserved.
|
||||
//
|
||||
|
||||
@protocol MWMSideMenuTapProtocol <NSObject>
|
||||
|
||||
- (void)handleSingleTap;
|
||||
- (void)handleDoubleTap;
|
||||
|
||||
@end
|
|
@ -15,6 +15,7 @@
|
|||
#import "MWMMapViewControlsCommon.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMSideMenuButton.h"
|
||||
#import "MWMSideMenuButtonDelegate.h"
|
||||
#import "MWMSideMenuDelegate.h"
|
||||
#import "MWMSideMenuManager.h"
|
||||
#import "MWMSideMenuView.h"
|
||||
|
@ -29,7 +30,7 @@ static NSString * const kMWMSideMenuViewsNibName = @"MWMSideMenuViews";
|
|||
|
||||
extern NSString * const kAlohalyticsTapEventKey;
|
||||
|
||||
@interface MWMSideMenuManager() <MWMSideMenuInformationDisplayProtocol>
|
||||
@interface MWMSideMenuManager() <MWMSideMenuInformationDisplayProtocol, MWMSideMenuTapProtocol>
|
||||
|
||||
@property (weak, nonatomic) MapViewController * controller;
|
||||
@property (nonatomic) IBOutlet MWMSideMenuButton * menuButton;
|
||||
|
@ -114,7 +115,7 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
[self.controller.searchView setState:SearchViewStateFullscreen animated:YES];
|
||||
}
|
||||
|
||||
- (IBAction)toggleMenu
|
||||
- (void)toggleMenu
|
||||
{
|
||||
if (self.state == MWMSideMenuStateActive)
|
||||
self.state = MWMSideMenuStateInactive;
|
||||
|
@ -122,6 +123,16 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
self.state = MWMSideMenuStateActive;
|
||||
}
|
||||
|
||||
- (void)handleSingleTap
|
||||
{
|
||||
[self toggleMenu];
|
||||
}
|
||||
|
||||
- (void)handleDoubleTap
|
||||
{
|
||||
[self menuActionOpenSearch];
|
||||
}
|
||||
|
||||
#pragma mark - MWMSideMenuInformationDisplayProtocol
|
||||
|
||||
- (void)setRulerPivot:(m2::PointD)pivot
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MWMSideMenuManager">
|
||||
|
@ -213,9 +213,6 @@
|
|||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<state key="highlighted" image="btn_green_menu_pressed"/>
|
||||
<connections>
|
||||
<action selector="toggleMenu" destination="-1" eventType="touchUpInside" id="XvK-dK-beZ"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="48" y="561"/>
|
||||
</button>
|
||||
</objects>
|
||||
|
|
|
@ -392,6 +392,7 @@
|
|||
34BC721E1B0DECAE0012A34B /* MWMZoomButtonsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMZoomButtonsView.h; sourceTree = "<group>"; };
|
||||
34BC721F1B0DECAE0012A34B /* MWMZoomButtonsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMZoomButtonsView.m; sourceTree = "<group>"; };
|
||||
34BC72201B0DECAE0012A34B /* MWMZoomButtonsView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMZoomButtonsView.xib; sourceTree = "<group>"; };
|
||||
34D56DDE1B3C310A00DFF4CC /* MWMSideMenuButtonDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuButtonDelegate.h; sourceTree = "<group>"; };
|
||||
34DF4D0F1AE77B9F0012702D /* MWMWKInterfaceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMWKInterfaceController.h; sourceTree = "<group>"; };
|
||||
34DF4D101AE77B9F0012702D /* MWMWKInterfaceController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMWKInterfaceController.mm; sourceTree = "<group>"; };
|
||||
3D443C9C19E421EE0025C2FC /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
|
@ -1077,6 +1078,7 @@
|
|||
34BC72131B0DECAE0012A34B /* MWMMapViewControlsCommon.h */,
|
||||
34BC72141B0DECAE0012A34B /* MWMSideMenuButton.h */,
|
||||
34BC72151B0DECAE0012A34B /* MWMSideMenuButton.mm */,
|
||||
34D56DDE1B3C310A00DFF4CC /* MWMSideMenuButtonDelegate.h */,
|
||||
34BC72161B0DECAE0012A34B /* MWMSideMenuManager.h */,
|
||||
34BC72171B0DECAE0012A34B /* MWMSideMenuManager.mm */,
|
||||
34BC72181B0DECAE0012A34B /* MWMSideMenuView.h */,
|
||||
|
|
Loading…
Add table
Reference in a new issue