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
2c261067
Unverified
Commit
2c261067
authored
Dec 30, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated NavigationDrawerController internals alongside BottomSheetController
parent
ffaaea85
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
67 deletions
+67
-67
Sources/iOS/BottomSheetController.swift
+36
-36
Sources/iOS/NavigationDrawerController.swift
+31
-31
No files found.
Sources/iOS/BottomSheetController.swift
View file @
2c261067
...
...
@@ -148,7 +148,7 @@ open class BottomSheetController: RootController {
A CGFloat property that is used internally to track
the original (x) position of the container view when panning.
*/
fileprivate
var
original
X
:
CGFloat
=
0
fileprivate
var
original
Y
:
CGFloat
=
0
/**
A UIPanGestureRecognizer property internally used for the
...
...
@@ -261,7 +261,7 @@ open class BottomSheetController: RootController {
guard
nil
!=
bottomView
else
{
return
false
}
return
bottomView
!.
x
!=
-
bottomView
Width
return
bottomView
!.
x
!=
-
bottomView
Height
}
/**
...
...
@@ -275,7 +275,7 @@ open class BottomSheetController: RootController {
opens up to.
*/
@IBInspectable
open
fileprivate
(
set
)
var
bottomView
Width
:
CGFloat
!
open
fileprivate
(
set
)
var
bottomView
Height
:
CGFloat
!
/**
An initializer that initializes the object with a NSCoder object.
...
...
@@ -314,17 +314,17 @@ open class BottomSheetController: RootController {
return
}
v
.
width
=
bottomViewW
idth
v
.
height
=
view
.
bounds
.
h
eight
bottomViewThreshold
=
bottomView
Width
/
2
v
.
width
=
view
.
bounds
.
w
idth
v
.
height
=
bottomViewH
eight
bottomViewThreshold
=
bottomView
Height
/
2
guard
let
vc
=
bottomViewController
else
{
return
}
vc
.
view
.
width
=
v
.
width
vc
.
view
.
height
=
v
.
height
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
width
/
2
,
y
:
v
.
height
/
2
)
vc
.
view
.
width
=
v
.
bounds
.
width
vc
.
view
.
height
=
v
.
bounds
.
height
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
bounds
.
width
/
2
,
y
:
v
.
bounds
.
height
/
2
)
}
/**
...
...
@@ -354,14 +354,14 @@ open class BottomSheetController: RootController {
return
}
bottomView
Width
=
width
bottomView
Height
=
width
if
animated
{
v
.
isShadowPathAutoSizing
=
false
if
isHidden
{
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -369,7 +369,7 @@ open class BottomSheetController: RootController {
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
-
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
})
{
[
weak
self
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -380,7 +380,7 @@ open class BottomSheetController: RootController {
}
}
else
{
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -388,7 +388,7 @@ open class BottomSheetController: RootController {
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
width
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
})
{
[
weak
self
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -403,7 +403,7 @@ open class BottomSheetController: RootController {
if
isHidden
{
hideView
(
container
:
v
)
v
.
position
.
x
=
-
v
.
width
/
2
v
.
position
.
x
=
-
v
.
bounds
.
width
/
2
rootViewController
.
view
.
alpha
=
1
}
else
{
v
.
isShadowPathAutoSizing
=
false
...
...
@@ -456,7 +456,7 @@ open class BottomSheetController: RootController {
return
}
v
.
position
.
x
=
v
.
width
/
2
v
.
position
.
y
=
-
v
.
bounds
.
height
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
})
{
[
weak
self
]
_
in
guard
let
s
=
self
else
{
...
...
@@ -487,14 +487,14 @@ open class BottomSheetController: RootController {
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
willClose
:
.
left
)
UIView
.
animate
(
withDuration
:
TimeInterval
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
return
}
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
return
}
v
.
position
.
x
=
-
v
.
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
})
{
[
weak
self
]
_
in
v
.
position
.
y
=
v
.
bounds
.
height
/
2
s
.
rootViewController
.
view
.
alpha
=
1
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -595,14 +595,14 @@ extension BottomSheetController {
isBottomViewEnabled
=
true
bottomView
Width
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
bottomView
Height
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
bottomView
=
UIView
()
bottomView
!.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
bottomViewWidth
,
height
:
view
.
h
eight
)
bottomView
!.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
view
.
bounds
.
width
,
height
:
bottomViewH
eight
)
bottomView
!.
backgroundColor
=
nil
view
.
addSubview
(
bottomView
!
)
bottomView
!.
isHidden
=
true
bottomView
!.
position
.
x
=
-
bottomViewWidth
/
2
bottomView
!.
position
.
y
=
-
bottomViewHeight
/
2
bottomView
!.
zPosition
=
2000
prepareBottomViewController
()
}
...
...
@@ -672,30 +672,30 @@ extension BottomSheetController: UIGestureRecognizerDelegate {
// Animate the panel.
switch
recognizer
.
state
{
case
.
began
:
original
X
=
v
.
position
.
x
original
Y
=
v
.
position
.
y
showView
(
container
:
v
)
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
didBeginPanAt
:
point
,
position
:
.
left
)
case
.
changed
:
let
w
=
v
.
width
let
translation
X
=
recognizer
.
translation
(
in
:
v
)
.
x
let
y
=
v
.
bounds
.
height
let
translation
Y
=
recognizer
.
translation
(
in
:
v
)
.
y
v
.
position
.
x
=
originalX
+
translationX
>
(
w
/
2
)
?
(
w
/
2
)
:
originalX
+
translationX
v
.
position
.
y
=
originalY
-
translationY
>
(
y
/
2
)
?
(
y
/
2
)
:
originalY
-
translationY
let
a
=
1
-
v
.
position
.
x
/
v
.
width
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
position
.
x
<=
v
.
width
/
2
?
a
:
0.5
let
a
=
1
-
v
.
position
.
y
/
v
.
bounds
.
height
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
position
.
y
<=
v
.
bounds
.
height
/
2
?
a
:
0.5
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
didChangePanAt
:
point
,
position
:
.
left
)
case
.
ended
,
.
cancelled
,
.
failed
:
let
p
=
recognizer
.
velocity
(
in
:
recognizer
.
view
)
let
x
=
p
.
x
>=
1000
||
p
.
x
<=
-
1000
?
p
.
x
:
0
let
y
=
p
.
y
>=
1000
||
p
.
y
<=
-
1000
?
p
.
y
:
0
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
didEndPanAt
:
point
,
position
:
.
left
)
if
v
.
x
<=
-
bottomViewWidth
+
bottomViewThreshold
||
x
<
-
1000
{
closeBottomView
(
velocity
:
x
)
if
v
.
y
<=
-
bottomViewHeight
+
bottomViewThreshold
||
y
<
-
1000
{
closeBottomView
(
velocity
:
y
)
}
else
{
openBottomView
(
velocity
:
x
)
openBottomView
(
velocity
:
y
)
}
case
.
possible
:
break
}
...
...
Sources/iOS/NavigationDrawerController.swift
View file @
2c261067
...
...
@@ -436,9 +436,9 @@ open class NavigationDrawerController: RootController {
v
.
height
=
view
.
bounds
.
height
leftViewThreshold
=
leftViewWidth
/
2
if
let
vc
=
leftViewController
{
vc
.
view
.
width
=
v
.
width
vc
.
view
.
height
=
v
.
height
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
width
/
2
,
y
:
v
.
height
/
2
)
vc
.
view
.
width
=
v
.
bounds
.
width
vc
.
view
.
height
=
v
.
bounds
.
height
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
bounds
.
width
/
2
,
y
:
v
.
bounds
.
height
/
2
)
}
}
...
...
@@ -447,9 +447,9 @@ open class NavigationDrawerController: RootController {
v
.
height
=
view
.
bounds
.
height
rightViewThreshold
=
view
.
bounds
.
width
-
rightViewWidth
/
2
if
let
vc
=
rightViewController
{
vc
.
view
.
width
=
v
.
width
vc
.
view
.
height
=
v
.
height
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
width
/
2
,
y
:
v
.
height
/
2
)
vc
.
view
.
width
=
v
.
bounds
.
width
vc
.
view
.
height
=
v
.
bounds
.
height
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
bounds
.
width
/
2
,
y
:
v
.
bounds
.
height
/
2
)
}
}
}
...
...
@@ -461,7 +461,7 @@ open class NavigationDrawerController: RootController {
return
}
v
.
position
.
x
=
size
.
width
+
(
isRightViewOpened
?
-
v
.
width
:
v
.
width
)
/
2
v
.
position
.
x
=
size
.
width
+
(
isRightViewOpened
?
-
v
.
bounds
.
width
:
v
.
bounds
.
width
)
/
2
}
/**
...
...
@@ -506,7 +506,7 @@ open class NavigationDrawerController: RootController {
if
hide
{
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -514,7 +514,7 @@ open class NavigationDrawerController: RootController {
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
-
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
})
{
[
weak
self
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -525,7 +525,7 @@ open class NavigationDrawerController: RootController {
}
}
else
{
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -533,7 +533,7 @@ open class NavigationDrawerController: RootController {
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
width
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
})
{
[
weak
self
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -548,7 +548,7 @@ open class NavigationDrawerController: RootController {
if
hide
{
hideView
(
container
:
v
)
v
.
position
.
x
=
-
v
.
width
/
2
v
.
position
.
x
=
-
v
.
bounds
.
width
/
2
rootViewController
.
view
.
alpha
=
1
}
else
{
v
.
isShadowPathAutoSizing
=
false
...
...
@@ -591,7 +591,7 @@ open class NavigationDrawerController: RootController {
if
hide
{
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -599,7 +599,7 @@ open class NavigationDrawerController: RootController {
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
s
.
view
.
bounds
.
width
+
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
})
{
[
weak
self
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -610,7 +610,7 @@ open class NavigationDrawerController: RootController {
}
}
else
{
UIView
.
animate
(
withDuration
:
duration
,
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -618,7 +618,7 @@ open class NavigationDrawerController: RootController {
v
.
bounds
.
size
.
width
=
width
v
.
position
.
x
=
s
.
view
.
bounds
.
width
-
width
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
})
{
[
weak
self
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -633,7 +633,7 @@ open class NavigationDrawerController: RootController {
if
hide
{
hideView
(
container
:
v
)
v
.
position
.
x
=
view
.
bounds
.
width
+
v
.
width
/
2
v
.
position
.
x
=
view
.
bounds
.
width
+
v
.
bounds
.
width
/
2
rootViewController
.
view
.
alpha
=
1
}
else
{
v
.
isShadowPathAutoSizing
=
false
...
...
@@ -698,7 +698,7 @@ open class NavigationDrawerController: RootController {
return
}
v
.
position
.
x
=
v
.
width
/
2
v
.
position
.
x
=
v
.
bounds
.
width
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
})
{
[
weak
self
]
_
in
guard
let
s
=
self
else
{
...
...
@@ -737,7 +737,7 @@ open class NavigationDrawerController: RootController {
return
}
v
.
position
.
x
=
s
.
view
.
bounds
.
width
-
v
.
width
/
2
v
.
position
.
x
=
s
.
view
.
bounds
.
width
-
v
.
bounds
.
width
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
})
{
[
weak
self
]
_
in
guard
let
s
=
self
else
{
...
...
@@ -773,9 +773,9 @@ open class NavigationDrawerController: RootController {
return
}
v
.
position
.
x
=
-
v
.
width
/
2
v
.
position
.
x
=
-
v
.
bounds
.
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
})
{
[
weak
self
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -812,9 +812,9 @@ open class NavigationDrawerController: RootController {
return
}
v
.
position
.
x
=
s
.
view
.
bounds
.
width
+
v
.
width
/
2
v
.
position
.
x
=
s
.
view
.
bounds
.
width
+
v
.
bounds
.
width
/
2
s
.
rootViewController
.
view
.
alpha
=
1
})
{
[
weak
self
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
@@ -1021,7 +1021,7 @@ extension NavigationDrawerController {
leftViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
leftView
=
UIView
()
leftView
!.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
leftViewWidth
,
height
:
view
.
height
)
leftView
!.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
leftViewWidth
,
height
:
view
.
bounds
.
height
)
leftView
!.
backgroundColor
=
nil
view
.
addSubview
(
leftView
!
)
...
...
@@ -1041,7 +1041,7 @@ extension NavigationDrawerController {
rightViewWidth
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
rightView
=
UIView
()
rightView
!.
frame
=
CGRect
(
x
:
view
.
width
,
y
:
0
,
width
:
rightViewWidth
,
height
:
view
.
height
)
rightView
!.
frame
=
CGRect
(
x
:
view
.
bounds
.
width
,
y
:
0
,
width
:
rightViewWidth
,
height
:
view
.
bounds
.
height
)
rightView
!.
backgroundColor
=
nil
view
.
addSubview
(
rightView
!
)
...
...
@@ -1152,13 +1152,13 @@ extension NavigationDrawerController: UIGestureRecognizerDelegate {
delegate
?
.
navigationDrawerController
?(
navigationDrawerController
:
self
,
didBeginPanAt
:
point
,
position
:
.
left
)
case
.
changed
:
let
w
=
v
.
width
let
w
=
v
.
bounds
.
width
let
translationX
=
recognizer
.
translation
(
in
:
v
)
.
x
v
.
position
.
x
=
originalX
+
translationX
>
(
w
/
2
)
?
(
w
/
2
)
:
originalX
+
translationX
let
a
=
1
-
v
.
position
.
x
/
v
.
width
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
position
.
x
<=
v
.
width
/
2
?
a
:
0.5
let
a
=
1
-
v
.
position
.
x
/
v
.
bounds
.
width
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
position
.
x
<=
v
.
bounds
.
width
/
2
?
a
:
0.5
if
translationX
>=
leftThreshold
{
hideStatusBar
()
...
...
@@ -1206,13 +1206,13 @@ extension NavigationDrawerController: UIGestureRecognizerDelegate {
delegate
?
.
navigationDrawerController
?(
navigationDrawerController
:
self
,
didBeginPanAt
:
point
,
position
:
.
right
)
case
.
changed
:
let
w
=
v
.
width
let
w
=
v
.
bounds
.
width
let
translationX
=
recognizer
.
translation
(
in
:
v
)
.
x
v
.
position
.
x
=
originalX
+
translationX
<
view
.
bounds
.
width
-
(
w
/
2
)
?
view
.
bounds
.
width
-
(
w
/
2
)
:
originalX
+
translationX
let
a
=
1
-
(
view
.
bounds
.
width
-
v
.
position
.
x
)
/
v
.
width
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
position
.
x
>=
v
.
width
/
2
?
a
:
0.5
let
a
=
1
-
(
view
.
bounds
.
width
-
v
.
position
.
x
)
/
v
.
bounds
.
width
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
position
.
x
>=
v
.
bounds
.
width
/
2
?
a
:
0.5
if
translationX
<=
-
rightThreshold
{
hideStatusBar
()
...
...
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