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
f30c239a
Unverified
Commit
f30c239a
authored
Jun 07, 2018
by
Daniel Dahan
Committed by
GitHub
Jun 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1052 from mumensh/master
Add option to enable/disable dim on rootViewController
parents
6703a405
04afbb10
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
16 deletions
+57
-16
Sources/iOS/NavigationDrawerController.swift
+57
-16
No files found.
Sources/iOS/NavigationDrawerController.swift
View file @
f30c239a
...
...
@@ -227,6 +227,29 @@ open class NavigationDrawerController: TransitionController {
}
/**
A Boolean property that enables and disabled the dim from
rootViewController. Defaults to true
*/
open
var
isDimEnabled
=
true
{
didSet
{
self
.
updateDim
()
}
}
/**
The alpha value of the rootViewController when left/right drawer
is presented, the value should be between 0.0 - 1.0. Defaults is 0.5
*/
open
var
dimAmount
:
CGFloat
=
0.5
{
didSet
{
if
dimAmount
<
0.0
||
dimAmount
>
1.0
{
dimAmount
=
0.5
}
self
.
updateDim
()
}
}
/**
A Boolean property that enables and disables the leftView from
opening and closing. Defaults to true.
*/
...
...
@@ -530,7 +553,7 @@ open class NavigationDrawerController: TransitionController {
v
.
bounds
.
size
.
width
=
width
v
.
layer
.
position
.
x
=
-
width
/
2
self
.
rootViewController
.
view
.
alpha
=
1
self
.
updateDim
()
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
`
self
`
=
self
else
{
...
...
@@ -551,7 +574,7 @@ open class NavigationDrawerController: TransitionController {
v
.
bounds
.
size
.
width
=
width
v
.
layer
.
position
.
x
=
width
/
2
self
.
rootViewController
.
view
.
alpha
=
0.5
self
.
updateDim
()
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
`
self
`
=
self
else
{
...
...
@@ -569,14 +592,14 @@ open class NavigationDrawerController: TransitionController {
if
hide
{
hideView
(
container
:
v
)
v
.
layer
.
position
.
x
=
-
v
.
bounds
.
width
/
2
rootViewController
.
view
.
alpha
=
1
}
else
{
showView
(
container
:
v
)
v
.
layer
.
position
.
x
=
width
/
2
rootViewController
.
view
.
alpha
=
0.5
}
self
.
updateDim
()
layoutSubviews
()
}
}
...
...
@@ -616,7 +639,7 @@ open class NavigationDrawerController: TransitionController {
v
.
bounds
.
size
.
width
=
width
v
.
layer
.
position
.
x
=
self
.
view
.
bounds
.
width
+
width
/
2
self
.
rootViewController
.
view
.
alpha
=
1
self
.
updateDim
()
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
`
self
`
=
self
else
{
...
...
@@ -637,7 +660,7 @@ open class NavigationDrawerController: TransitionController {
v
.
bounds
.
size
.
width
=
width
v
.
layer
.
position
.
x
=
self
.
view
.
bounds
.
width
-
width
/
2
self
.
rootViewController
.
view
.
alpha
=
0.5
self
.
updateDim
()
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
`
self
`
=
self
else
{
...
...
@@ -655,14 +678,13 @@ open class NavigationDrawerController: TransitionController {
if
hide
{
hideView
(
container
:
v
)
v
.
layer
.
position
.
x
=
view
.
bounds
.
width
+
v
.
bounds
.
width
/
2
rootViewController
.
view
.
alpha
=
1
}
else
{
showView
(
container
:
v
)
v
.
layer
.
position
.
x
=
view
.
bounds
.
width
-
width
/
2
rootViewController
.
view
.
alpha
=
0.5
}
self
.
updateDim
()
layoutSubviews
()
}
}
...
...
@@ -724,7 +746,7 @@ open class NavigationDrawerController: TransitionController {
}
v
.
layer
.
position
.
x
=
v
.
bounds
.
width
/
2
self
.
rootViewController
.
view
.
alpha
=
0.5
self
.
updateDim
()
})
{
[
weak
self
]
_
in
guard
let
`
self
`
=
self
else
{
...
...
@@ -771,7 +793,7 @@ open class NavigationDrawerController: TransitionController {
}
v
.
layer
.
position
.
x
=
self
.
view
.
bounds
.
width
-
v
.
bounds
.
width
/
2
self
.
rootViewController
.
view
.
alpha
=
0.5
self
.
updateDim
()
})
{
[
weak
self
]
_
in
guard
let
`
self
`
=
self
else
{
...
...
@@ -814,7 +836,7 @@ open class NavigationDrawerController: TransitionController {
}
v
.
layer
.
position
.
x
=
-
v
.
bounds
.
width
/
2
self
.
rootViewController
.
view
.
alpha
=
1
self
.
updateDim
()
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
`
self
`
=
self
else
{
...
...
@@ -861,7 +883,7 @@ open class NavigationDrawerController: TransitionController {
}
v
.
layer
.
position
.
x
=
self
.
view
.
bounds
.
width
+
v
.
bounds
.
width
/
2
self
.
rootViewController
.
view
.
alpha
=
1
self
.
updateDim
()
})
{
[
weak
self
,
v
=
v
]
_
in
guard
let
`
self
`
=
self
else
{
...
...
@@ -1035,6 +1057,21 @@ open class NavigationDrawerController: TransitionController {
container
.
depthPreset
=
.
none
container
.
isHidden
=
true
}
/**
A method to update rootViewController dim value
*/
fileprivate
func
updateDim
()
{
if
isDimEnabled
{
if
isOpened
{
self
.
rootViewController
.
view
.
alpha
=
1.0
}
else
{
self
.
rootViewController
.
view
.
alpha
=
self
.
dimAmount
}
return
}
self
.
rootViewController
.
view
.
alpha
=
1.0
}
}
extension
NavigationDrawerController
{
...
...
@@ -1196,8 +1233,10 @@ extension NavigationDrawerController: UIGestureRecognizerDelegate {
v
.
layer
.
position
.
x
=
originalX
+
translationX
>
(
w
/
2
)
?
(
w
/
2
)
:
originalX
+
translationX
let
a
=
1
-
v
.
layer
.
position
.
x
/
v
.
bounds
.
width
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
layer
.
position
.
x
<=
v
.
bounds
.
width
/
2
?
a
:
0.5
if
isDimEnabled
{
let
a
=
1
-
v
.
layer
.
position
.
x
/
v
.
bounds
.
width
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
layer
.
position
.
x
<=
v
.
bounds
.
width
/
2
?
a
:
0.5
}
if
translationX
>=
leftThreshold
{
hideStatusBar
()
...
...
@@ -1253,8 +1292,10 @@ extension NavigationDrawerController: UIGestureRecognizerDelegate {
v
.
layer
.
position
.
x
=
originalX
+
translationX
<
view
.
bounds
.
width
-
(
w
/
2
)
?
view
.
bounds
.
width
-
(
w
/
2
)
:
originalX
+
translationX
let
a
=
1
-
(
view
.
bounds
.
width
-
v
.
layer
.
position
.
x
)
/
v
.
bounds
.
width
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
layer
.
position
.
x
>=
v
.
bounds
.
width
/
2
?
a
:
0.5
if
isDimEnabled
{
let
a
=
1
-
(
view
.
bounds
.
width
-
v
.
layer
.
position
.
x
)
/
v
.
bounds
.
width
rootViewController
.
view
.
alpha
=
0.5
<
a
&&
v
.
layer
.
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