Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
888f717c
Commit
888f717c
authored
Jan 30, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added delegation examples to Example SideNav app
parent
fd4d8871
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
8 deletions
+80
-8
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/MainViewController.swift
+68
-0
Sources/SideNavigationViewController.swift
+12
-8
No files found.
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/MainViewController.swift
View file @
888f717c
...
@@ -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."
)
}
}
Sources/SideNavigationViewController.swift
View file @
888f717c
...
@@ -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
()
}
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment