Commit 888f717c by Daniel Dahan

added delegation examples to Example SideNav app

parent fd4d8871
...@@ -70,6 +70,7 @@ class MainViewController: UIViewController { ...@@ -70,6 +70,7 @@ class MainViewController: UIViewController {
the MainViewController and SideViewController. the MainViewController and SideViewController.
*/ */
sideNavigationViewController?.setLeftViewWidth(view.bounds.width - 88, hidden: true, animated: false) sideNavigationViewController?.setLeftViewWidth(view.bounds.width - 88, hidden: true, animated: false)
sideNavigationViewController?.delegate = self
} }
/** /**
...@@ -248,3 +249,70 @@ extension MainViewController: UITableViewDelegate { ...@@ -248,3 +249,70 @@ extension MainViewController: UITableViewDelegate {
return 48 return 48
} }
} }
/// SideNavigationViewControllerDelegate methods.
extension MainViewController: SideNavigationViewControllerDelegate {
/**
An optional delegation method that is fired before the
SideNavigationViewController opens.
*/
func sideNavigationViewWillOpen(sideNavigationViewController: SideNavigationViewController, position: SideNavigationPosition) {
print("Will open", .Left == position ? "Left" : "Right", "view.")
}
/**
An optional delegation method that is fired after the
SideNavigationViewController opened.
*/
func sideNavigationViewDidOpen(sideNavigationViewController: SideNavigationViewController, position: SideNavigationPosition) {
print("Did open", .Left == position ? "Left" : "Right", "view.")
}
/**
An optional delegation method that is fired before the
SideNavigationViewController closes.
*/
func sideNavigationViewWillClose(sideNavigationViewController: SideNavigationViewController, position: SideNavigationPosition) {
print("Will close", .Left == position ? "Left" : "Right", "view.")
}
/**
An optional delegation method that is fired after the
SideNavigationViewController closed.
*/
func sideNavigationViewDidClose(sideNavigationViewController: SideNavigationViewController, position: SideNavigationPosition) {
print("Did close", .Left == position ? "Left" : "Right", "view.")
}
/**
An optional delegation method that is fired when the
SideNavigationViewController pan gesture begins.
*/
func sideNavigationViewPanDidBegin(sideNavigationViewController: SideNavigationViewController, point: CGPoint, position: SideNavigationPosition) {
print("Pan did begin for", .Left == position ? "Left" : "Right", "view.")
}
/**
An optional delegation method that is fired when the
SideNavigationViewController pan gesture changes position.
*/
func sideNavigationViewPanDidChange(sideNavigationViewController: SideNavigationViewController, point: CGPoint, position: SideNavigationPosition) {
print("Pan did change for", .Left == position ? "Left" : "Right", "view.")
}
/**
An optional delegation method that is fired when the
SideNavigationViewController pan gesture ends.
*/
func sideNavigationViewPanDidEnd(sideNavigationViewController: SideNavigationViewController, point: CGPoint, position: SideNavigationPosition) {
print("Pan did end for", .Left == position ? "Left" : "Right", "view.")
}
/**
An optional delegation method that is fired when the
SideNavigationViewController tap gesture begins.
*/
func sideNavigationViewDidTap(sideNavigationViewController: SideNavigationViewController, point: CGPoint, position: SideNavigationPosition) {
print("Did Tap for", .Left == position ? "Left" : "Right", "view.")
}
}
...@@ -740,16 +740,20 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -740,16 +740,20 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
passed to the handler when recognized. passed to the handler when recognized.
*/ */
internal func handleTapGesture(recognizer: UITapGestureRecognizer) { internal func handleTapGesture(recognizer: UITapGestureRecognizer) {
if let v: MaterialView = leftView { if openedLeftView {
delegate?.sideNavigationViewDidTap?(self, point: recognizer.locationInView(view), position: .Left) if let v: MaterialView = leftView {
if enabledLeftView && openedLeftView && !isPointContainedWithinView(v, point: recognizer.locationInView(v)) { delegate?.sideNavigationViewDidTap?(self, point: recognizer.locationInView(view), position: .Left)
closeLeftView() if enabledLeftView && openedLeftView && !isPointContainedWithinView(v, point: recognizer.locationInView(v)) {
closeLeftView()
}
} }
} }
if let v: MaterialView = rightView { if openedRightView {
delegate?.sideNavigationViewDidTap?(self, point: recognizer.locationInView(view), position: .Right) if let v: MaterialView = rightView {
if enabledRightView && openedRightView && !isPointContainedWithinView(v, point: recognizer.locationInView(v)) { delegate?.sideNavigationViewDidTap?(self, point: recognizer.locationInView(view), position: .Right)
closeRightView() if enabledRightView && openedRightView && !isPointContainedWithinView(v, point: recognizer.locationInView(v)) {
closeRightView()
}
} }
} }
} }
......
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