Commit 212e652c by Daniel Dahan

updated to Motion.async and partial update on TabsController lifecycle

parent 36c2c4d6
......@@ -635,7 +635,7 @@ fileprivate extension Layout {
- Parameter for view: A UIView.
*/
class func updateConstraints(for view: UIView) {
DispatchQueue.main.async {
Motion.async {
view.setNeedsLayout()
view.layoutIfNeeded()
view.updateConstraintsIfNeeded()
......
......@@ -30,6 +30,7 @@
import UIKit
import Accelerate
import Motion
@objc(ImageFormat)
public enum ImageFormat: Int {
......@@ -198,7 +199,7 @@ extension UIImage {
*/
open class func contentsOfURL(url: URL, completion: @escaping ((UIImage?, Error?) -> Void)) {
URLSession.shared.dataTask(with: URLRequest(url: url)) { [completion = completion] (data: Data?, response: URLResponse?, error: Error?) in
DispatchQueue.main.async {
Motion.async {
if let v = error {
completion(nil, v)
} else if let v = data {
......
......@@ -29,6 +29,7 @@
*/
import UIKit
import Motion
@objc(NavigationDrawerPosition)
public enum NavigationDrawerPosition: Int {
......@@ -863,7 +864,7 @@ open class NavigationDrawerController: TransitionController {
/// Shows the statusBar.
fileprivate func showStatusBar() {
DispatchQueue.main.async { [weak self] in
Motion.async { [weak self] in
guard let s = self else {
return
}
......@@ -884,7 +885,7 @@ open class NavigationDrawerController: TransitionController {
return
}
DispatchQueue.main.async { [weak self] in
Motion.async { [weak self] in
guard let s = self else {
return
}
......
......@@ -197,48 +197,48 @@ fileprivate extension TabsController {
return
}
fvc.beginAppearanceTransition(false, animated: true)
guard let fvcIndex = viewControllers.index(of: fvc) else {
return
}
let fvcIndex = viewControllers.index(of: fvc)
let tvcIndex = viewControllers.index(of: viewController)
guard let tvcIndex = viewControllers.index(of: viewController) else {
return
}
let tvc = viewController
tvc.view.isHidden = false
tvc.view.frame = container.bounds
var isAuto = false
viewController.view.isHidden = false
viewController.view.frame = container.bounds
switch tvc.motionModalTransitionType {
var isAuto = false
switch viewController.motionModalTransitionType {
case .auto:
isAuto = true
tvc.motionModalTransitionType = fvcIndex! < tvcIndex! ? .slide(direction: .left) : .slide(direction: .right)
viewController.motionModalTransitionType = fvcIndex < tvcIndex ? .slide(direction: .left) : .slide(direction: .right)
default:break
}
if isTriggeredByUserInteraction {
delegate?.tabsController?(tabsController: self, willSelect: tvc)
delegate?.tabsController?(tabsController: self, willSelect: viewController)
}
view.isUserInteractionEnabled = false
Motion.shared.transition(from: fvc, to: tvc, in: container) { [weak self, tvc = tvc, isAuto = isAuto, completion = completion] (isFinished) in
Motion.shared.transition(from: fvc, to: viewController, in: container) { [weak self, viewController = viewController, isAuto = isAuto, completion = completion] (isFinished) in
guard let s = self else {
return
}
if isAuto {
tvc.motionModalTransitionType = .auto
viewController.motionModalTransitionType = .auto
}
s.rootViewController = tvc
s.rootViewController = viewController
s.view.isUserInteractionEnabled = true
s.removeViewController(viewController: fvc)
fvc.endAppearanceTransition()
completion?(isFinished)
if isTriggeredByUserInteraction {
s.delegate?.tabsController?(tabsController: s, didSelect: tvc)
s.delegate?.tabsController?(tabsController: s, didSelect: viewController)
}
}
}
......@@ -254,15 +254,6 @@ internal extension TabsController {
fileprivate extension TabsController {
/// Prepares all the view controllers.
func prepareViewControllers() {
for i in 0..<viewControllers.count {
guard i != selectedIndex else {
continue
}
viewControllers[i].view.isHidden = true
prepareViewController(at: i)
}
prepareViewController(at: selectedIndex)
prepareRootViewController()
}
......
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