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
4b82cec3
Commit
4b82cec3
authored
Aug 27, 2015
by
adamdahan
Browse files
Options
Browse Files
Download
Plain Diff
issue-16: merging development
parents
56be7e2d
e3f48228
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
35 deletions
+19
-35
Source/SideNavController.swift
+19
-35
No files found.
Source/SideNavController.swift
View file @
4b82cec3
...
@@ -83,10 +83,10 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -83,10 +83,10 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
public
static
var
backdropViewContainerBackgroundColor
:
UIColor
=
.
blackColor
()
public
static
var
backdropViewContainerBackgroundColor
:
UIColor
=
.
blackColor
()
public
static
var
animationDuration
:
CGFloat
=
0.5
public
static
var
animationDuration
:
CGFloat
=
0.5
public
static
var
leftBezelWidth
:
CGFloat
=
16
public
static
var
leftBezelWidth
:
CGFloat
=
16
public
static
var
leftViewContainerWidth
:
CGFloat
=
2
7
0
public
static
var
leftViewContainerWidth
:
CGFloat
=
2
4
0
public
static
var
leftPanFromBezel
:
Bool
=
true
public
static
var
leftPanFromBezel
:
Bool
=
true
public
static
var
rightBezelWidth
:
CGFloat
=
16
public
static
var
rightBezelWidth
:
CGFloat
=
16
public
static
var
rightViewContainerWidth
:
CGFloat
=
2
7
0
public
static
var
rightViewContainerWidth
:
CGFloat
=
2
4
0
public
static
var
rightPanFromBezel
:
Bool
=
true
public
static
var
rightPanFromBezel
:
Bool
=
true
public
static
var
bottomBezelHeight
:
CGFloat
=
16
public
static
var
bottomBezelHeight
:
CGFloat
=
16
public
static
var
bottomViewContainerHeight
:
CGFloat
=
270
public
static
var
bottomViewContainerHeight
:
CGFloat
=
270
...
@@ -135,7 +135,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -135,7 +135,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
/**
/**
:name: isUserInteractionEnabled
:name: isUserInteractionEnabled
*/
*/
public
private(set)
var
isUserInteractionEnabled
:
Bool
{
public
var
isUserInteractionEnabled
:
Bool
{
get
{
get
{
return
mainViewContainer
!.
userInteractionEnabled
return
mainViewContainer
!.
userInteractionEnabled
}
}
...
@@ -276,8 +276,8 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -276,8 +276,8 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
self
.
init
()
self
.
init
()
self
.
mainViewController
=
mainViewController
self
.
mainViewController
=
mainViewController
self
.
leftViewController
=
leftViewController
self
.
leftViewController
=
leftViewController
setup
View
()
prepare
View
()
setup
LeftView
()
prepare
LeftView
()
}
}
/**
/**
...
@@ -287,8 +287,8 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -287,8 +287,8 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
self
.
init
()
self
.
init
()
self
.
mainViewController
=
mainViewController
self
.
mainViewController
=
mainViewController
self
.
rightViewController
=
rightViewController
self
.
rightViewController
=
rightViewController
setup
View
()
prepare
View
()
setup
RightView
()
prepare
RightView
()
}
}
/**
/**
...
@@ -310,9 +310,9 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -310,9 +310,9 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
self
.
mainViewController
=
mainViewController
self
.
mainViewController
=
mainViewController
self
.
leftViewController
=
leftViewController
self
.
leftViewController
=
leftViewController
self
.
rightViewController
=
rightViewController
self
.
rightViewController
=
rightViewController
setup
View
()
prepare
View
()
setup
LeftView
()
prepare
LeftView
()
setup
RightView
()
prepare
RightView
()
}
}
/**
/**
...
@@ -643,15 +643,15 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -643,15 +643,15 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
}
}
//
//
// :name:
setup
View
// :name:
prepare
View
//
//
internal
func
setup
View
()
{
internal
func
prepare
View
()
{
prepareMainContainer
()
prepareMainContainer
()
prepareBackdropContainer
()
prepareBackdropContainer
()
}
}
//
//
// :name:
setup
LeftView
// :name:
prepare
LeftView
//
//
internal
func
setupLeftView
()
{
internal
func
setupLeftView
()
{
prepareContainer
(
&
leftContainer
,
viewContainer
:
&
leftViewContainer
,
originX
:
leftOriginX
,
originY
:
0
,
width
:
options
.
leftViewContainerWidth
,
height
:
view
.
bounds
.
size
.
height
)
prepareContainer
(
&
leftContainer
,
viewContainer
:
&
leftViewContainer
,
originX
:
leftOriginX
,
originY
:
0
,
width
:
options
.
leftViewContainerWidth
,
height
:
view
.
bounds
.
size
.
height
)
...
@@ -659,7 +659,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -659,7 +659,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
}
}
//
//
// :name:
setup
RightView
// :name:
prepare
RightView
//
//
internal
func
setupRightView
()
{
internal
func
setupRightView
()
{
prepareContainer
(
&
rightContainer
,
viewContainer
:
&
rightViewContainer
,
originX
:
rightOriginX
,
originY
:
0
,
width
:
options
.
rightViewContainerWidth
,
height
:
view
.
bounds
.
size
.
height
)
prepareContainer
(
&
rightContainer
,
viewContainer
:
&
rightViewContainer
,
originX
:
rightOriginX
,
originY
:
0
,
width
:
options
.
rightViewContainerWidth
,
height
:
view
.
bounds
.
size
.
height
)
...
@@ -709,9 +709,9 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -709,9 +709,9 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
//
//
internal
func
handleLeftPanGesture
(
gesture
:
UIPanGestureRecognizer
)
{
internal
func
handleLeftPanGesture
(
gesture
:
UIPanGestureRecognizer
)
{
if
isRightContainerOpened
{
return
}
if
isRightContainerOpened
{
return
}
if
.
Began
==
gesture
.
state
{
if
let
vc
=
leftViewContainer
{
if
let
vc
=
leftViewContainer
{
if
let
c
=
leftContainer
{
if
let
c
=
leftContainer
{
if
.
Began
==
gesture
.
state
{
leftViewController
?
.
beginAppearanceTransition
(
!
isLeftContainerOpened
,
animated
:
true
)
leftViewController
?
.
beginAppearanceTransition
(
!
isLeftContainerOpened
,
animated
:
true
)
addShadow
(
&
leftViewContainer
)
addShadow
(
&
leftViewContainer
)
toggleWindow
(
shouldOpen
:
true
)
toggleWindow
(
shouldOpen
:
true
)
...
@@ -719,11 +719,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -719,11 +719,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
c
.
point
=
gesture
.
locationInView
(
view
)
c
.
point
=
gesture
.
locationInView
(
view
)
c
.
frame
=
vc
.
frame
c
.
frame
=
vc
.
frame
delegate
?
.
sideNavDidBeginLeftPan
?(
self
,
container
:
c
)
delegate
?
.
sideNavDidBeginLeftPan
?(
self
,
container
:
c
)
}
}
}
else
if
.
Changed
==
gesture
.
state
{
}
else
if
.
Changed
==
gesture
.
state
{
if
let
vc
=
leftViewContainer
{
if
let
c
=
leftContainer
{
c
.
point
=
gesture
.
translationInView
(
gesture
.
view
!
)
c
.
point
=
gesture
.
translationInView
(
gesture
.
view
!
)
let
r
=
(
vc
.
frame
.
origin
.
x
-
leftOriginX
)
/
vc
.
frame
.
size
.
width
let
r
=
(
vc
.
frame
.
origin
.
x
-
leftOriginX
)
/
vc
.
frame
.
size
.
width
let
s
:
CGFloat
=
1
-
(
1
-
options
.
contentViewScale
)
*
r
let
s
:
CGFloat
=
1
-
(
1
-
options
.
contentViewScale
)
*
r
...
@@ -732,11 +728,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -732,11 +728,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
backdropViewContainer
?
.
layer
.
opacity
=
Float
(
r
*
options
.
contentViewOpacity
)
backdropViewContainer
?
.
layer
.
opacity
=
Float
(
r
*
options
.
contentViewOpacity
)
mainViewContainer
?
.
transform
=
CGAffineTransformMakeScale
(
s
,
s
)
mainViewContainer
?
.
transform
=
CGAffineTransformMakeScale
(
s
,
s
)
delegate
?
.
sideNavDidChangeLeftPan
?(
self
,
container
:
c
)
delegate
?
.
sideNavDidChangeLeftPan
?(
self
,
container
:
c
)
}
}
}
else
{
}
else
{
if
let
vc
=
leftViewContainer
{
if
let
c
=
leftContainer
{
c
.
point
=
gesture
.
velocityInView
(
gesture
.
view
)
c
.
point
=
gesture
.
velocityInView
(
gesture
.
view
)
let
x
:
CGFloat
=
c
.
point
.
x
>=
1000
||
c
.
point
.
x
<=
-
1000
?
c
.
point
.
x
:
0
let
x
:
CGFloat
=
c
.
point
.
x
>=
1000
||
c
.
point
.
x
<=
-
1000
?
c
.
point
.
x
:
0
c
.
state
=
vc
.
frame
.
origin
.
x
<=
CGFloat
(
floor
(
leftOriginX
))
+
options
.
pointOfNoReturnWidth
||
c
.
point
.
x
<=
-
1000
?
.
Closed
:
.
Opened
c
.
state
=
vc
.
frame
.
origin
.
x
<=
CGFloat
(
floor
(
leftOriginX
))
+
options
.
pointOfNoReturnWidth
||
c
.
point
.
x
<=
-
1000
?
.
Closed
:
.
Opened
...
@@ -766,21 +758,17 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -766,21 +758,17 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
//
//
internal
func
handleRightPanGesture
(
gesture
:
UIPanGestureRecognizer
)
{
internal
func
handleRightPanGesture
(
gesture
:
UIPanGestureRecognizer
)
{
if
isLeftContainerOpened
{
return
}
if
isLeftContainerOpened
{
return
}
if
.
Began
==
gesture
.
state
{
if
let
vc
=
rightViewContainer
{
if
let
vc
=
rightViewContainer
{
if
let
c
=
rightContainer
{
if
let
c
=
rightContainer
{
if
.
Began
==
gesture
.
state
{
c
.
point
=
gesture
.
locationInView
(
view
)
c
.
state
=
isRightContainerOpened
?
.
Opened
:
.
Closed
c
.
frame
=
vc
.
frame
rightViewController
?
.
beginAppearanceTransition
(
!
isRightContainerOpened
,
animated
:
true
)
rightViewController
?
.
beginAppearanceTransition
(
!
isRightContainerOpened
,
animated
:
true
)
addShadow
(
&
rightViewContainer
)
addShadow
(
&
rightViewContainer
)
toggleWindow
(
shouldOpen
:
true
)
toggleWindow
(
shouldOpen
:
true
)
c
.
state
=
isRightContainerOpened
?
.
Opened
:
.
Closed
c
.
point
=
gesture
.
locationInView
(
view
)
c
.
frame
=
vc
.
frame
delegate
?
.
sideNavDidBeginRightPan
?(
self
,
container
:
c
)
delegate
?
.
sideNavDidBeginRightPan
?(
self
,
container
:
c
)
}
}
}
else
if
.
Changed
==
gesture
.
state
{
}
else
if
.
Changed
==
gesture
.
state
{
if
let
vc
=
rightViewContainer
{
if
let
c
=
rightContainer
{
c
.
point
=
gesture
.
translationInView
(
gesture
.
view
!
)
c
.
point
=
gesture
.
translationInView
(
gesture
.
view
!
)
let
r
=
(
rightOriginX
-
vc
.
frame
.
origin
.
x
)
/
vc
.
frame
.
size
.
width
let
r
=
(
rightOriginX
-
vc
.
frame
.
origin
.
x
)
/
vc
.
frame
.
size
.
width
let
s
:
CGFloat
=
1
-
(
1
-
options
.
contentViewScale
)
*
r
let
s
:
CGFloat
=
1
-
(
1
-
options
.
contentViewScale
)
*
r
...
@@ -790,11 +778,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
...
@@ -790,11 +778,7 @@ public class SideNavController: MaterialViewController, UIGestureRecognizerDeleg
backdropViewContainer
?
.
layer
.
opacity
=
Float
(
r
*
options
.
contentViewOpacity
)
backdropViewContainer
?
.
layer
.
opacity
=
Float
(
r
*
options
.
contentViewOpacity
)
mainViewContainer
?
.
transform
=
CGAffineTransformMakeScale
(
s
,
s
)
mainViewContainer
?
.
transform
=
CGAffineTransformMakeScale
(
s
,
s
)
delegate
?
.
sideNavDidChangeRightPan
?(
self
,
container
:
c
)
delegate
?
.
sideNavDidChangeRightPan
?(
self
,
container
:
c
)
}
}
}
else
{
}
else
{
if
let
vc
=
rightViewContainer
{
if
let
c
=
rightContainer
{
c
.
point
=
gesture
.
velocityInView
(
gesture
.
view
)
c
.
point
=
gesture
.
velocityInView
(
gesture
.
view
)
let
x
:
CGFloat
=
c
.
point
.
x
<=
-
1000
||
c
.
point
.
x
>=
1000
?
c
.
point
.
x
:
0
let
x
:
CGFloat
=
c
.
point
.
x
<=
-
1000
||
c
.
point
.
x
>=
1000
?
c
.
point
.
x
:
0
c
.
state
=
vc
.
frame
.
origin
.
x
>=
CGFloat
(
floor
(
rightOriginX
)
-
options
.
pointOfNoReturnWidth
)
||
c
.
point
.
x
>=
1000
?
.
Closed
:
.
Opened
c
.
state
=
vc
.
frame
.
origin
.
x
>=
CGFloat
(
floor
(
rightOriginX
)
-
options
.
pointOfNoReturnWidth
)
||
c
.
point
.
x
>=
1000
?
.
Closed
:
.
Opened
...
...
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