Commit 05b19fa0 by Daniel Dahan

development: updated NavigationDrawerController to be open rather than public

parent d5605753
...@@ -57,141 +57,143 @@ extension UIViewController { ...@@ -57,141 +57,143 @@ extension UIViewController {
@objc(NavigationDrawerControllerDelegate) @objc(NavigationDrawerControllerDelegate)
public protocol NavigationDrawerControllerDelegate { public protocol NavigationDrawerControllerDelegate {
/** /**
An optional delegation method that is fired before the An optional delegation method that is fired before the
NavigationDrawerController opens. NavigationDrawerController opens.
*/ */
@objc @objc
optional func navigationDrawerWillOpen(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition) optional func navigationDrawerWillOpen(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired after the An optional delegation method that is fired after the
NavigationDrawerController opened. NavigationDrawerController opened.
*/ */
@objc @objc
optional func navigationDrawerDidOpen(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition) optional func navigationDrawerDidOpen(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired before the An optional delegation method that is fired before the
NavigationDrawerController closes. NavigationDrawerController closes.
*/ */
@objc @objc
optional func navigationDrawerWillClose(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition) optional func navigationDrawerWillClose(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired after the An optional delegation method that is fired after the
NavigationDrawerController closed. NavigationDrawerController closed.
*/ */
@objc @objc
optional func navigationDrawerDidClose(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition) optional func navigationDrawerDidClose(navigationDrawerController: NavigationDrawerController, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
NavigationDrawerController pan gesture begins. NavigationDrawerController pan gesture begins.
*/ */
@objc @objc
optional func navigationDrawerPanDidBegin(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition) optional func navigationDrawerPanDidBegin(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
NavigationDrawerController pan gesture changes position. NavigationDrawerController pan gesture changes position.
*/ */
@objc @objc
optional func navigationDrawerPanDidChange(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition) optional func navigationDrawerPanDidChange(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
NavigationDrawerController pan gesture ends. NavigationDrawerController pan gesture ends.
*/ */
@objc @objc
optional func navigationDrawerPanDidEnd(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition) optional func navigationDrawerPanDidEnd(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
NavigationDrawerController tap gesture executes. NavigationDrawerController tap gesture executes.
*/ */
@objc @objc
optional func navigationDrawerDidTap(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition) optional func navigationDrawerDidTap(navigationDrawerController: NavigationDrawerController, point: CGPoint, position: NavigationDrawerPosition)
/** /**
An optional delegation method that is fired when the An optional delegation method that is fired when the
status bar is about to change display, hidden or not. status bar is about to change display, hidden or not.
*/ */
@objc @objc
optional func navigationDrawerStatusBarHiddenState(navigationDrawerController: NavigationDrawerController, hidden: Bool) optional func navigationDrawerStatusBarHiddenState(navigationDrawerController: NavigationDrawerController, hidden: Bool)
} }
@IBDesignable @IBDesignable
@objc(NavigationDrawerController) @objc(NavigationDrawerController)
public class NavigationDrawerController: RootController, UIGestureRecognizerDelegate { open class NavigationDrawerController: RootController, UIGestureRecognizerDelegate {
/** /**
A CGFloat property that is used internally to track A CGFloat property that is used internally to track
the original (x) position of the container view when panning. the original (x) position of the container view when panning.
*/ */
private var originalX: CGFloat = 0 private var originalX: CGFloat = 0
/** /**
A UIPanGestureRecognizer property internally used for the A UIPanGestureRecognizer property internally used for the
leftView pan gesture. leftView pan gesture.
*/ */
internal private(set) var leftPanGesture: UIPanGestureRecognizer? internal private(set) var leftPanGesture: UIPanGestureRecognizer?
/** /**
A UIPanGestureRecognizer property internally used for the A UIPanGestureRecognizer property internally used for the
rightView pan gesture. rightView pan gesture.
*/ */
internal private(set) var rightPanGesture: UIPanGestureRecognizer? internal private(set) var rightPanGesture: UIPanGestureRecognizer?
/** /**
A UITapGestureRecognizer property internally used for the A UITapGestureRecognizer property internally used for the
leftView tap gesture. leftView tap gesture.
*/ */
internal private(set) var leftTapGesture: UITapGestureRecognizer? internal private(set) var leftTapGesture: UITapGestureRecognizer?
/** /**
A UITapGestureRecognizer property internally used for the A UITapGestureRecognizer property internally used for the
rightView tap gesture. rightView tap gesture.
*/ */
internal private(set) var rightTapGesture: UITapGestureRecognizer? internal private(set) var rightTapGesture: UITapGestureRecognizer?
/** /**
A CGFloat property that accesses the leftView threshold of A CGFloat property that accesses the leftView threshold of
the NavigationDrawerController. When the panning gesture has the NavigationDrawerController. When the panning gesture has
ended, if the position is beyond the threshold, ended, if the position is beyond the threshold,
the leftView is opened, if it is below the threshold, the the leftView is opened, if it is below the threshold, the
leftView is closed. The leftViewThreshold is always at half leftView is closed. The leftViewThreshold is always at half
the width of the leftView. the width of the leftView.
*/ */
@IBInspectable public var leftThreshold: CGFloat = 64 @IBInspectable public var leftThreshold: CGFloat = 64
private var leftViewThreshold: CGFloat = 0 private var leftViewThreshold: CGFloat = 0
/** /**
A CGFloat property that accesses the rightView threshold of A CGFloat property that accesses the rightView threshold of
the NavigationDrawerController. When the panning gesture has the NavigationDrawerController. When the panning gesture has
ended, if the position is beyond the threshold, ended, if the position is beyond the threshold,
the rightView is closed, if it is below the threshold, the the rightView is closed, if it is below the threshold, the
rightView is opened. The rightViewThreshold is always at half rightView is opened. The rightViewThreshold is always at half
the width of the rightView. the width of the rightView.
*/ */
@IBInspectable public var rightThreshold: CGFloat = 64 @IBInspectable public var rightThreshold: CGFloat = 64
private var rightViewThreshold: CGFloat = 0 private var rightViewThreshold: CGFloat = 0
/** /**
A NavigationDrawerControllerDelegate property used to bind A NavigationDrawerControllerDelegate property used to bind
the delegation object. the delegation object.
*/ */
open weak var delegate: NavigationDrawerControllerDelegate? open weak var delegate: NavigationDrawerControllerDelegate?
/** /**
A CGFloat property that sets the animation duration of the A CGFloat property that sets the animation duration of the
leftView when closing and opening. Defaults to 0.25. leftView when closing and opening. Defaults to 0.25.
*/ */
@IBInspectable public var animationDuration: TimeInterval = 0.25 @IBInspectable
open var animationDuration: TimeInterval = 0.25
/** /**
A Boolean property that enables and disables the leftView from A Boolean property that enables and disables the leftView from
opening and closing. Defaults to true. opening and closing. Defaults to true.
*/ */
@IBInspectable public var enabled: Bool { @IBInspectable
open var enabled: Bool {
get { get {
return enabledLeftView || enabledRightView return enabledLeftView || enabledRightView
} }
...@@ -206,10 +208,11 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -206,10 +208,11 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A Boolean property that enables and disables the leftView from A Boolean property that enables and disables the leftView from
opening and closing. Defaults to true. opening and closing. Defaults to true.
*/ */
@IBInspectable public var enabledLeftView: Bool = false { @IBInspectable
open var enabledLeftView = false {
didSet { didSet {
enabledLeftPanGesture = enabledLeftView enabledLeftPanGesture = enabledLeftView
enabledLeftTapGesture = enabledLeftView enabledLeftTapGesture = enabledLeftView
...@@ -217,7 +220,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -217,7 +220,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/// Enables the left pan gesture. /// Enables the left pan gesture.
@IBInspectable public var enabledLeftPanGesture: Bool = false { @IBInspectable
open var enabledLeftPanGesture = false {
didSet { didSet {
if enabledLeftPanGesture { if enabledLeftPanGesture {
prepareLeftPanGesture() prepareLeftPanGesture()
...@@ -228,7 +232,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -228,7 +232,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/// Enables the left tap gesture. /// Enables the left tap gesture.
@IBInspectable public var enabledLeftTapGesture: Bool = false { @IBInspectable
open var enabledLeftTapGesture = false {
didSet { didSet {
if enabledLeftTapGesture { if enabledLeftTapGesture {
prepareLeftTapGesture() prepareLeftTapGesture()
...@@ -239,10 +244,11 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -239,10 +244,11 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A Boolean property that enables and disables the rightView from A Boolean property that enables and disables the rightView from
opening and closing. Defaults to true. opening and closing. Defaults to true.
*/ */
@IBInspectable public var enabledRightView: Bool = false { @IBInspectable
open var enabledRightView = false {
didSet { didSet {
enabledRightPanGesture = enabledRightView enabledRightPanGesture = enabledRightView
enabledRightTapGesture = enabledRightView enabledRightTapGesture = enabledRightView
...@@ -250,7 +256,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -250,7 +256,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/// Enables the right pan gesture. /// Enables the right pan gesture.
@IBInspectable public var enabledRightPanGesture: Bool = false { @IBInspectable
open var enabledRightPanGesture = false {
didSet { didSet {
if enabledRightPanGesture { if enabledRightPanGesture {
prepareRightPanGesture() prepareRightPanGesture()
...@@ -261,7 +268,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -261,7 +268,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/// Enables the right tap gesture. /// Enables the right tap gesture.
@IBInspectable public var enabledRightTapGesture: Bool = false { @IBInspectable
open var enabledRightTapGesture = false {
didSet { didSet {
if enabledRightTapGesture { if enabledRightTapGesture {
prepareRightTapGesture() prepareRightTapGesture()
...@@ -272,41 +280,42 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -272,41 +280,42 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A Boolean property that triggers the status bar to be hidden A Boolean property that triggers the status bar to be hidden
when the leftView is opened. Defaults to true. when the leftView is opened. Defaults to true.
*/ */
@IBInspectable public var enableHideStatusBar: Bool = true @IBInspectable
open var enableHideStatusBar = true
/// Sets the statusBar to hidden or not. /// Sets the statusBar to hidden or not.
public private(set) var isStatusBarHidden: Bool = false open private(set) var isStatusBarHidden = false
/** /**
A DepthPreset property that is used to set the depth of the A DepthPreset property that is used to set the depth of the
leftView when opened. leftView when opened.
*/ */
public var depthPreset: DepthPreset = .depth1 open var depthPreset = DepthPreset.depth1
/** /**
A View property that is used to hide and reveal the A View property that is used to hide and reveal the
leftViewController. It is very rare that this property will leftViewController. It is very rare that this property will
need to be accessed externally. need to be accessed externally.
*/ */
public private(set) var leftView: View? open private(set) var leftView: View?
/** /**
A View property that is used to hide and reveal the A View property that is used to hide and reveal the
rightViewController. It is very rare that this property will rightViewController. It is very rare that this property will
need to be accessed externally. need to be accessed externally.
*/ */
public private(set) var rightView: View? open private(set) var rightView: View?
/// Indicates whether the leftView or rightView is opened. /// Indicates whether the leftView or rightView is opened.
public var opened: Bool { open var opened: Bool {
return openedLeftView || openedRightView return openedLeftView || openedRightView
} }
/// indicates if the leftView is opened. /// indicates if the leftView is opened.
public var openedLeftView: Bool { open var openedLeftView: Bool {
guard nil != leftView else { guard nil != leftView else {
return false return false
} }
...@@ -314,7 +323,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -314,7 +323,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/// Indicates if the rightView is opened. /// Indicates if the rightView is opened.
public var openedRightView: Bool { open var openedRightView: Bool {
guard nil != rightView else { guard nil != rightView else {
return false return false
} }
...@@ -322,61 +331,65 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -322,61 +331,65 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
Content view controller to encompase the entire component. This is Content view controller to encompase the entire component. This is
primarily used when the StatusBar is being hidden. The alpha value of primarily used when the StatusBar is being hidden. The alpha value of
the rootViewController decreases, and shows the StatusBar. To avoid the rootViewController decreases, and shows the StatusBar. To avoid
this, and to add a hidden transition viewController for complex this, and to add a hidden transition viewController for complex
situations, the contentViewController was added. situations, the contentViewController was added.
*/ */
public private(set) lazy var contentViewController: UIViewController = UIViewController() open private(set) lazy var contentViewController: UIViewController = UIViewController()
/** /**
A UIViewController property that references the A UIViewController property that references the
active left UIViewController. active left UIViewController.
*/ */
public private(set) var leftViewController: UIViewController? open private(set) var leftViewController: UIViewController?
/** /**
A UIViewController property that references the A UIViewController property that references the
active right UIViewController. active right UIViewController.
*/ */
public private(set) var rightViewController: UIViewController? open private(set) var rightViewController: UIViewController?
/** /**
A CGFloat property to access the width that the leftView A CGFloat property to access the width that the leftView
opens up to. opens up to.
*/ */
@IBInspectable public private(set) var leftViewWidth: CGFloat! @IBInspectable
open private(set) var leftViewWidth: CGFloat!
/** /**
A CGFloat property to access the width that the rightView A CGFloat property to access the width that the rightView
opens up to. opens up to.
*/ */
@IBInspectable public private(set) var rightViewWidth: CGFloat! @IBInspectable
open private(set) var rightViewWidth: CGFloat!
/** /**
An initializer that initializes the object with a NSCoder object. An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance. - Parameter aDecoder: A NSCoder instance.
*/ */
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView()
} }
/** /**
An initializer that initializes the object with an Optional nib and bundle. An initializer that initializes the object with an Optional nib and bundle.
- Parameter nibNameOrNil: An Optional String for the nib. - Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located. - Parameter bundle: An Optional NSBundle where the nib is located.
*/ */
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
prepareView()
} }
/** /**
An initializer for the NavigationDrawerController. An initializer for the NavigationDrawerController.
- Parameter rootViewController: The main UIViewController. - Parameter rootViewController: The main UIViewController.
- Parameter leftViewController: An Optional left UIViewController. - Parameter leftViewController: An Optional left UIViewController.
- Parameter rightViewController: An Optional right UIViewController. - Parameter rightViewController: An Optional right UIViewController.
*/ */
public init(rootViewController: UIViewController, leftViewController: UIViewController? = nil, rightViewController: UIViewController? = nil) { public init(rootViewController: UIViewController, leftViewController: UIViewController? = nil, rightViewController: UIViewController? = nil) {
super.init(rootViewController: rootViewController) super.init(rootViewController: rootViewController)
self.leftViewController = leftViewController self.leftViewController = leftViewController
...@@ -385,13 +398,13 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -385,13 +398,13 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method it is recommended to override the prepareView method
to initialize property values and other setup operations. to initialize property values and other setup operations.
The super.prepareView method should always be called immediately The super.prepareView method should always be called immediately
when subclassing. when subclassing.
*/ */
public override func prepareView() { open override func prepareView() {
super.prepareView() super.prepareView()
prepareContentViewController() prepareContentViewController()
prepareLeftView() prepareLeftView()
...@@ -399,7 +412,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -399,7 +412,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/// Layout subviews. /// Layout subviews.
public override func layoutSubviews() { open override func layoutSubviews() {
if opened { if opened {
hideStatusBar() hideStatusBar()
} else { } else {
...@@ -429,7 +442,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -429,7 +442,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
} }
public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator) super.viewWillTransition(to: size, with: coordinator)
// Ensures the view is hidden. // Ensures the view is hidden.
if let v: View = rightView { if let v: View = rightView {
...@@ -438,16 +451,16 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -438,16 +451,16 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A method that is used to set the width of the leftView when A method that is used to set the width of the leftView when
opened. This is the recommended method of setting the leftView opened. This is the recommended method of setting the leftView
width. width.
- Parameter width: A CGFloat value to set as the new width. - Parameter width: A CGFloat value to set as the new width.
- Parameter hidden: A Boolean value of whether the leftView - Parameter hidden: A Boolean value of whether the leftView
should be hidden after the width has been updated or not. should be hidden after the width has been updated or not.
- Parameter animated: A Boolean value that indicates to animate - Parameter animated: A Boolean value that indicates to animate
the leftView width change. the leftView width change.
*/ */
public func setLeftViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: TimeInterval = 0.5) { open func setLeftViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: TimeInterval = 0.5) {
if let v: View = leftView { if let v: View = leftView {
leftViewWidth = width leftViewWidth = width
...@@ -512,16 +525,16 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -512,16 +525,16 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A method that is used to set the width of the rightView when A method that is used to set the width of the rightView when
opened. This is the recommended method of setting the rightView opened. This is the recommended method of setting the rightView
width. width.
- Parameter width: A CGFloat value to set as the new width. - Parameter width: A CGFloat value to set as the new width.
- Parameter hidden: A Boolean value of whether the rightView - Parameter hidden: A Boolean value of whether the rightView
should be hidden after the width has been updated or not. should be hidden after the width has been updated or not.
- Parameter animated: A Boolean value that indicates to animate - Parameter animated: A Boolean value that indicates to animate
the rightView width change. the rightView width change.
*/ */
public func setRightViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: TimeInterval = 0.5) { open func setRightViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: TimeInterval = 0.5) {
if let v: View = rightView { if let v: View = rightView {
rightViewWidth = width rightViewWidth = width
...@@ -585,34 +598,34 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -585,34 +598,34 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A method that toggles the leftView opened if previously closed, A method that toggles the leftView opened if previously closed,
or closed if previously opened. or closed if previously opened.
- Parameter velocity: A CGFloat value that sets the - Parameter velocity: A CGFloat value that sets the
velocity of the user interaction when animating the velocity of the user interaction when animating the
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
public func toggleLeftView(velocity: CGFloat = 0) { open func toggleLeftView(velocity: CGFloat = 0) {
openedLeftView ? closeLeftView(velocity: velocity) : openLeftView(velocity: velocity) openedLeftView ? closeLeftView(velocity: velocity) : openLeftView(velocity: velocity)
} }
/** /**
A method that toggles the rightView opened if previously closed, A method that toggles the rightView opened if previously closed,
or closed if previously opened. or closed if previously opened.
- Parameter velocity: A CGFloat value that sets the - Parameter velocity: A CGFloat value that sets the
velocity of the user interaction when animating the velocity of the user interaction when animating the
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
public func toggleRightView(velocity: CGFloat = 0) { open func toggleRightView(velocity: CGFloat = 0) {
openedRightView ? closeRightView(velocity: velocity) : openRightView(velocity: velocity) openedRightView ? closeRightView(velocity: velocity) : openRightView(velocity: velocity)
} }
/** /**
A method that opens the leftView. A method that opens the leftView.
- Parameter velocity: A CGFloat value that sets the - Parameter velocity: A CGFloat value that sets the
velocity of the user interaction when animating the velocity of the user interaction when animating the
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
public func openLeftView(velocity: CGFloat = 0) { open func openLeftView(velocity: CGFloat = 0) {
if enabledLeftView { if enabledLeftView {
if let v: View = leftView { if let v: View = leftView {
hideStatusBar() hideStatusBar()
...@@ -633,12 +646,12 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -633,12 +646,12 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A method that opens the rightView. A method that opens the rightView.
- Parameter velocity: A CGFloat value that sets the - Parameter velocity: A CGFloat value that sets the
velocity of the user interaction when animating the velocity of the user interaction when animating the
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
public func openRightView(velocity: CGFloat = 0) { open func openRightView(velocity: CGFloat = 0) {
if enabledRightView { if enabledRightView {
if let v: View = rightView { if let v: View = rightView {
hideStatusBar() hideStatusBar()
...@@ -661,12 +674,12 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -661,12 +674,12 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A method that closes the leftView. A method that closes the leftView.
- Parameter velocity: A CGFloat value that sets the - Parameter velocity: A CGFloat value that sets the
velocity of the user interaction when animating the velocity of the user interaction when animating the
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
public func closeLeftView(velocity: CGFloat = 0) { open func closeLeftView(velocity: CGFloat = 0) {
if enabledLeftView { if enabledLeftView {
if let v: View = leftView { if let v: View = leftView {
isUserInteractionEnabled = true isUserInteractionEnabled = true
...@@ -689,12 +702,12 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -689,12 +702,12 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A method that closes the rightView. A method that closes the rightView.
- Parameter velocity: A CGFloat value that sets the - Parameter velocity: A CGFloat value that sets the
velocity of the user interaction when animating the velocity of the user interaction when animating the
leftView. Defaults to 0. leftView. Defaults to 0.
*/ */
public func closeRightView(velocity: CGFloat = 0) { open func closeRightView(velocity: CGFloat = 0) {
if enabledRightView { if enabledRightView {
if let v: View = rightView { if let v: View = rightView {
isUserInteractionEnabled = true isUserInteractionEnabled = true
...@@ -717,12 +730,12 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -717,12 +730,12 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
Detects the gesture recognizer being used. Detects the gesture recognizer being used.
- Parameter gestureRecognizer: A UIGestureRecognizer to detect. - Parameter gestureRecognizer: A UIGestureRecognizer to detect.
- Parameter touch: The UITouch event. - Parameter touch: The UITouch event.
- Returns: A Boolean of whether to continue the gesture or not. - Returns: A Boolean of whether to continue the gesture or not.
*/ */
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { open func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
if !openedRightView && gestureRecognizer == leftPanGesture && (openedLeftView || isPointContainedWithinLeftThreshold(point: touch.location(in: view))) { if !openedRightView && gestureRecognizer == leftPanGesture && (openedLeftView || isPointContainedWithinLeftThreshold(point: touch.location(in: view))) {
return true return true
} }
...@@ -1058,58 +1071,58 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -1058,58 +1071,58 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
} }
/** /**
A method that determines whether the passed point is A method that determines whether the passed point is
contained within the bounds of the leftViewThreshold contained within the bounds of the leftViewThreshold
and height of the NavigationDrawerController view frame and height of the NavigationDrawerController view frame
property. property.
- Parameter point: A CGPoint to test against. - Parameter point: A CGPoint to test against.
- Returns: A Boolean of the result, true if yes, false - Returns: A Boolean of the result, true if yes, false
otherwise. otherwise.
*/ */
private func isPointContainedWithinLeftThreshold(point: CGPoint) -> Bool { private func isPointContainedWithinLeftThreshold(point: CGPoint) -> Bool {
return point.x <= leftThreshold return point.x <= leftThreshold
} }
/** /**
A method that determines whether the passed point is A method that determines whether the passed point is
contained within the bounds of the rightViewThreshold contained within the bounds of the rightViewThreshold
and height of the NavigationDrawerController view frame and height of the NavigationDrawerController view frame
property. property.
- Parameter point: A CGPoint to test against. - Parameter point: A CGPoint to test against.
- Returns: A Boolean of the result, true if yes, false - Returns: A Boolean of the result, true if yes, false
otherwise. otherwise.
*/ */
private func isPointContainedWithinRighThreshold(point: CGPoint) -> Bool { private func isPointContainedWithinRighThreshold(point: CGPoint) -> Bool {
return point.x >= view.bounds.width - rightThreshold return point.x >= view.bounds.width - rightThreshold
} }
/** /**
A method that determines whether the passed in point is A method that determines whether the passed in point is
contained within the bounds of the passed in container view. contained within the bounds of the passed in container view.
- Parameter container: A UIView that sets the bounds to test - Parameter container: A UIView that sets the bounds to test
against. against.
- Parameter point: A CGPoint to test whether or not it is - Parameter point: A CGPoint to test whether or not it is
within the bounds of the container parameter. within the bounds of the container parameter.
- Returns: A Boolean of the result, true if yes, false - Returns: A Boolean of the result, true if yes, false
otherwise. otherwise.
*/ */
private func isPointContainedWithinView(container: UIView, point: CGPoint) -> Bool { private func isPointContainedWithinView(container: UIView, point: CGPoint) -> Bool {
return container.bounds.contains(point) return container.bounds.contains(point)
} }
/** /**
A method that shows a view. A method that shows a view.
- Parameter container: A container view. - Parameter container: A container view.
*/ */
private func showView(container: View) { private func showView(container: View) {
container.depthPreset = depthPreset container.depthPreset = depthPreset
container.isHidden = false container.isHidden = false
} }
/** /**
A method that hides a view. A method that hides a view.
- Parameter container: A container view. - Parameter container: A container view.
*/ */
private func hideView(container: View) { private func hideView(container: View) {
container.depthPreset = .none container.depthPreset = .none
container.isHidden = true container.isHidden = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment