CariocaGestureManager

class CariocaGestureManager

Manages all the gestures

  • The hostview of the menu

    Declaration

    Swift

    let hostView: UIView
  • The menu’s controller

    Declaration

    Swift

    let controller: CariocaController
  • The edges of the menu

    Declaration

    Swift

    let edges: [UIRectEdge]
  • The edge gestures

    Declaration

    Swift

    let edgePanGestures: [UIScreenEdgePanGestureRecognizer] = []
  • The events delegate

    Declaration

    Swift

    weak var delegate: CariocaGestureManagerDelegate?
  • The Y position in which the ScreenEdgePan started.

    Declaration

    Swift

    var originalScreeenEdgePanY: CGFloat = 0.0
  • The menu’s container

    Declaration

    Swift

    let container: CariocaMenuContainerView
  • Internal selection index, used to check index changes.

    Declaration

    Swift

    private var internalSelectedIndex: Int
  • Initialises the gesture manager

    Declaration

    Swift

    init(hostView: UIView,
          controller: CariocaController,
          edges: [UIRectEdge],
          container: CariocaMenuContainerView,
    selectedIndex: Int)

    Parameters

    hostView

    The menu’s host view

    controller

    The menu’s content controller

    edges

    The menu’s edges

    container

    The menu’s container view

    selectedIndex

    The menu’s default selected index

  • Create the required gestures depending on the edges

    Declaration

    Swift

    func makeEdgePanGestures()
  • Pan gesture event received

    Declaration

    Swift

    @objc func panGestureEvent(_ gesture: UIScreenEdgePanGestureRecognizer)

    Parameters

    gesture

    UIScreenEdgePanGestureRecognizer

  • Manages the panning in the view

    Declaration

    Swift

    func panned(yLocation: CGFloat, edge: UIRectEdge, state: UIGestureRecognizerState, fromGesture: Bool = true)

    Parameters

    yLocation

    The gesture’s location

    edge

    The edge where the gesture started

    state

    The gesture state

    state

    The gesture state

    fromGesture

    When called from rotation event, some method calls are optionl. Default: true

  • Calculates the y top constraint, to move the menu

    Declaration

    Swift

    class func topYConstraint(yLocation: CGFloat,
                              originalScreeenEdgePanY: CGFloat,
                              menuHeight: CGFloat,
                              heightForRow: CGFloat,
                              selectedIndex: Int,
                              yRange: ClosedRange<CGFloat>,
                              isOffscreenAllowed: Bool) -> CGFloat

    Parameters

    yLocation

    The gesture’s location

    originalScreenEdgePanY

    The Y location where the gesture started

    menuHeight

    The total menu height

    heightForRow

    The height of each menu item

    selectedIndex

    The menu’s previously selected index

    yRange

    The y range representing the top/bottom Y limits where the menu can go

    isOffscreenAllowed

    Can the menu go out of the screen ?

    Return Value

    CGFloat: The new menu’s Y position

  • Calculates the menu’s matching index based on Y position

    Declaration

    Swift

    class func matchingIndex(yLocation: CGFloat,
                             menuYPosition: CGFloat,
                             heightForRow: CGFloat,
                             numberOfMenuItems: Int) -> Int

    Parameters

    yLocation

    The gesture’s location

    menuYPosition

    The menu’s Y top constraint value

    heightForRow

    The menu’s item height

    numberOfMenuItems

    The number of items in the menu

    Return Value

    Int: The matching index