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
1236e286
Unverified
Commit
1236e286
authored
Jan 01, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: BottomSheetController open and close methods working
parent
2c261067
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
40 deletions
+40
-40
Sources/iOS/BottomSheetController.swift
+32
-32
Sources/iOS/NavigationDrawerController.swift
+8
-8
No files found.
Sources/iOS/BottomSheetController.swift
View file @
1236e286
...
@@ -258,10 +258,10 @@ open class BottomSheetController: RootController {
...
@@ -258,10 +258,10 @@ open class BottomSheetController: RootController {
/// indicates if the bottomView is opened.
/// indicates if the bottomView is opened.
open
var
isBottomViewOpened
:
Bool
{
open
var
isBottomViewOpened
:
Bool
{
guard
nil
!
=
bottomView
else
{
guard
let
v
=
bottomView
else
{
return
false
return
false
}
}
return
bottomView
!.
x
!=
-
bottomViewH
eight
return
v
.
y
!=
Screen
.
h
eight
}
}
/**
/**
...
@@ -316,15 +316,15 @@ open class BottomSheetController: RootController {
...
@@ -316,15 +316,15 @@ open class BottomSheetController: RootController {
v
.
width
=
view
.
bounds
.
width
v
.
width
=
view
.
bounds
.
width
v
.
height
=
bottomViewHeight
v
.
height
=
bottomViewHeight
bottomViewThreshold
=
bottomViewHeight
/
2
bottomViewThreshold
=
view
.
bounds
.
height
-
bottomViewHeight
/
2
guard
let
vc
=
bottomViewController
else
{
guard
let
vc
=
bottomViewController
else
{
return
return
}
}
vc
.
view
.
width
=
v
.
bounds
.
width
vc
.
view
.
width
=
v
.
bounds
.
width
vc
.
view
.
height
=
v
.
bounds
.
h
eight
vc
.
view
.
height
=
bottomViewH
eight
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
bounds
.
width
/
2
,
y
:
v
.
bounds
.
h
eight
/
2
)
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
bounds
.
width
/
2
,
y
:
bottomViewH
eight
/
2
)
}
}
/**
/**
...
@@ -349,12 +349,12 @@ open class BottomSheetController: RootController {
...
@@ -349,12 +349,12 @@ open class BottomSheetController: RootController {
- Parameter animated: A Boolean value that indicates to animate
- Parameter animated: A Boolean value that indicates to animate
the bottomView width change.
the bottomView width change.
*/
*/
open
func
setBottomViewHeight
(
width
:
CGFloat
,
isHidden
:
Bool
,
animated
:
Bool
,
duration
:
TimeInterval
=
0.5
)
{
open
func
setBottomViewHeight
(
height
:
CGFloat
,
isHidden
:
Bool
,
animated
:
Bool
,
duration
:
TimeInterval
=
0.5
)
{
guard
let
v
=
bottomView
else
{
guard
let
v
=
bottomView
else
{
return
return
}
}
bottomViewHeight
=
width
bottomViewHeight
=
height
if
animated
{
if
animated
{
v
.
isShadowPathAutoSizing
=
false
v
.
isShadowPathAutoSizing
=
false
...
@@ -366,8 +366,8 @@ open class BottomSheetController: RootController {
...
@@ -366,8 +366,8 @@ open class BottomSheetController: RootController {
return
return
}
}
v
.
bounds
.
size
.
width
=
width
v
.
bounds
.
size
.
height
=
height
v
.
position
.
x
=
-
width
/
2
v
.
position
.
y
=
-
height
/
2
s
.
rootViewController
.
view
.
alpha
=
1
s
.
rootViewController
.
view
.
alpha
=
1
})
{
[
weak
self
,
v
=
v
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
...
@@ -385,8 +385,8 @@ open class BottomSheetController: RootController {
...
@@ -385,8 +385,8 @@ open class BottomSheetController: RootController {
return
return
}
}
v
.
bounds
.
size
.
width
=
width
v
.
bounds
.
size
.
height
=
height
v
.
position
.
x
=
width
/
2
v
.
position
.
y
=
height
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
s
.
rootViewController
.
view
.
alpha
=
0.5
})
{
[
weak
self
,
v
=
v
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
...
@@ -399,17 +399,17 @@ open class BottomSheetController: RootController {
...
@@ -399,17 +399,17 @@ open class BottomSheetController: RootController {
}
}
}
}
}
else
{
}
else
{
v
.
bounds
.
size
.
width
=
width
v
.
bounds
.
size
.
height
=
height
if
isHidden
{
if
isHidden
{
hideView
(
container
:
v
)
hideView
(
container
:
v
)
v
.
position
.
x
=
-
v
.
bounds
.
width
/
2
v
.
position
.
y
=
-
v
.
bounds
.
height
/
2
rootViewController
.
view
.
alpha
=
1
rootViewController
.
view
.
alpha
=
1
}
else
{
}
else
{
v
.
isShadowPathAutoSizing
=
false
v
.
isShadowPathAutoSizing
=
false
showView
(
container
:
v
)
showView
(
container
:
v
)
v
.
position
.
x
=
width
/
2
v
.
position
.
y
=
height
/
2
rootViewController
.
view
.
alpha
=
0.5
rootViewController
.
view
.
alpha
=
0.5
v
.
isShadowPathAutoSizing
=
true
v
.
isShadowPathAutoSizing
=
true
}
}
...
@@ -448,22 +448,22 @@ open class BottomSheetController: RootController {
...
@@ -448,22 +448,22 @@ open class BottomSheetController: RootController {
isUserInteractionEnabled
=
false
isUserInteractionEnabled
=
false
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
willOpen
:
.
lef
t
)
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
willOpen
:
.
righ
t
)
UIView
.
animate
(
withDuration
:
TimeInterval
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
TimeInterval
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
y
/
velocity
)))),
animations
:
{
[
weak
self
,
v
=
v
]
in
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
v
.
position
.
y
=
-
v
.
bounds
.
height
/
2
v
.
position
.
y
=
s
.
view
.
bounds
.
height
-
v
.
bounds
.
height
/
2
s
.
rootViewController
.
view
.
alpha
=
0.5
s
.
rootViewController
.
view
.
alpha
=
0.5
})
{
[
weak
self
]
_
in
})
{
[
weak
self
]
_
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
s
.
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
s
,
didOpen
:
.
lef
t
)
s
.
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
s
,
didOpen
:
.
righ
t
)
}
}
}
}
...
@@ -486,13 +486,13 @@ open class BottomSheetController: RootController {
...
@@ -486,13 +486,13 @@ open class BottomSheetController: RootController {
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
willClose
:
.
left
)
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
willClose
:
.
left
)
UIView
.
animate
(
withDuration
:
TimeInterval
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
x
/
velocity
)))),
UIView
.
animate
(
withDuration
:
TimeInterval
(
0
==
velocity
?
animationDuration
:
fmax
(
0.1
,
fmin
(
1
,
Double
(
v
.
y
/
velocity
)))),
animations
:
{
[
weak
self
,
v
=
v
]
in
animations
:
{
[
weak
self
,
v
=
v
]
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
}
}
v
.
position
.
y
=
v
.
bounds
.
height
/
2
v
.
position
.
y
=
s
.
view
.
bounds
.
height
+
v
.
bounds
.
height
/
2
s
.
rootViewController
.
view
.
alpha
=
1
s
.
rootViewController
.
view
.
alpha
=
1
})
{
[
weak
self
,
v
=
v
]
_
in
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
...
@@ -541,7 +541,7 @@ open class BottomSheetController: RootController {
...
@@ -541,7 +541,7 @@ open class BottomSheetController: RootController {
otherwise.
otherwise.
*/
*/
fileprivate
func
isPointContainedWithinBottomThreshold
(
point
:
CGPoint
)
->
Bool
{
fileprivate
func
isPointContainedWithinBottomThreshold
(
point
:
CGPoint
)
->
Bool
{
return
point
.
x
<=
bottomThreshold
return
point
.
y
>=
view
.
bounds
.
height
-
bottomThreshold
}
}
/**
/**
...
@@ -598,11 +598,11 @@ extension BottomSheetController {
...
@@ -598,11 +598,11 @@ extension BottomSheetController {
bottomViewHeight
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
bottomViewHeight
=
.
phone
==
Device
.
userInterfaceIdiom
?
280
:
320
bottomView
=
UIView
()
bottomView
=
UIView
()
bottomView
!.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
view
.
bounds
.
width
,
height
:
bottomViewHeight
)
bottomView
!.
frame
=
CGRect
(
x
:
0
,
y
:
0
,
width
:
view
.
bounds
.
width
,
height
:
bottomViewHeight
)
bottomView
!.
backgroundColor
=
nil
bottomView
!.
backgroundColor
=
Color
.
green
.
base
view
.
addSubview
(
bottomView
!
)
view
.
addSubview
(
bottomView
!
)
bottomView
!.
isHidden
=
true
bottomView
!.
isHidden
=
true
bottomView
!.
position
.
y
=
-
bottomViewHeight
/
2
bottomView
!.
position
.
y
=
view
.
bounds
.
height
+
bottomViewHeight
/
2
bottomView
!.
zPosition
=
2000
bottomView
!.
zPosition
=
2000
prepareBottomViewController
()
prepareBottomViewController
()
}
}
...
@@ -659,7 +659,7 @@ extension BottomSheetController: UIGestureRecognizerDelegate {
...
@@ -659,7 +659,7 @@ extension BottomSheetController: UIGestureRecognizerDelegate {
*/
*/
@objc
@objc
fileprivate
func
handleBottomViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
fileprivate
func
handleBottomViewPanGesture
(
recognizer
:
UIPanGestureRecognizer
)
{
guard
isBottomViewEnabled
&&
(
isBottomViewOpened
||
isPointContainedWithinBottomThreshold
(
point
:
recognizer
.
location
(
in
:
view
)))
else
{
guard
isBottomViewEnabled
&&
(
isBottomViewOpened
&&
isPointContainedWithinBottomThreshold
(
point
:
recognizer
.
location
(
in
:
view
)))
else
{
return
return
}
}
...
@@ -675,24 +675,24 @@ extension BottomSheetController: UIGestureRecognizerDelegate {
...
@@ -675,24 +675,24 @@ extension BottomSheetController: UIGestureRecognizerDelegate {
originalY
=
v
.
position
.
y
originalY
=
v
.
position
.
y
showView
(
container
:
v
)
showView
(
container
:
v
)
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
didBeginPanAt
:
point
,
position
:
.
lef
t
)
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
didBeginPanAt
:
point
,
position
:
.
righ
t
)
case
.
changed
:
case
.
changed
:
let
y
=
v
.
bounds
.
height
let
h
=
v
.
bounds
.
height
let
translationY
=
recognizer
.
translation
(
in
:
v
)
.
y
let
translationY
=
recognizer
.
translation
(
in
:
v
)
.
y
v
.
position
.
y
=
originalY
-
translationY
>
(
y
/
2
)
?
(
y
/
2
)
:
originalY
-
translationY
v
.
position
.
y
=
originalY
+
translationY
<
view
.
bounds
.
height
-
(
h
/
2
)
?
view
.
bounds
.
height
-
(
h
/
2
)
:
originalY
+
translationY
let
a
=
1
-
v
.
position
.
y
/
v
.
bounds
.
height
let
a
=
1
-
(
view
.
bounds
.
height
-
v
.
position
.
y
)
/
v
.
bounds
.
height
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
position
.
y
<
=
v
.
bounds
.
height
/
2
?
a
:
0.5
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
position
.
y
>
=
v
.
bounds
.
height
/
2
?
a
:
0.5
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
didChangePanAt
:
point
,
position
:
.
lef
t
)
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
didChangePanAt
:
point
,
position
:
.
righ
t
)
case
.
ended
,
.
cancelled
,
.
failed
:
case
.
ended
,
.
cancelled
,
.
failed
:
let
p
=
recognizer
.
velocity
(
in
:
recognizer
.
view
)
let
p
=
recognizer
.
velocity
(
in
:
recognizer
.
view
)
let
y
=
p
.
y
>=
1000
||
p
.
y
<=
-
1000
?
p
.
y
:
0
let
y
=
p
.
y
>=
1000
||
p
.
y
<=
-
1000
?
p
.
y
:
0
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
didEndPanAt
:
point
,
position
:
.
lef
t
)
delegate
?
.
bottomSheetController
?(
bottomSheetController
:
self
,
didEndPanAt
:
point
,
position
:
.
righ
t
)
if
v
.
y
<=
-
bottomViewHeight
+
bottomViewThreshold
||
y
<
-
1000
{
if
v
.
y
>=
bottomViewThreshold
||
y
>
1000
{
closeBottomView
(
velocity
:
y
)
closeBottomView
(
velocity
:
y
)
}
else
{
}
else
{
openBottomView
(
velocity
:
y
)
openBottomView
(
velocity
:
y
)
...
...
Sources/iOS/NavigationDrawerController.swift
View file @
1236e286
...
@@ -334,18 +334,18 @@ open class NavigationDrawerController: RootController {
...
@@ -334,18 +334,18 @@ open class NavigationDrawerController: RootController {
/// indicates if the leftView is opened.
/// indicates if the leftView is opened.
open
var
isLeftViewOpened
:
Bool
{
open
var
isLeftViewOpened
:
Bool
{
guard
nil
!
=
leftView
else
{
guard
let
v
=
leftView
else
{
return
false
return
false
}
}
return
leftView
!
.
x
!=
-
leftViewWidth
return
v
.
x
!=
-
leftViewWidth
}
}
/// Indicates if the rightView is opened.
/// Indicates if the rightView is opened.
open
var
isRightViewOpened
:
Bool
{
open
var
isRightViewOpened
:
Bool
{
guard
nil
!
=
rightView
else
{
guard
let
v
=
rightView
else
{
return
false
return
false
}
}
return
rightView
!
.
x
!=
Screen
.
width
return
v
.
x
!=
Screen
.
width
}
}
/**
/**
...
@@ -436,9 +436,9 @@ open class NavigationDrawerController: RootController {
...
@@ -436,9 +436,9 @@ open class NavigationDrawerController: RootController {
v
.
height
=
view
.
bounds
.
height
v
.
height
=
view
.
bounds
.
height
leftViewThreshold
=
leftViewWidth
/
2
leftViewThreshold
=
leftViewWidth
/
2
if
let
vc
=
leftViewController
{
if
let
vc
=
leftViewController
{
vc
.
view
.
width
=
v
.
bounds
.
w
idth
vc
.
view
.
width
=
leftViewW
idth
vc
.
view
.
height
=
v
.
bounds
.
height
vc
.
view
.
height
=
v
.
bounds
.
height
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
bounds
.
w
idth
/
2
,
y
:
v
.
bounds
.
height
/
2
)
vc
.
view
.
center
=
CGPoint
(
x
:
leftViewW
idth
/
2
,
y
:
v
.
bounds
.
height
/
2
)
}
}
}
}
...
@@ -447,9 +447,9 @@ open class NavigationDrawerController: RootController {
...
@@ -447,9 +447,9 @@ open class NavigationDrawerController: RootController {
v
.
height
=
view
.
bounds
.
height
v
.
height
=
view
.
bounds
.
height
rightViewThreshold
=
view
.
bounds
.
width
-
rightViewWidth
/
2
rightViewThreshold
=
view
.
bounds
.
width
-
rightViewWidth
/
2
if
let
vc
=
rightViewController
{
if
let
vc
=
rightViewController
{
vc
.
view
.
width
=
v
.
bounds
.
w
idth
vc
.
view
.
width
=
rightViewW
idth
vc
.
view
.
height
=
v
.
bounds
.
height
vc
.
view
.
height
=
v
.
bounds
.
height
vc
.
view
.
center
=
CGPoint
(
x
:
v
.
bounds
.
w
idth
/
2
,
y
:
v
.
bounds
.
height
/
2
)
vc
.
view
.
center
=
CGPoint
(
x
:
rightViewW
idth
/
2
,
y
:
v
.
bounds
.
height
/
2
)
}
}
}
}
}
}
...
...
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