Commit e1bece98 by Daniel Dahan

updated SideNavigationController and animation pulse for .Center type

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