Commit 05b19fa0 by Daniel Dahan

development: updated NavigationDrawerController to be open rather than public

parent d5605753
...@@ -122,7 +122,7 @@ public protocol NavigationDrawerControllerDelegate { ...@@ -122,7 +122,7 @@ public protocol NavigationDrawerControllerDelegate {
@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.
...@@ -185,13 +185,15 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -185,13 +185,15 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
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
} }
...@@ -209,7 +211,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -209,7 +211,8 @@ 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()
...@@ -242,7 +247,8 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -242,7 +247,8 @@ 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()
...@@ -275,38 +283,39 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -275,38 +283,39 @@ 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
} }
...@@ -328,31 +337,33 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -328,31 +337,33 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
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.
...@@ -360,6 +371,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -360,6 +371,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
*/ */
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView()
} }
/** /**
...@@ -369,6 +381,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -369,6 +381,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
*/ */
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()
} }
/** /**
...@@ -391,7 +404,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -391,7 +404,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
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 {
...@@ -447,7 +460,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -447,7 +460,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
- 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
...@@ -521,7 +534,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -521,7 +534,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
- 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
...@@ -591,7 +604,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -591,7 +604,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
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)
} }
...@@ -602,7 +615,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -602,7 +615,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
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)
} }
...@@ -612,7 +625,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -612,7 +625,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
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()
...@@ -638,7 +651,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -638,7 +651,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
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()
...@@ -666,7 +679,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -666,7 +679,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
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
...@@ -694,7 +707,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -694,7 +707,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
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
...@@ -722,7 +735,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -722,7 +735,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
- 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
} }
......
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