Commit e1bece98 by Daniel Dahan

updated SideNavigationController and animation pulse for .Center type

parent ff3d131f
...@@ -44,6 +44,7 @@ class AppNavigationController: NavigationController { ...@@ -44,6 +44,7 @@ class AppNavigationController: NavigationController {
override func viewWillLayoutSubviews() { override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews() super.viewWillLayoutSubviews()
statusBarView?.hidden = MaterialDevice.statusBarHidden statusBarView?.hidden = MaterialDevice.statusBarHidden
print(MaterialDevice.statusBarHidden)
} }
/// Prepares the statusBarView /// Prepares the statusBarView
......
...@@ -42,7 +42,7 @@ public class FabButton : MaterialButton { ...@@ -42,7 +42,7 @@ public class FabButton : MaterialButton {
super.prepareView() super.prepareView()
depth = .Depth1 depth = .Depth1
shape = .Circle shape = .Circle
pulseAnimation = .Center pulseAnimation = .CenterWithBacking
pulseColor = MaterialColor.white pulseColor = MaterialColor.white
tintColor = MaterialColor.white tintColor = MaterialColor.white
backgroundColor = MaterialColor.red.base backgroundColor = MaterialColor.red.base
......
...@@ -74,17 +74,20 @@ internal extension MaterialAnimation { ...@@ -74,17 +74,20 @@ internal extension MaterialAnimation {
pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeScale(0, 0)) pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeScale(0, 0))
}) })
bLayer.setValue(false, forKey: "animated") bLayer.setValue(false, forKey: "animated")
let duration: CFTimeInterval = .Center == pulseAnimation ? 0.16125 : 0.325
switch pulseAnimation { switch pulseAnimation {
case .CenterWithBacking, .Backing, .AtPointWithBacking: case .CenterWithBacking, .Backing, .AtPointWithBacking:
bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(pulseOpacity / 2), duration: 0.325), forKey: nil) bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(pulseOpacity / 2), duration: duration), forKey: nil)
default:break default:break
} }
switch pulseAnimation { switch pulseAnimation {
case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking: case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking:
pLayer.addAnimation(MaterialAnimation.scale(1, duration: 0.325), forKey: nil) pLayer.addAnimation(MaterialAnimation.scale(1, duration: duration), forKey: nil)
default:break default:break
} }
MaterialAnimation.delay(0.325, completion: { MaterialAnimation.delay(duration, completion: {
bLayer.setValue(true, forKey: "animated") bLayer.setValue(true, forKey: "animated")
}) })
} }
...@@ -102,20 +105,23 @@ internal extension MaterialAnimation { ...@@ -102,20 +105,23 @@ internal extension MaterialAnimation {
let animated: Bool? = bLayer.valueForKey("animated") as? Bool let animated: Bool? = bLayer.valueForKey("animated") as? Bool
MaterialAnimation.delay(true == animated ? 0 : 0.15) { MaterialAnimation.delay(true == animated ? 0 : 0.15) {
if let pLayer: CAShapeLayer = bLayer.sublayers?.first as? CAShapeLayer { if let pLayer: CAShapeLayer = bLayer.sublayers?.first as? CAShapeLayer {
let duration: CFTimeInterval = 0.325
switch pulseAnimation { switch pulseAnimation {
case .CenterWithBacking, .Backing, .AtPointWithBacking: case .CenterWithBacking, .Backing, .AtPointWithBacking:
bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0), duration: 0.325), forKey: nil) bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0), duration: 0.325), forKey: nil)
default:break default:break
} }
switch pulseAnimation { switch pulseAnimation {
case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking: case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking:
pLayer.addAnimation(MaterialAnimation.animationGroup([ pLayer.addAnimation(MaterialAnimation.animationGroup([
MaterialAnimation.scale(.Center == pulseAnimation ? 1 : 1.325), MaterialAnimation.scale(.Center == pulseAnimation ? 1 : 1.325),
MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0)) MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0))
], duration: 0.325), forKey: nil) ], duration: duration), forKey: nil)
default:break default:break
} }
MaterialAnimation.delay(0.325) { MaterialAnimation.delay(duration) {
pLayer.removeFromSuperlayer() pLayer.removeFromSuperlayer()
bLayer.removeFromSuperlayer() bLayer.removeFromSuperlayer()
} }
......
...@@ -396,9 +396,9 @@ public class NavigationBar : UINavigationBar { ...@@ -396,9 +396,9 @@ public class NavigationBar : UINavigationBar {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
barStyle = .Black barStyle = .Default
translucent = false translucent = false
backButtonImage = nil backButtonImage = UIImage.imageWithColor(MaterialColor.clear, size: CGSizeMake(1, 1))
backgroundColor = MaterialColor.white backgroundColor = MaterialColor.white
depth = .Depth1 depth = .Depth1
contentInsetPreset = .Square1 contentInsetPreset = .Square1
......
...@@ -175,6 +175,16 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -175,6 +175,16 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
/// Sets the statusBar style. /// Sets the statusBar style.
public var statusBarStyle: UIStatusBarStyle = .Default public var statusBarStyle: UIStatusBarStyle = .Default
/// Sets the statusBar to hidden or not.
public var statusBarHidden: Bool {
get {
return MaterialDevice.statusBarHidden
}
set(value) {
MaterialDevice.statusBarHidden = value
}
}
/** /**
A SideNavigationControllerDelegate property used to bind A SideNavigationControllerDelegate property used to bind
the delegation object. the delegation object.
...@@ -958,49 +968,29 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -958,49 +968,29 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
} }
} }
// /// Shows the statusBar.
// private func showStatusBar() {
// willHideStatusBar = false
// UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
// animations: { [weak self] in
// self?.setNeedsStatusBarAppearanceUpdate()
// MaterialDevice.statusBarHidden = false
// })
// delegate?.sideNavigationStatusBarHiddenState?(self, hidden: false)
// }
//
// /// Hides the statusBar.
// private func hideStatusBar() {
// if enableHideStatusbar {
// willHideStatusBar = true
// UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
// animations: { [weak self] in
// self?.setNeedsStatusBarAppearanceUpdate()
// MaterialDevice.statusBarHidden = true
// })
// delegate?.sideNavigationStatusBarHiddenState?(self, hidden: true)
// }
// }
/// Shows the statusBar. /// Shows the statusBar.
private func showStatusBar() { private func showStatusBar() {
willHideStatusBar = false if statusBarHidden {
UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration), willHideStatusBar = false
animations: { [weak self] in print("show")
self?.setNeedsStatusBarAppearanceUpdate() UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
MaterialDevice.statusBarHidden = false animations: { [weak self] in
}) self?.setNeedsStatusBarAppearanceUpdate()
delegate?.sideNavigationStatusBarHiddenState?(self, hidden: false) self?.statusBarHidden = false
})
delegate?.sideNavigationStatusBarHiddenState?(self, hidden: false)
}
} }
/// Hides the statusBar. /// Hides the statusBar.
private func hideStatusBar() { private func hideStatusBar() {
if enableHideStatusbar { if enableHideStatusbar && !statusBarHidden {
willHideStatusBar = true willHideStatusBar = true
print("hide")
UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration), UIView.animateWithDuration(NSTimeInterval(UINavigationControllerHideShowBarDuration),
animations: { [weak self] in animations: { [weak self] in
self?.setNeedsStatusBarAppearanceUpdate() self?.setNeedsStatusBarAppearanceUpdate()
MaterialDevice.statusBarHidden = true self?.statusBarHidden = true
}) })
delegate?.sideNavigationStatusBarHiddenState?(self, hidden: true) delegate?.sideNavigationStatusBarHiddenState?(self, hidden: true)
} }
...@@ -1075,7 +1065,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -1075,7 +1065,7 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
/// Layout subviews. /// Layout subviews.
private func layoutSubviews() { private func layoutSubviews() {
toggleStatusBar() // toggleStatusBar()
if let v: MaterialView = leftView { if let v: MaterialView = leftView {
v.width = leftViewWidth v.width = leftViewWidth
v.height = view.bounds.height v.height = view.bounds.height
......
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