Commit da9375eb by Daniel Dahan

development: updated RootController API

parent 75c4665b
...@@ -143,6 +143,7 @@ extension UINavigationItem { ...@@ -143,6 +143,7 @@ extension UINavigationItem {
} }
} }
/// Title text.
@nonobjc @nonobjc
public var title: String? { public var title: String? {
get { get {
......
...@@ -113,25 +113,27 @@ open class RootController: UIViewController { ...@@ -113,25 +113,27 @@ open class RootController: UIViewController {
the transition animation from the active rootViewController the transition animation from the active rootViewController
to the toViewController has completed. to the toViewController has completed.
*/ */
open func transitionFromRootViewController(toViewController: UIViewController, duration: TimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) { open func transition(to viewController: UIViewController, duration: TimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) {
rootViewController.willMove(toParentViewController: nil) rootViewController.willMove(toParentViewController: nil)
addChildViewController(toViewController) addChildViewController(viewController)
toViewController.view.frame = rootViewController.view.bounds viewController.view.frame = rootViewController.view.bounds
transition(from: rootViewController, transition(from: rootViewController,
to: toViewController, to: viewController,
duration: duration, duration: duration,
options: options, options: options,
animations: animations, animations: animations,
completion: { [weak self] (result: Bool) in completion: { [weak self] (result: Bool) in
if let s: RootController = self { guard let s = self else {
toViewController.didMove(toParentViewController: s) return
}
viewController.didMove(toParentViewController: s)
s.rootViewController.removeFromParentViewController() s.rootViewController.removeFromParentViewController()
s.rootViewController = toViewController s.rootViewController = viewController
s.rootViewController.view.clipsToBounds = true s.rootViewController.view.clipsToBounds = true
s.rootViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] s.rootViewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
s.rootViewController.view.contentScaleFactor = Device.scale s.rootViewController.view.contentScaleFactor = Device.scale
completion?(result) completion?(result)
}
}) })
} }
...@@ -171,7 +173,10 @@ open class RootController: UIViewController { ...@@ -171,7 +173,10 @@ open class RootController: UIViewController {
passed in controller view within the view hierarchy. passed in controller view within the view hierarchy.
*/ */
internal func prepareControllerWithinContainer(viewController: UIViewController?, container: UIView) { internal func prepareControllerWithinContainer(viewController: UIViewController?, container: UIView) {
if let v: UIViewController = viewController { guard let v = viewController else {
return
}
addChildViewController(v) addChildViewController(v)
container.addSubview(v.view) container.addSubview(v.view)
v.didMove(toParentViewController: self) v.didMove(toParentViewController: self)
...@@ -179,5 +184,4 @@ open class RootController: UIViewController { ...@@ -179,5 +184,4 @@ open class RootController: UIViewController {
v.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] v.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
v.view.contentScaleFactor = Device.scale v.view.contentScaleFactor = Device.scale
} }
}
} }
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