Commit 6d9130cc by Daniel Dahan

Updated SideNavigationViewController to support mainViewController swapping.

parent c56f8f96
...@@ -39,7 +39,7 @@ class AMainViewController: UIViewController { ...@@ -39,7 +39,7 @@ class AMainViewController: UIViewController {
:description: General preparation statements. :description: General preparation statements.
*/ */
private func prepareView() { private func prepareView() {
view.backgroundColor = MaterialColor.green.base view.backgroundColor = MaterialColor.blue.base
} }
/** /**
......
...@@ -39,7 +39,7 @@ class BMainViewController: UIViewController { ...@@ -39,7 +39,7 @@ class BMainViewController: UIViewController {
:description: General preparation statements. :description: General preparation statements.
*/ */
private func prepareView() { private func prepareView() {
view.backgroundColor = MaterialColor.blue.base view.backgroundColor = MaterialColor.green.base
} }
/** /**
...@@ -48,12 +48,13 @@ class BMainViewController: UIViewController { ...@@ -48,12 +48,13 @@ class BMainViewController: UIViewController {
*/ */
private func prepareSwapSideNavigationViewControllerExample() { private func prepareSwapSideNavigationViewControllerExample() {
let button: FabButton = FabButton() let button: FabButton = FabButton()
button.backgroundColor = MaterialColor.yellow.base
button.addTarget(self, action: "handleSwapViewControllers", forControlEvents: .TouchUpInside) button.addTarget(self, action: "handleSwapViewControllers", forControlEvents: .TouchUpInside)
// Add the button through MaterialLayout. // Add the button through MaterialLayout.
view.addSubview(button) view.addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false button.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromBottomRight(view, child: button, bottom: 24, right: 24) MaterialLayout.alignFromBottomLeft(view, child: button, bottom: 24, left: 24)
MaterialLayout.size(view, child: button, width: 64, height: 64) MaterialLayout.size(view, child: button, width: 64, height: 64)
} }
} }
......
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'MK' s.name = 'MK'
s.version = '1.24.12' s.version = '1.24.13'
s.license = { :type => "AGPL-3.0", :file => "LICENSE" } s.license = { :type => "AGPL-3.0", :file => "LICENSE" }
s.summary = 'Beautiful Material Design in Swift.' s.summary = 'Beautiful Material Design in Swift.'
s.homepage = 'http://materialkit.io' s.homepage = 'http://materialkit.io'
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.24.12</string> <string>1.24.13</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -189,12 +189,22 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -189,12 +189,22 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
} }
/** /**
:name: maintViewController :name: mainViewController
*/ */
public var mainViewController: UIViewController! { public var mainViewController: UIViewController! {
didSet { didSet {
prepareMainViewController()
if let v: UIViewController = oldValue { if let v: UIViewController = oldValue {
v.willMoveToParentViewController(nil)
addChildViewController(mainViewController)
transitionFromViewController(v,
toViewController: mainViewController,
duration: 0.25,
options: .TransitionCrossDissolve,
animations: nil
) { _ in
v.removeFromParentViewController()
self.mainViewController.didMoveToParentViewController(self)
}
userInteractionEnabled = v.view.userInteractionEnabled userInteractionEnabled = v.view.userInteractionEnabled
} }
} }
...@@ -510,8 +520,6 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer ...@@ -510,8 +520,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.willMoveToParentViewController(nil)
controller.removeFromParentViewController()
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