Skip to content

Commit

Permalink
Introduce ZoomGestureHandlerProtocol for common zoom-related gesture …
Browse files Browse the repository at this point in the history
…handler things
  • Loading branch information
evil159 committed Feb 15, 2022
1 parent aba883a commit b8bc6cf
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 30 deletions.
7 changes: 3 additions & 4 deletions Sources/MapboxMaps/Foundation/MapViewDependencyProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ internal final class MapViewDependencyProvider: MapViewDependencyProviderProtoco

func makeDoubleTapToZoomInGestureHandler(view: UIView,
mapboxMap: MapboxMapProtocol,
cameraAnimationsManager: CameraAnimationsManagerProtocol) -> DoubleTapToZoomInGestureHandlerProtocol {
cameraAnimationsManager: CameraAnimationsManagerProtocol) -> ZoomGestureHandlerProtocol {
let gestureRecognizer = UITapGestureRecognizer()
view.addGestureRecognizer(gestureRecognizer)
return DoubleTapToZoomInGestureHandler(
Expand All @@ -81,7 +81,7 @@ internal final class MapViewDependencyProvider: MapViewDependencyProviderProtoco

func makeDoubleTouchToZoomOutGestureHandler(view: UIView,
mapboxMap: MapboxMapProtocol,
cameraAnimationsManager: CameraAnimationsManagerProtocol) -> DoubleTouchToZoomOutGestureHandlerProtocol {
cameraAnimationsManager: CameraAnimationsManagerProtocol) -> ZoomGestureHandlerProtocol {
let gestureRecognizer = UITapGestureRecognizer()
view.addGestureRecognizer(gestureRecognizer)
return DoubleTouchToZoomOutGestureHandler(
Expand All @@ -90,8 +90,7 @@ internal final class MapViewDependencyProvider: MapViewDependencyProviderProtoco
cameraAnimationsManager: cameraAnimationsManager)
}

func makeQuickZoomGestureHandler(view: UIView,
mapboxMap: MapboxMapProtocol) -> QuickZoomGestureHandlerProtocol {
func makeQuickZoomGestureHandler(view: UIView, mapboxMap: MapboxMapProtocol) -> ZoomGestureHandlerProtocol {
let gestureRecognizer = UILongPressGestureRecognizer()
view.addGestureRecognizer(gestureRecognizer)
return QuickZoomGestureHandler(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import UIKit

internal protocol DoubleTapToZoomInGestureHandlerProtocol: GestureHandler {
var focalPoint: CGPoint? { get set }
}

/// `DoubleTapToZoomInGestureHandler` updates the map camera in response
/// to double tap gestures with 1 touch
internal final class DoubleTapToZoomInGestureHandler: GestureHandler, DoubleTapToZoomInGestureHandlerProtocol {
internal final class DoubleTapToZoomInGestureHandler: GestureHandler, ZoomGestureHandlerProtocol {
internal var focalPoint: CGPoint?

private let mapboxMap: MapboxMapProtocol
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import UIKit

internal protocol DoubleTouchToZoomOutGestureHandlerProtocol: GestureHandler {
var focalPoint: CGPoint? { get set }
}

/// `DoubleTouchToZoomOutGestureHandler` updates the map camera in response
/// to single tap gestures with 2 touches
internal final class DoubleTouchToZoomOutGestureHandler: GestureHandler, DoubleTouchToZoomOutGestureHandlerProtocol {
internal final class DoubleTouchToZoomOutGestureHandler: GestureHandler, ZoomGestureHandlerProtocol {
internal var focalPoint: CGPoint?

private let mapboxMap: MapboxMapProtocol
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import UIKit

internal protocol PinchGestureHandlerProtocol: GestureHandler {
internal protocol PinchGestureHandlerProtocol: ZoomGestureHandlerProtocol {
var rotateEnabled: Bool { get set }
var behavior: PinchGestureBehavior { get set }
var focalPoint: CGPoint? { get set }
}

internal protocol PinchGestureHandlerImpl: AnyObject {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import UIKit

internal protocol QuickZoomGestureHandlerProtocol: GestureHandler {
var focalPoint: CGPoint? { get set }
}

/// `QuickZoomGestureHandler` updates the map camera in response to double tap and drag gestures
internal final class QuickZoomGestureHandler: GestureHandler, QuickZoomGestureHandlerProtocol {
internal final class QuickZoomGestureHandler: GestureHandler, ZoomGestureHandlerProtocol {
internal var focalPoint: CGPoint?

private var initialLocation: CGPoint?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

internal protocol ZoomGestureHandlerProtocol: GestureHandler {
var focalPoint: CGPoint? { get set }
}
12 changes: 6 additions & 6 deletions Sources/MapboxMaps/Gestures/GestureManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ public final class GestureManager: GestureHandlerDelegate {
private let panGestureHandler: PanGestureHandlerProtocol
private let pinchGestureHandler: PinchGestureHandlerProtocol
private let pitchGestureHandler: GestureHandler
private let doubleTapToZoomInGestureHandler: DoubleTapToZoomInGestureHandlerProtocol
private let doubleTouchToZoomOutGestureHandler: DoubleTouchToZoomOutGestureHandlerProtocol
private let quickZoomGestureHandler: QuickZoomGestureHandlerProtocol
private let doubleTapToZoomInGestureHandler: ZoomGestureHandlerProtocol
private let doubleTouchToZoomOutGestureHandler: ZoomGestureHandlerProtocol
private let quickZoomGestureHandler: ZoomGestureHandlerProtocol
private let singleTapGestureHandler: GestureHandler
private let anyTouchGestureHandler: GestureHandler
private let mapboxMap: MapboxMapProtocol

internal init(panGestureHandler: PanGestureHandlerProtocol,
pinchGestureHandler: PinchGestureHandlerProtocol,
pitchGestureHandler: GestureHandler,
doubleTapToZoomInGestureHandler: DoubleTapToZoomInGestureHandlerProtocol,
doubleTouchToZoomOutGestureHandler: DoubleTouchToZoomOutGestureHandlerProtocol,
quickZoomGestureHandler: QuickZoomGestureHandlerProtocol,
doubleTapToZoomInGestureHandler: ZoomGestureHandlerProtocol,
doubleTouchToZoomOutGestureHandler: ZoomGestureHandlerProtocol,
quickZoomGestureHandler: ZoomGestureHandlerProtocol,
singleTapGestureHandler: GestureHandler,
anyTouchGestureHandler: GestureHandler,
mapboxMap: MapboxMapProtocol) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@testable import MapboxMaps

final class MockDoubleTapToZoomInGestureHandler: GestureHandler, DoubleTapToZoomInGestureHandlerProtocol {
final class MockDoubleTapToZoomInGestureHandler: GestureHandler, ZoomGestureHandlerProtocol {
var focalPoint: CGPoint?
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@testable import MapboxMaps

final class MockDoubleTouchToZoomOutGestureHandler: GestureHandler, DoubleTouchToZoomOutGestureHandlerProtocol {
final class MockDoubleTouchToZoomOutGestureHandler: GestureHandler, ZoomGestureHandlerProtocol {
var focalPoint: CGPoint?
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@testable import MapboxMaps

final class MockQuickZoomGestureHandler: GestureHandler, QuickZoomGestureHandlerProtocol {
final class MockQuickZoomGestureHandler: GestureHandler, ZoomGestureHandlerProtocol {
var focalPoint: CGPoint?
}

0 comments on commit b8bc6cf

Please sign in to comment.