Commit 75472447 by Daniel Dahan

fixed userInteraction issue with SideNavigationController

parent c73bd151
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
96162C6C1CA71C8700E3A235 /* VideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6B1CA71C8700E3A235 /* VideoViewController.swift */; }; 96162C6C1CA71C8700E3A235 /* VideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6B1CA71C8700E3A235 /* VideoViewController.swift */; };
96162C6E1CA7274E00E3A235 /* PhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */; }; 96162C6E1CA7274E00E3A235 /* PhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */; };
9658F2221CD7B30700B902C1 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9658F2211CD7B30700B902C1 /* Material.framework */; };
9658F2231CD7B30700B902C1 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9658F2211CD7B30700B902C1 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9663F9321C7A744600AF0965 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9311C7A744600AF0965 /* AppDelegate.swift */; }; 9663F9321C7A744600AF0965 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9311C7A744600AF0965 /* AppDelegate.swift */; };
9663F9341C7A744600AF0965 /* RecommendationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9331C7A744600AF0965 /* RecommendationViewController.swift */; }; 9663F9341C7A744600AF0965 /* RecommendationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9331C7A744600AF0965 /* RecommendationViewController.swift */; };
9663F9391C7A744600AF0965 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9663F9381C7A744600AF0965 /* Assets.xcassets */; }; 9663F9391C7A744600AF0965 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9663F9381C7A744600AF0965 /* Assets.xcassets */; };
...@@ -28,6 +30,7 @@ ...@@ -28,6 +30,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
9658F2231CD7B30700B902C1 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -37,6 +40,7 @@ ...@@ -37,6 +40,7 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
96162C6B1CA71C8700E3A235 /* VideoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoViewController.swift; sourceTree = "<group>"; }; 96162C6B1CA71C8700E3A235 /* VideoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoViewController.swift; sourceTree = "<group>"; };
96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoViewController.swift; sourceTree = "<group>"; }; 96162C6D1CA7274E00E3A235 /* PhotoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoViewController.swift; sourceTree = "<group>"; };
9658F2211CD7B30700B902C1 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-bshwisidfobstlbomegqyybbrygh/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
9663F92E1C7A744600AF0965 /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; 9663F92E1C7A744600AF0965 /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
9663F9311C7A744600AF0965 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 9663F9311C7A744600AF0965 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
9663F9331C7A744600AF0965 /* RecommendationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendationViewController.swift; sourceTree = "<group>"; }; 9663F9331C7A744600AF0965 /* RecommendationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendationViewController.swift; sourceTree = "<group>"; };
...@@ -56,6 +60,7 @@ ...@@ -56,6 +60,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
9658F2221CD7B30700B902C1 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -65,6 +70,7 @@ ...@@ -65,6 +70,7 @@
9663F9251C7A744500AF0965 = { 9663F9251C7A744500AF0965 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9658F2211CD7B30700B902C1 /* Material.framework */,
9663F9301C7A744600AF0965 /* App */, 9663F9301C7A744600AF0965 /* App */,
9663F92F1C7A744600AF0965 /* Products */, 9663F92F1C7A744600AF0965 /* Products */,
); );
......
...@@ -45,6 +45,6 @@ public class FabButton : MaterialButton { ...@@ -45,6 +45,6 @@ public class FabButton : MaterialButton {
pulseAnimation = .Center pulseAnimation = .Center
pulseColor = MaterialColor.white pulseColor = MaterialColor.white
tintColor = MaterialColor.white tintColor = MaterialColor.white
backgroundColor = MaterialColor.blue.base backgroundColor = MaterialColor.red.base
} }
} }
\ No newline at end of file
...@@ -568,11 +568,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -568,11 +568,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
if let v: MaterialView = leftView { if let v: MaterialView = leftView {
hideStatusBar() hideStatusBar()
showView(v) showView(v)
userInteractionEnabled = false
delegate?.sideNavigationWillOpen?(self, position: .Left) delegate?.sideNavigationWillOpen?(self, position: .Left)
rootViewController.view.alpha = 0.5
UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { animations: {
v.position.x = v.width / 2 v.position.x = v.width / 2
self.rootViewController.view.alpha = 0.5
}) { [unowned self] _ in }) { [unowned self] _ in
self.delegate?.sideNavigationDidOpen?(self, position: .Left) self.delegate?.sideNavigationDidOpen?(self, position: .Left)
} }
...@@ -591,11 +592,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -591,11 +592,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
if let v: MaterialView = rightView { if let v: MaterialView = rightView {
hideStatusBar() hideStatusBar()
showView(v) showView(v)
userInteractionEnabled = false
delegate?.sideNavigationWillOpen?(self, position: .Right) delegate?.sideNavigationWillOpen?(self, position: .Right)
rootViewController.view.alpha = 0.5
UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { [unowned self] in animations: { [unowned self] in
v.position.x = self.view.bounds.width - v.width / 2 v.position.x = self.view.bounds.width - v.width / 2
self.rootViewController.view.alpha = 0.5
}) { [unowned self] _ in }) { [unowned self] _ in
self.delegate?.sideNavigationDidOpen?(self, position: .Right) self.delegate?.sideNavigationDidOpen?(self, position: .Right)
} }
...@@ -613,11 +615,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -613,11 +615,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
if enabledLeftView { if enabledLeftView {
if let v: MaterialView = leftView { if let v: MaterialView = leftView {
showStatusBar() showStatusBar()
userInteractionEnabled = true
delegate?.sideNavigationWillClose?(self, position: .Left) delegate?.sideNavigationWillClose?(self, position: .Left)
rootViewController.view.alpha = 1
UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { animations: { [unowned self] in
v.position.x = -v.width / 2 v.position.x = -v.width / 2
self.rootViewController.view.alpha = 1
}) { [unowned self] _ in }) { [unowned self] _ in
self.hideView(v) self.hideView(v)
self.delegate?.sideNavigationDidClose?(self, position: .Left) self.delegate?.sideNavigationDidClose?(self, position: .Left)
...@@ -636,11 +639,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -636,11 +639,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
if enabledRightView { if enabledRightView {
if let v: MaterialView = rightView { if let v: MaterialView = rightView {
showStatusBar() showStatusBar()
userInteractionEnabled = true
delegate?.sideNavigationWillClose?(self, position: .Right) delegate?.sideNavigationWillClose?(self, position: .Right)
rootViewController.view.alpha = 1
UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animateWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { [unowned self] in animations: { [unowned self] in
v.position.x = self.view.bounds.width + v.width / 2 v.position.x = self.view.bounds.width + v.width / 2
self.rootViewController.view.alpha = 1
}) { [unowned self] _ in }) { [unowned self] _ in
self.hideView(v) self.hideView(v)
self.delegate?.sideNavigationDidClose?(self, position: .Right) self.delegate?.sideNavigationDidClose?(self, position: .Right)
...@@ -695,9 +699,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -695,9 +699,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
v.position.x = originalX + translationX > (w / 2) ? (w / 2) : originalX + translationX v.position.x = originalX + translationX > (w / 2) ? (w / 2) : originalX + translationX
let a: CGFloat = 1 - v.position.x / v.width let a: CGFloat = 1 - v.position.x / v.width
rootViewController.view.alpha = 0.5 < a ? a : 0.5 rootViewController.view.alpha = 0.5 < a && v.position.x <= v.width / 2 ? a : 0.5
if v.position.x >= leftThreshold { if translationX >= leftThreshold {
hideStatusBar() hideStatusBar()
} }
...@@ -743,9 +747,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -743,9 +747,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
v.position.x = originalX + translationX < view.bounds.width - (w / 2) ? view.bounds.width - (w / 2) : originalX + translationX v.position.x = originalX + translationX < view.bounds.width - (w / 2) ? view.bounds.width - (w / 2) : originalX + translationX
let a: CGFloat = 1 - (view.bounds.width - v.position.x) / v.width let a: CGFloat = 1 - (view.bounds.width - v.position.x) / v.width
rootViewController.view.alpha = 0.5 < a ? a : 0.5 rootViewController.view.alpha = 0.5 < a && v.position.x >= v.width / 2 ? a : 0.5
if v.position.x <= view.bounds.width - rightThreshold { if translationX <= view.bounds.width - rightThreshold {
hideStatusBar() hideStatusBar()
} }
...@@ -1035,7 +1039,6 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -1035,7 +1039,6 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
- Parameter container: A container view. - Parameter container: A container view.
*/ */
private func showView(container: MaterialView) { private func showView(container: MaterialView) {
userInteractionEnabled = false
container.depth = depth container.depth = depth
container.hidden = false container.hidden = false
} }
...@@ -1045,7 +1048,6 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -1045,7 +1048,6 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
- Parameter container: A container view. - Parameter container: A container view.
*/ */
private func hideView(container: MaterialView) { private func hideView(container: MaterialView) {
userInteractionEnabled = true
container.depth = .None container.depth = .None
container.hidden = true container.hidden = true
} }
......
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