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
b5cc6a58
Commit
b5cc6a58
authored
Jan 28, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issue with tap gesture recognizer
parent
d7cb2f19
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
9 deletions
+40
-9
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/MainViewController.swift
+15
-1
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/RightViewController.swift
+3
-3
Sources/SideNavigationViewController.swift
+22
-5
No files found.
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/MainViewController.swift
View file @
b5cc6a58
...
...
@@ -44,7 +44,7 @@ private struct Item {
var
image
:
UIImage
?
}
class
MainViewController
:
UIViewController
{
class
MainViewController
:
UIViewController
,
SideNavigationViewControllerDelegate
{
/// A tableView used to display Bond entries.
private
let
tableView
:
UITableView
=
UITableView
()
...
...
@@ -70,6 +70,11 @@ class MainViewController: UIViewController {
the MainViewController and SideViewController.
*/
sideNavigationViewController
?
.
setLeftViewWidth
(
view
.
bounds
.
width
-
88
,
hidden
:
true
,
animated
:
false
)
sideNavigationViewController
?
.
delegate
=
self
}
func
sideNavigationViewDidTap
(
sideNavigationViewController
:
SideNavigationViewController
,
point
:
CGPoint
)
{
print
(
point
)
}
/**
...
...
@@ -80,6 +85,14 @@ class MainViewController: UIViewController {
sideNavigationViewController
?
.
openLeftView
()
}
/**
Handles the search button click, which opens the
SideNavigationViewController.
*/
func
handleSearchButton
()
{
sideNavigationViewController
?
.
openRightView
()
}
/// Prepares view.
private
func
prepareView
()
{
view
.
backgroundColor
=
MaterialColor
.
white
...
...
@@ -153,6 +166,7 @@ class MainViewController: UIViewController {
searchButton
.
setImage
(
img2
,
forState
:
.
Normal
)
searchButton
.
setImage
(
img2
,
forState
:
.
Highlighted
)
searchButton
.
tintColor
=
MaterialColor
.
cyan
.
darken4
searchButton
.
addTarget
(
self
,
action
:
"handleSearchButton"
,
forControlEvents
:
.
TouchUpInside
)
// Add searchButton to right side.
navigationBarView
.
rightButtons
=
[
searchButton
]
...
...
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/RightViewController.swift
View file @
b5cc6a58
...
...
@@ -53,13 +53,13 @@ class RightViewController: UIViewController {
super
.
viewDidLoad
()
prepareView
()
prepareItems
()
prepareProfileView
()
prepareTableView
()
//
prepareProfileView()
//
prepareTableView()
}
/// General preparation statements.
private
func
prepareView
()
{
view
.
backgroundColor
=
MaterialColor
.
clear
view
.
backgroundColor
=
MaterialColor
.
black
}
override
func
viewWillAppear
(
animated
:
Bool
)
{
...
...
Sources/SideNavigationViewController.swift
View file @
b5cc6a58
...
...
@@ -283,9 +283,12 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
public
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
if
let
v
:
MaterialView
=
leftView
{
MaterialAnimation
.
animationDisabled
{
[
unowned
self
]
in
self
.
backdropLayer
.
frame
=
self
.
view
.
bounds
}
if
let
v
:
MaterialView
=
leftView
{
MaterialAnimation
.
animationDisabled
{
[
unowned
self
]
in
v
.
width
=
self
.
leftViewWidth
v
.
height
=
self
.
view
.
bounds
.
height
}
...
...
@@ -294,6 +297,17 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
leftViewController
?
.
view
.
frame
.
size
.
height
=
v
.
height
leftViewController
?
.
view
.
center
=
CGPointMake
(
v
.
width
/
2
,
v
.
height
/
2
)
}
if
let
v
:
MaterialView
=
rightView
{
MaterialAnimation
.
animationDisabled
{
[
unowned
self
]
in
v
.
width
=
self
.
rightViewWidth
v
.
height
=
self
.
view
.
bounds
.
height
}
rightViewThreshold
=
rightViewWidth
/
2
rightViewController
?
.
view
.
frame
.
size
.
width
=
v
.
width
rightViewController
?
.
view
.
frame
.
size
.
height
=
v
.
height
rightViewController
?
.
view
.
center
=
CGPointMake
(
v
.
width
/
2
,
v
.
height
/
2
)
}
}
/**
...
...
@@ -521,7 +535,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
delegate
?
.
sideNavigationViewWillOpen
?(
self
)
MaterialAnimation
.
animateWithDuration
(
Double
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
v
.
position
=
CGPointMake
(
v
.
width
/
2
,
v
.
height
/
2
)
v
.
position
=
CGPointMake
(
-
v
.
width
/
2
,
v
.
height
/
2
)
})
{
[
unowned
self
]
in
self
.
userInteractionEnabled
=
false
self
.
showRightViewDepth
()
...
...
@@ -597,6 +611,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
passed to the handler when recognized.
*/
internal
func
handlePanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
if
enabled
{
switch
recognizer
.
state
{
case
.
Began
:
backdropLayer
.
hidden
=
false
...
...
@@ -626,6 +641,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
case
.
Possible
:
break
}
}
}
/**
A method that is fired when the tap gesture is recognized
...
...
@@ -646,6 +662,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
prepareLeftView
()
prepareRightView
()
prepareLeftViewController
()
prepareRightViewController
()
prepareGestures
(
&
panGesture
,
panSelector
:
"handlePanGesture:"
,
tap
:
&
tapGesture
,
tapSelector
:
"handleTapGesture:"
)
}
...
...
@@ -665,7 +682,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/// A method that prepares the rightViewController.
private
func
prepareRightViewController
()
{
if
let
v
:
MaterialView
=
lef
tView
{
if
let
v
:
MaterialView
=
righ
tView
{
rightViewController
?
.
view
.
clipsToBounds
=
true
prepareViewControllerWithinContainer
(
rightViewController
,
container
:
v
)
}
...
...
@@ -690,7 +707,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
private
func
prepareRightView
()
{
if
nil
!=
rightViewController
{
rightView
=
MaterialView
()
rightView
!.
frame
=
CGRectMake
(
0
,
0
,
rightViewWidth
,
view
.
frame
.
height
)
rightView
!.
frame
=
CGRectMake
(
view
.
bounds
.
width
,
0
,
rightViewWidth
,
view
.
frame
.
height
)
rightView
!.
backgroundColor
=
MaterialColor
.
clear
view
.
addSubview
(
leftView
!
)
...
...
@@ -746,7 +763,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
view
.
addGestureRecognizer
(
pan
!
)
}
if
nil
==
pan
{
if
nil
==
tap
{
tap
=
UITapGestureRecognizer
(
target
:
self
,
action
:
tapSelector
)
tap
!.
delegate
=
self
view
.
addGestureRecognizer
(
tap
!
)
...
...
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