Commit 0029c656 by danieldahan

updated SideNav dimension resize when cell-phone status is on

parent bfe9ed9f
...@@ -166,10 +166,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -166,10 +166,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
public override func viewWillLayoutSubviews() { public override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews() super.viewWillLayoutSubviews()
layoutBackdropLayer() layoutBackdropLayer()
if let v: MaterialView = sideView { sideView.height = view.bounds.height
sideViewController?.view.frame = v.bounds sideViewController.view.frame.size.width = sideView.width
sideViewController?.view.center = CGPointMake(v.width / 2, v.height / 2) sideViewController.view.frame.size.height = sideView.height
} sideViewController.view.center = CGPointMake(sideView.width / 2, sideView.height / 2)
} }
/** /**
...@@ -184,7 +184,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -184,7 +184,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
MaterialAnimation.animationWithDuration(0.25, animations: { MaterialAnimation.animationWithDuration(0.25, animations: {
self.sideView.width = width self.sideView.width = width
self.sideView.position.x = w self.sideView.position.x = w
}) { }) {
self.userInteractionEnabled = false self.userInteractionEnabled = false
} }
} else { } else {
...@@ -206,13 +206,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -206,13 +206,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
:name: open :name: open
*/ */
public func open(velocity: CGFloat = 0) { public func open(velocity: CGFloat = 0) {
let w: CGFloat = sideView.width
let h: CGFloat = sideView.height
let d: Double = Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(sideView.x / velocity))))
toggleStatusBar(true) toggleStatusBar(true)
MaterialAnimation.animationWithDuration(d, animations: { MaterialAnimation.animationWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(sideView.x / velocity)))),
self.sideView.position = CGPointMake(w / 2, h / 2) animations: {
self.sideView.position = CGPointMake(self.sideView.width / 2, self.sideView.height / 2)
self.backdropLayer.hidden = false self.backdropLayer.hidden = false
}) { }) {
self.userInteractionEnabled = false self.userInteractionEnabled = false
...@@ -223,13 +220,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -223,13 +220,10 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
:name: close :name: close
*/ */
public func close(velocity: CGFloat = 0) { public func close(velocity: CGFloat = 0) {
let w: CGFloat = sideView.width
let h: CGFloat = sideView.height
let d: Double = Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(sideView.x / velocity))))
toggleStatusBar(false) toggleStatusBar(false)
MaterialAnimation.animationWithDuration(d, animations: { MaterialAnimation.animationWithDuration(Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(sideView.x / velocity)))),
self.sideView.position = CGPointMake(-w / 2, h / 2) animations: {
self.sideView.position = CGPointMake(-self.sideView.width / 2, self.sideView.height / 2)
self.backdropLayer.hidden = true self.backdropLayer.hidden = true
}) { }) {
self.userInteractionEnabled = true self.userInteractionEnabled = true
...@@ -281,6 +275,8 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -281,6 +275,8 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
// //
internal func prepareMainView() { internal func prepareMainView() {
prepareViewControllerWithinContainer(mainViewController, container: view) prepareViewControllerWithinContainer(mainViewController, container: view)
mainViewController.view.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: mainViewController.view)
} }
// //
...@@ -290,6 +286,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -290,6 +286,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
// container // container
sideView.frame = CGRectMake(0, 0, sideViewControllerWidth, view.frame.height) sideView.frame = CGRectMake(0, 0, sideViewControllerWidth, view.frame.height)
sideView.backgroundColor = MaterialColor.blue.accent3 sideView.backgroundColor = MaterialColor.blue.accent3
sideView.autoresizesSubviews = true
view.addSubview(sideView) view.addSubview(sideView)
MaterialAnimation.animationDisabled({ MaterialAnimation.animationDisabled({
...@@ -297,7 +294,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -297,7 +294,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
self.sideView.zPosition = 1000 self.sideView.zPosition = 1000
}) })
prepareViewControllerWithinContainer(sideViewController!, container: sideView) prepareViewControllerWithinContainer(sideViewController, container: sideView)
// gestures // gestures
prepareGestures() prepareGestures()
...@@ -422,7 +419,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -422,7 +419,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
// :name: prepareViewControllerWithinContainer // :name: prepareViewControllerWithinContainer
// //
private func prepareViewControllerWithinContainer(controller: UIViewController, container: UIView) { private func prepareViewControllerWithinContainer(controller: UIViewController, container: UIView) {
controller.view.clipsToBounds = true
addChildViewController(controller) addChildViewController(controller)
container.addSubview(controller.view) container.addSubview(controller.view)
controller.didMoveToParentViewController(self) controller.didMoveToParentViewController(self)
......
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