fix iOS 12 behavior when calling dismiss without presentedController, add withAnimationCompletion for StackRoutable

This commit is contained in:
Ivan Smolin 2023-12-04 18:06:04 +03:00
parent c76079e667
commit d348414ab7
3 changed files with 29 additions and 4 deletions

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TICoordinatorKit'
s.version = '1.1.5'
s.version = '1.1.7'
s.summary = 'A framework for performing navigation in iOS application.'
s.homepage = 'https://github.com/TouchInstinct/TICoordinatorKit'
s.license = 'Apache License, Version 2.0'

View File

@ -72,11 +72,18 @@ public final class ModalRouter: ModalRoutable {
}
public func dismissModule(animated: Bool, completion: (() -> ())?) {
rootController?.dismiss(animated: animated) { [weak self] in
self?.topController = self?.rootController
self?.childRootControllers = []
let dismissCompletion = {
self.topController = self.rootController
self.childRootControllers = []
completion?()
}
guard rootController?.presentedViewController != nil else {
dismissCompletion()
return
}
rootController?.dismiss(animated: animated, completion: dismissCompletion)
}
public func presentChild(_ module: Presentable?,

View File

@ -51,3 +51,21 @@ public protocol StackRoutable: ModalRoutable {
func pop(to module: Presentable?)
func pop(to module: Presentable?, animated: Bool)
}
public extension StackRoutable {
var headModuleInTheStack: Bool {
if let headModule = headModule, headModule.toPresent()?.parent === toPresent() {
return true
}
return false
}
func withAnimationCompletion(_ animationCompletion: (() -> Void)?,
routerActions: (StackRoutable) -> Void) {
CATransaction.begin()
CATransaction.setCompletionBlock(animationCompletion)
routerActions(self)
CATransaction.commit()
}
}