Commit fc5025d2 by Daniel Dahan

update to SideNavigationViewController transition from mainViewController

parent f13ac5a5
......@@ -24,14 +24,16 @@ class AMainViewController: UIViewController {
super.viewDidLoad()
prepareView()
// Examples of using Capture.
// Uncomment different examples and read
// the comments below.
// Examples of using SideNavigationViewController.
prepareSwapSideNavigationViewControllerExample()
}
internal func handleSwapViewControllers() {
sideNavigationViewController?.mainViewController = BMainViewController()
sideNavigationViewController?.transitionFromMainViewController(BMainViewController(),
duration: 0.25,
options: .TransitionCrossDissolve,
animations: nil,
completion: nil)
}
/**
......
......@@ -71,6 +71,11 @@
"idiom" : "ipad",
"filename" : "Icon-76@2x.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
......
......@@ -24,14 +24,16 @@ class BMainViewController: UIViewController {
super.viewDidLoad()
prepareView()
// Examples of using Capture.
// Uncomment different examples and read
// the comments below.
// Examples of using SideNavigationViewController.
prepareSwapSideNavigationViewControllerExample()
}
internal func handleSwapViewControllers() {
sideNavigationViewController?.mainViewController = AMainViewController()
sideNavigationViewController?.transitionFromMainViewController(AMainViewController(),
duration: 0.25,
options: .TransitionCrossDissolve,
animations: nil,
completion: nil)
}
/**
......
......@@ -23,6 +23,20 @@ class SideViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareView()
// Examples of using SideNavigationViewController.
prepareSwapSideNavigationViewControllerExample()
}
internal func handleSwapViewControllers() {
sideNavigationViewController?.transitionFromMainViewController(sideNavigationViewController?.mainViewController is AMainViewController ? BMainViewController() : AMainViewController(),
duration: 0.25,
options: .TransitionCrossDissolve,
animations: nil,
completion: { (result: Bool) in
self.sideNavigationViewController?.close()
}
)
}
/**
......@@ -32,5 +46,21 @@ class SideViewController: UIViewController {
private func prepareView() {
view.backgroundColor = MaterialColor.purple.base
}
/**
:name: prepareGeneralSideNavigationViewControllerExample
:description: General usage example.
*/
private func prepareSwapSideNavigationViewControllerExample() {
let button: FabButton = FabButton()
button.backgroundColor = MaterialColor.orange.base
button.addTarget(self, action: "handleSwapViewControllers", forControlEvents: .TouchUpInside)
// Add the button through MaterialLayout.
view.addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignFromTopRight(view, child: button, top: 24, right: 24)
MaterialLayout.size(view, child: button, width: 48, height: 48)
}
}
Pod::Spec.new do |s|
s.name = 'MK'
s.version = '1.24.14'
s.version = '1.24.15'
s.license = { :type => "AGPL-3.0", :file => "LICENSE" }
s.summary = 'Beautiful Material Design in Swift.'
s.homepage = 'http://materialkit.io'
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.24.14</string>
<string>1.24.15</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -191,25 +191,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
/**
:name: mainViewController
*/
public var mainViewController: UIViewController! {
didSet {
if let v: UIViewController = oldValue {
v.willMoveToParentViewController(nil)
addChildViewController(mainViewController)
mainViewController.view.frame = view.bounds
transitionFromViewController(v,
toViewController: mainViewController,
duration: 0.25,
options: .TransitionCrossDissolve,
animations: nil
) { _ in
v.removeFromParentViewController()
self.mainViewController.didMoveToParentViewController(self)
}
userInteractionEnabled = v.view.userInteractionEnabled
}
}
}
public private(set) var mainViewController: UIViewController!
/**
:name: sideViewController
......@@ -248,6 +230,27 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
}
/**
:name: transitionFromMainViewController
*/
public func transitionFromMainViewController(toViewController: UIViewController, duration: NSTimeInterval, options: UIViewAnimationOptions, animations: (() -> Void)?, completion: ((Bool) -> Void)?) {
mainViewController.willMoveToParentViewController(nil)
addChildViewController(toViewController)
toViewController.view.frame = view.bounds
transitionFromViewController(mainViewController,
toViewController: toViewController,
duration: duration,
options: options,
animations: animations,
completion: { (result: Bool) in
self.mainViewController.removeFromParentViewController()
toViewController.didMoveToParentViewController(self)
self.mainViewController = toViewController
self.userInteractionEnabled = !self.opened
completion?(result)
})
}
/**
:name: setSideViewControllerWidth
*/
public func setSideViewControllerWidth(width: CGFloat, hidden: Bool, animated: Bool) {
......@@ -395,7 +398,11 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
backdropLayer.hidden = false
originalPosition = sideView.position
toggleStatusBar(true)
if enableShadowDepth {
MaterialAnimation.animationDisabled {
self.sideView.shadowDepth = self.shadowDepth
}
}
delegate?.sideNavigationViewPanDidBegin?(self, point: sideView.position)
case .Changed:
let translation: CGPoint = recognizer.translationInView(sideView)
......
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