Commit 4f28c1ac by Daniel Dahan

removed dimming PR as it was not working

parent b862f893
/* /*
* Copyright (C) 2015 - 2018, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>. * Copyright (C) 2015 - 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* * Redistributions of source code must retain the above copyright notice, this * * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* *
* * Redistributions in binary form must reproduce the above copyright notice, * * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* *
* * Neither the name of CosmicMind nor the names of its * * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from * contributors may be used to endorse or promote products derived from
* this software without specific prior written permission. * this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
...@@ -227,30 +227,6 @@ open class NavigationDrawerController: TransitionController { ...@@ -227,30 +227,6 @@ open class NavigationDrawerController: TransitionController {
} }
/** /**
A Boolean property that enables and disabled the dim from
rootViewController. Defaults to true
*/
open var isDimEnabled = true {
didSet {
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 dimValue: CGFloat = 0.5 {
didSet {
if 0 > dimValue || 1 < dimValue {
dimValue = 0.5
}
updateDim()
}
}
/**
A Boolean property that enables and disables the leftView from A Boolean property that enables and disables the leftView from
opening and closing. Defaults to true. opening and closing. Defaults to true.
*/ */
...@@ -554,7 +530,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -554,7 +530,7 @@ open class NavigationDrawerController: TransitionController {
v.bounds.size.width = width v.bounds.size.width = width
v.layer.position.x = -width / 2 v.layer.position.x = -width / 2
self.updateDim() self.rootViewController.view.alpha = 1
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let `self` = self else { guard let `self` = self else {
...@@ -575,7 +551,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -575,7 +551,7 @@ open class NavigationDrawerController: TransitionController {
v.bounds.size.width = width v.bounds.size.width = width
v.layer.position.x = width / 2 v.layer.position.x = width / 2
self.updateDim() self.rootViewController.view.alpha = 0.5
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let `self` = self else { guard let `self` = self else {
...@@ -593,14 +569,14 @@ open class NavigationDrawerController: TransitionController { ...@@ -593,14 +569,14 @@ open class NavigationDrawerController: TransitionController {
if hide { if hide {
hideView(container: v) hideView(container: v)
v.layer.position.x = -v.bounds.width / 2 v.layer.position.x = -v.bounds.width / 2
rootViewController.view.alpha = 1
} else { } else {
showView(container: v) showView(container: v)
v.layer.position.x = width / 2 v.layer.position.x = width / 2
rootViewController.view.alpha = 0.5
} }
self.updateDim()
layoutSubviews() layoutSubviews()
} }
} }
...@@ -640,7 +616,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -640,7 +616,7 @@ open class NavigationDrawerController: TransitionController {
v.bounds.size.width = width v.bounds.size.width = width
v.layer.position.x = self.view.bounds.width + width / 2 v.layer.position.x = self.view.bounds.width + width / 2
self.updateDim() self.rootViewController.view.alpha = 1
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let `self` = self else { guard let `self` = self else {
...@@ -661,7 +637,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -661,7 +637,7 @@ open class NavigationDrawerController: TransitionController {
v.bounds.size.width = width v.bounds.size.width = width
v.layer.position.x = self.view.bounds.width - width / 2 v.layer.position.x = self.view.bounds.width - width / 2
self.updateDim() self.rootViewController.view.alpha = 0.5
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let `self` = self else { guard let `self` = self else {
...@@ -679,13 +655,14 @@ open class NavigationDrawerController: TransitionController { ...@@ -679,13 +655,14 @@ open class NavigationDrawerController: TransitionController {
if hide { if hide {
hideView(container: v) hideView(container: v)
v.layer.position.x = view.bounds.width + v.bounds.width / 2 v.layer.position.x = view.bounds.width + v.bounds.width / 2
rootViewController.view.alpha = 1
} else { } else {
showView(container: v) showView(container: v)
v.layer.position.x = view.bounds.width - width / 2 v.layer.position.x = view.bounds.width - width / 2
rootViewController.view.alpha = 0.5
} }
self.updateDim()
layoutSubviews() layoutSubviews()
} }
} }
...@@ -747,7 +724,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -747,7 +724,7 @@ open class NavigationDrawerController: TransitionController {
} }
v.layer.position.x = v.bounds.width / 2 v.layer.position.x = v.bounds.width / 2
self.updateDim() self.rootViewController.view.alpha = 0.5
}) { [weak self] _ in }) { [weak self] _ in
guard let `self` = self else { guard let `self` = self else {
...@@ -794,7 +771,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -794,7 +771,7 @@ open class NavigationDrawerController: TransitionController {
} }
v.layer.position.x = self.view.bounds.width - v.bounds.width / 2 v.layer.position.x = self.view.bounds.width - v.bounds.width / 2
self.updateDim() self.rootViewController.view.alpha = 0.5
}) { [weak self] _ in }) { [weak self] _ in
guard let `self` = self else { guard let `self` = self else {
...@@ -802,6 +779,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -802,6 +779,7 @@ open class NavigationDrawerController: TransitionController {
} }
self.isAnimating = false self.isAnimating = false
self.delegate?.navigationDrawerController?(navigationDrawerController: self, didOpen: .right) self.delegate?.navigationDrawerController?(navigationDrawerController: self, didOpen: .right)
} }
} }
...@@ -836,7 +814,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -836,7 +814,7 @@ open class NavigationDrawerController: TransitionController {
} }
v.layer.position.x = -v.bounds.width / 2 v.layer.position.x = -v.bounds.width / 2
self.updateDim() self.rootViewController.view.alpha = 1
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let `self` = self else { guard let `self` = self else {
...@@ -883,7 +861,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -883,7 +861,7 @@ open class NavigationDrawerController: TransitionController {
} }
v.layer.position.x = self.view.bounds.width + v.bounds.width / 2 v.layer.position.x = self.view.bounds.width + v.bounds.width / 2
self.updateDim() self.rootViewController.view.alpha = 1
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
guard let `self` = self else { guard let `self` = self else {
...@@ -895,7 +873,7 @@ open class NavigationDrawerController: TransitionController { ...@@ -895,7 +873,7 @@ open class NavigationDrawerController: TransitionController {
self.isAnimating = false self.isAnimating = false
self.isUserInteractionEnabled = true self.isUserInteractionEnabled = true
self.delegate?.navigationDrawerController?(navigationDrawerController: self, didClose: .right) self.delegate?.navigationDrawerController?(navigationDrawerController: self, didClose: .right)
} }
} }
...@@ -1057,24 +1035,6 @@ open class NavigationDrawerController: TransitionController { ...@@ -1057,24 +1035,6 @@ open class NavigationDrawerController: TransitionController {
container.depthPreset = .none container.depthPreset = .none
container.isHidden = true container.isHidden = true
} }
/**
A method to update rootViewController dim value
*/
fileprivate func updateDim() {
if isDimEnabled {
if isOpened {
rootViewController.view.alpha = 1.0
} else {
rootViewController.view.alpha = dimValue
}
return
}
rootViewController.view.alpha = 1.0
}
} }
extension NavigationDrawerController { extension NavigationDrawerController {
...@@ -1236,10 +1196,8 @@ extension NavigationDrawerController: UIGestureRecognizerDelegate { ...@@ -1236,10 +1196,8 @@ extension NavigationDrawerController: UIGestureRecognizerDelegate {
v.layer.position.x = originalX + translationX > (w / 2) ? (w / 2) : originalX + translationX v.layer.position.x = originalX + translationX > (w / 2) ? (w / 2) : originalX + translationX
if isDimEnabled { let a = 1 - v.layer.position.x / v.bounds.width
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
rootViewController.view.alpha = 0.5 < a && v.layer.position.x <= v.bounds.width / 2 ? a : 0.5
}
if translationX >= leftThreshold { if translationX >= leftThreshold {
hideStatusBar() hideStatusBar()
...@@ -1295,10 +1253,8 @@ extension NavigationDrawerController: UIGestureRecognizerDelegate { ...@@ -1295,10 +1253,8 @@ extension NavigationDrawerController: UIGestureRecognizerDelegate {
v.layer.position.x = originalX + translationX < view.bounds.width - (w / 2) ? view.bounds.width - (w / 2) : originalX + translationX v.layer.position.x = originalX + translationX < view.bounds.width - (w / 2) ? view.bounds.width - (w / 2) : originalX + translationX
if isDimEnabled { let a = 1 - (view.bounds.width - v.layer.position.x) / v.bounds.width
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
rootViewController.view.alpha = 0.5 < a && v.layer.position.x >= v.bounds.width / 2 ? a : 0.5
}
if translationX <= -rightThreshold { if translationX <= -rightThreshold {
hideStatusBar() hideStatusBar()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment