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
7a577efb
Commit
7a577efb
authored
Jan 28, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tap working for left and right views
parent
a02d99b0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
5 deletions
+60
-5
Sources/SideNavigationViewController.swift
+60
-5
No files found.
Sources/SideNavigationViewController.swift
View file @
7a577efb
...
...
@@ -108,6 +108,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
private
var
originalPosition
:
CGPoint
=
CGPointZero
/**
A UIView property that is used internally to track
the currentView, either leftView or rightView.
*/
private
var
currentView
:
UIView
?
/**
A UIPanGestureRecognizer property internally used for the
pan gesture.
*/
...
...
@@ -178,9 +184,34 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
*/
public
var
enabled
:
Bool
=
true
{
didSet
{
if
enabled
{
enabledLeftView
=
enabled
enabledRightView
=
enabled
}
}
/**
A Boolean property that enables and disables the leftView from
opening and closing. Defaults to true.
*/
public
var
enabledLeftView
:
Bool
=
true
{
didSet
{
if
enabledLeftView
{
prepareGestures
(
&
panGesture
,
panSelector
:
"handlePanGesture:"
,
tap
:
&
tapGesture
,
tapSelector
:
"handleTapGesture:"
)
}
else
{
}
else
if
!
enabledRightView
{
removeGestures
(
&
panGesture
,
tap
:
&
tapGesture
)
}
}
}
/**
A Boolean property that enables and disables the rightView from
opening and closing. Defaults to true.
*/
public
var
enabledRightView
:
Bool
=
true
{
didSet
{
if
enabledRightView
{
prepareGestures
(
&
panGesture
,
panSelector
:
"handlePanGesture:"
,
tap
:
&
tapGesture
,
tapSelector
:
"handleTapGesture:"
)
}
else
if
!
enabledLeftView
{
removeGestures
(
&
panGesture
,
tap
:
&
tapGesture
)
}
}
...
...
@@ -518,6 +549,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
leftView. Defaults to 0.
*/
public
func
openLeftView
(
velocity
:
CGFloat
=
0
)
{
if
enabledLeftView
{
toggleStatusBar
(
true
)
backdropLayer
.
hidden
=
false
...
...
@@ -533,6 +565,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
}
}
}
/**
A method that opens the rightView.
...
...
@@ -541,6 +574,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
leftView. Defaults to 0.
*/
public
func
openRightView
(
velocity
:
CGFloat
=
0
)
{
if
enabledRightView
{
toggleStatusBar
(
true
)
backdropLayer
.
hidden
=
false
...
...
@@ -556,6 +590,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
}
}
}
/**
A method that closes the leftView.
...
...
@@ -564,6 +599,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
leftView. Defaults to 0.
*/
public
func
closeLeftView
(
velocity
:
CGFloat
=
0
)
{
if
enabledLeftView
{
toggleStatusBar
(
false
)
backdropLayer
.
hidden
=
true
...
...
@@ -579,6 +615,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
}
}
}
/**
A method that closes the rightView.
...
...
@@ -587,6 +624,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
leftView. Defaults to 0.
*/
public
func
closeRightView
(
velocity
:
CGFloat
=
0
)
{
if
enabledRightView
{
toggleStatusBar
(
false
)
backdropLayer
.
hidden
=
true
...
...
@@ -602,18 +640,17 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
}
}
}
public
func
gestureRecognizer
(
gestureRecognizer
:
UIGestureRecognizer
,
shouldReceiveTouch
touch
:
UITouch
)
->
Bool
{
if
enabled
{
if
gestureRecognizer
==
panGesture
{
return
opened
||
enabled
&&
isPointContainedWithinLeftViewThreshold
(
touch
.
locationInView
(
view
))
return
opened
||
enabled
&&
(
isPointContainedWithinLeftViewThreshold
(
touch
.
locationInView
(
view
))
||
isPointContainedWithinRightViewThreshold
(
touch
.
locationInView
(
view
)
))
}
if
opened
&&
gestureRecognizer
==
tapGesture
{
let
point
:
CGPoint
=
touch
.
locationInView
(
view
)
delegate
?
.
sideNavigationViewDidTap
?(
self
,
point
:
point
)
return
!
isPointContainedWithinView
(
leftView
!
,
point
:
point
)
||
!
isPointContainedWithinView
(
rightView
!
,
point
:
point
)
}
}
return
false
}
...
...
@@ -627,6 +664,11 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
if
enabled
{
switch
recognizer
.
state
{
case
.
Began
:
if
!
opened
{
if
isPointContainedWithinLeftViewThreshold
(
recognizer
.
locationInView
(
view
))
{
}
}
backdropLayer
.
hidden
=
false
originalPosition
=
leftView
!.
position
toggleStatusBar
(
true
)
...
...
@@ -830,6 +872,19 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
A method that determines whether the passed point is
contained within the bounds of the rightViewThreshold
and height of the SideNavigationViewController view frame
property.
- Parameter point: A CGPoint to test against.
- Returns: A Boolean of the result, true if yes, false
otherwise.
*/
private
func
isPointContainedWithinRightViewThreshold
(
point
:
CGPoint
)
->
Bool
{
return
CGRectContainsPoint
(
CGRectMake
(
0
,
0
,
view
.
bounds
.
width
-
rightViewThreshold
,
view
.
frame
.
height
),
point
)
}
/**
A method that determines whether the passed in point is
contained within the bounds of the passed in container view.
- Parameter container: A UIView that sets the bounds to test
...
...
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