Commit 66e17f2b by danieldahan

Updated SideNavigationViewController enabled handling

parent e3f144a9
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Material' s.name = 'Material'
s.version = '1.30.1' s.version = '1.30.2'
s.license = 'BSD' s.license = 'BSD'
s.summary = 'A beautiful graphics framework for Material Design in Swift.' s.summary = 'A beautiful graphics framework for Material Design in Swift.'
s.homepage = 'http://cosmicmind.io' s.homepage = 'http://cosmicmind.io'
......
...@@ -509,6 +509,7 @@ ...@@ -509,6 +509,7 @@
TargetAttributes = { TargetAttributes = {
963832351B88DFD80015F710 = { 963832351B88DFD80015F710 = {
CreatedOnToolsVersion = 6.4; CreatedOnToolsVersion = 6.4;
DevelopmentTeam = 6R427Q9MFC;
}; };
963832401B88DFD80015F710 = { 963832401B88DFD80015F710 = {
CreatedOnToolsVersion = 6.4; CreatedOnToolsVersion = 6.4;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.30.1</string> <string>1.30.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -187,8 +187,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -187,8 +187,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
return enabledLeftView || enabledRightView return enabledLeftView || enabledRightView
} }
set(value) { set(value) {
enabledLeftView = value if nil != leftView {
enabledRightView = value enabledLeftView = value
}
if nil != rightView {
enabledRightView = value
}
} }
} }
...@@ -196,12 +200,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -196,12 +200,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
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.
*/ */
public var enabledLeftView: Bool = true { public var enabledLeftView: Bool = false {
didSet { didSet {
if enabledLeftView { if enabledLeftView {
prepareGestures(&panGesture, panSelector: "handlePanGesture:", tap: &tapGesture, tapSelector: "handleTapGesture:") prepareGestures(panSelector: "handlePanGesture:", tapSelector: "handleTapGesture:")
} else if !enabledRightView { } else if !enabledRightView {
removeGestures(&panGesture, tap: &tapGesture) removeGestures()
} }
} }
} }
...@@ -210,12 +214,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -210,12 +214,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
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.
*/ */
public var enabledRightView: Bool = true { public var enabledRightView: Bool = false {
didSet { didSet {
if enabledRightView { if enabledRightView {
prepareGestures(&panGesture, panSelector: "handlePanGesture:", tap: &tapGesture, tapSelector: "handleTapGesture:") prepareGestures(panSelector: "handlePanGesture:", tapSelector: "handleTapGesture:")
} else if !enabledLeftView { } else if !enabledLeftView {
removeGestures(&panGesture, tap: &tapGesture) removeGestures()
} }
} }
} }
...@@ -364,12 +368,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -364,12 +368,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
options: options, options: options,
animations: animations, animations: animations,
completion: { [unowned self] (result: Bool) in completion: { [unowned self] (result: Bool) in
self.mainViewController.removeFromParentViewController()
toViewController.didMoveToParentViewController(self) toViewController.didMoveToParentViewController(self)
self.mainViewController.removeFromParentViewController()
self.mainViewController = toViewController self.mainViewController = toViewController
self.userInteractionEnabled = !self.opened self.userInteractionEnabled = !self.opened
completion?(result) completion?(result)
}) })
} }
/** /**
...@@ -735,7 +739,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -735,7 +739,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
prepareRightView() prepareRightView()
prepareLeftViewController() prepareLeftViewController()
prepareRightViewController() prepareRightViewController()
prepareGestures(&panGesture, panSelector: "handlePanGesture:", tap: &tapGesture, tapSelector: "handleTapGesture:") enabled = true
} }
/// A method that prepares the mainViewController. /// A method that prepares the mainViewController.
...@@ -819,48 +823,38 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -819,48 +823,38 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/** /**
A method that prepares the gestures used within the A method that prepares the gestures used within the
SideNavigationViewController. SideNavigationViewController.
- Parameter pan: A UIPanGestureRecognizer that is used to
recognize pan gestures.
- Parameter panSelector: A Selector that is fired when the - Parameter panSelector: A Selector that is fired when the
pan gesture is recognized. pan gesture is recognized.
- Parameter tap: A UITapGestureRecognizer that is used to
recognize tap gestures.
- Parameter tapSelector: A Selector that is fired when the - Parameter tapSelector: A Selector that is fired when the
tap gesture is recognized. tap gesture is recognized.
*/ */
private func prepareGestures(inout pan: UIPanGestureRecognizer?, panSelector: Selector, inout tap: UITapGestureRecognizer?, tapSelector: Selector) { private func prepareGestures(panSelector panSelector: Selector, tapSelector: Selector) {
removeGestures(&panGesture, tap: &tapGesture) if nil == panGesture {
panGesture = UIPanGestureRecognizer(target: self, action: panSelector)
if nil == pan { panGesture!.delegate = self
pan = UIPanGestureRecognizer(target: self, action: panSelector) view.addGestureRecognizer(panGesture!)
pan!.delegate = self
view.addGestureRecognizer(pan!)
} }
if nil == tap { if nil == tapGesture {
tap = UITapGestureRecognizer(target: self, action: tapSelector) tapGesture = UITapGestureRecognizer(target: self, action: tapSelector)
tap!.cancelsTouchesInView = false tapGesture!.cancelsTouchesInView = false
tap!.delegate = self tapGesture!.delegate = self
view.addGestureRecognizer(tap!) view.addGestureRecognizer(tapGesture!)
} }
} }
/** /**
A method that removes the passed in pan and tap gesture A method that removes the passed in pan and tap gesture
recognizers. recognizers.
- Parameter pan: A UIPanGestureRecognizer that should be
removed from the SideNavigationViewController.
- Parameter tap: A UITapGestureRecognizer that should be
removed from the SideNavigationViewController.
*/ */
private func removeGestures(inout pan: UIPanGestureRecognizer?, inout tap: UITapGestureRecognizer?) { private func removeGestures() {
if let v: UIPanGestureRecognizer = pan { if let v: UIPanGestureRecognizer = panGesture {
view.removeGestureRecognizer(v) view.removeGestureRecognizer(v)
pan = nil panGesture = nil
} }
if let v: UITapGestureRecognizer = tap { if let v: UITapGestureRecognizer = tapGesture {
view.removeGestureRecognizer(v) view.removeGestureRecognizer(v)
tap = nil tapGesture = nil
} }
} }
......
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