Commit 73f6234e by Daniel Dahan

issue-452: fixed issue where left and right view controllers are not enabled on…

issue-452: fixed issue where left and right view controllers are not enabled on NavigationDrawerController
parent 1e72fe35
...@@ -200,18 +200,15 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -200,18 +200,15 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
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 = true { @IBInspectable public var enabledLeftView: Bool = false {
didSet { didSet {
if enabledLeftView { enabledLeftPanGesture = enabledLeftView
prepareLeftViewGestures() enabledLeftTapGesture = enabledLeftView
} else {
removeLeftViewGestures()
}
} }
} }
/// Enables the left pan gesture. /// Enables the left pan gesture.
@IBInspectable public var enabledLeftPanGesture: Bool = true { @IBInspectable public var enabledLeftPanGesture: Bool = false {
didSet { didSet {
if enabledLeftPanGesture { if enabledLeftPanGesture {
prepareLeftPanGesture() prepareLeftPanGesture()
...@@ -222,7 +219,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -222,7 +219,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
} }
/// Enables the left tap gesture. /// Enables the left tap gesture.
@IBInspectable public var enabledLeftTapGesture: Bool = true { @IBInspectable public var enabledLeftTapGesture: Bool = false {
didSet { didSet {
if enabledLeftTapGesture { if enabledLeftTapGesture {
prepareLeftTapGesture() prepareLeftTapGesture()
...@@ -236,18 +233,15 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -236,18 +233,15 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
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 = true { @IBInspectable public var enabledRightView: Bool = false {
didSet { didSet {
if enabledRightView { enabledRightPanGesture = enabledRightView
prepareRightViewGestures() enabledRightTapGesture = enabledRightView
} else {
removeRightViewGestures()
}
} }
} }
/// Enables the right pan gesture. /// Enables the right pan gesture.
@IBInspectable public var enabledRightPanGesture: Bool = true { @IBInspectable public var enabledRightPanGesture: Bool = false {
didSet { didSet {
if enabledRightPanGesture { if enabledRightPanGesture {
prepareRightPanGesture() prepareRightPanGesture()
...@@ -258,7 +252,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -258,7 +252,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
} }
/// Enables the right tap gesture. /// Enables the right tap gesture.
@IBInspectable public var enabledRightTapGesture: Bool = true { @IBInspectable public var enabledRightTapGesture: Bool = false {
didSet { didSet {
if enabledRightTapGesture { if enabledRightTapGesture {
prepareRightTapGesture() prepareRightTapGesture()
...@@ -878,7 +872,6 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -878,7 +872,6 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
private func prepareLeftViewController() { private func prepareLeftViewController() {
if let v: MaterialView = leftView { if let v: MaterialView = leftView {
prepareViewControllerWithinContainer(leftViewController, container: v) prepareViewControllerWithinContainer(leftViewController, container: v)
prepareLeftViewGestures()
} }
} }
...@@ -886,57 +879,50 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -886,57 +879,50 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
private func prepareRightViewController() { private func prepareRightViewController() {
if let v: MaterialView = rightView { if let v: MaterialView = rightView {
prepareViewControllerWithinContainer(rightViewController, container: v) prepareViewControllerWithinContainer(rightViewController, container: v)
prepareRightViewGestures()
} }
} }
/// A method that prepares the leftView. /// A method that prepares the leftView.
private func prepareLeftView() { private func prepareLeftView() {
if nil == leftViewController { guard let _: UIViewController = leftViewController else {
enabledLeftView = false return
enabledLeftPanGesture = false
enabledLeftTapGesture = false
} else if nil == leftView {
leftViewWidth = .iPhone == MaterialDevice.type ? 280 : 320
leftView = MaterialView()
leftView!.frame = CGRectMake(0, 0, leftViewWidth, view.frame.height)
leftView!.backgroundColor = MaterialColor.clear
view.addSubview(leftView!)
leftView!.hidden = true
leftView!.position.x = -leftViewWidth / 2
leftView!.zPosition = 2000
prepareLeftViewController()
} }
enabledLeftView = true
leftViewWidth = .iPhone == MaterialDevice.type ? 280 : 320
leftView = MaterialView()
leftView!.frame = CGRectMake(0, 0, leftViewWidth, view.frame.height)
leftView!.backgroundColor = MaterialColor.clear
view.addSubview(leftView!)
leftView!.hidden = true
leftView!.position.x = -leftViewWidth / 2
leftView!.zPosition = 2000
prepareLeftViewController()
} }
/// A method that prepares the leftView. /// A method that prepares the leftView.
private func prepareRightView() { private func prepareRightView() {
if nil == rightViewController { guard let _: UIViewController = rightViewController else {
enabledRightView = false return
enabledRightPanGesture = false
enabledRightTapGesture = false
} else if nil == rightView {
rightViewWidth = .iPhone == MaterialDevice.type ? 280 : 320
rightView = MaterialView()
rightView!.frame = CGRectMake(0, 0, rightViewWidth, view.frame.height)
rightView!.backgroundColor = MaterialColor.clear
view.addSubview(rightView!)
rightView!.hidden = true
rightView!.position.x = view.bounds.width + rightViewWidth / 2
rightView!.zPosition = 2000
prepareRightViewController()
} }
enabledRightView = true
rightViewWidth = .iPhone == MaterialDevice.type ? 280 : 320
rightView = MaterialView()
rightView!.frame = CGRectMake(0, 0, rightViewWidth, view.frame.height)
rightView!.backgroundColor = MaterialColor.clear
view.addSubview(rightView!)
rightView!.hidden = true
rightView!.position.x = view.bounds.width + rightViewWidth / 2
rightView!.zPosition = 2000
prepareRightViewController()
} }
/// A method that prepares the gestures used within the leftView. /// Prepare the left pan gesture.
private func prepareLeftViewGestures() {
prepareLeftPanGesture()
prepareLeftTapGesture()
}
/// Prepare the left pan gesture.
private func prepareLeftPanGesture() { private func prepareLeftPanGesture() {
if nil == leftPanGesture { if nil == leftPanGesture {
leftPanGesture = UIPanGestureRecognizer(target: self, action: #selector(handleLeftViewPanGesture(_:))) leftPanGesture = UIPanGestureRecognizer(target: self, action: #selector(handleLeftViewPanGesture(_:)))
...@@ -955,12 +941,6 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -955,12 +941,6 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
} }
} }
/// A method that prepares the gestures used within the rightView.
private func prepareRightViewGestures() {
prepareRightPanGesture()
prepareRightTapGesture()
}
/// Prepares the right pan gesture. /// Prepares the right pan gesture.
private func prepareRightPanGesture() { private func prepareRightPanGesture() {
if nil == rightPanGesture { if nil == rightPanGesture {
......
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