-
Notifications
You must be signed in to change notification settings - Fork 1
Fix "Pop problem" #9
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |
|
|
||
| import UIKit | ||
|
|
||
| open class StackRouter: StackRoutable { | ||
| open class StackRouter: NSObject, StackRoutable, UINavigationControllerDelegate { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Определение себя делегатом навигейшен контроллера в StackRouter убивает подписку в кастомной реализации UINavigationController в проекте. Кажется, это совершенно не очевидное поведение библиотеки |
||
|
|
||
| private var completions: [UIViewController: () -> ()] | ||
|
|
||
|
|
@@ -45,6 +45,10 @@ open class StackRouter: StackRoutable { | |
| self.rootController = rootController | ||
| self.headModule = rootController.topViewController | ||
| self.completions = [:] | ||
|
|
||
| super.init() | ||
|
|
||
| self.rootController?.delegate = self | ||
| } | ||
|
|
||
| // MARK: - StackRoutable | ||
|
|
@@ -53,6 +57,12 @@ open class StackRouter: StackRoutable { | |
| push(module, animated: true) | ||
| } | ||
|
|
||
| public func push(_ module: Presentable?, | ||
| completion: (() -> ())?) { | ||
|
|
||
| push(module, animated: true, completion: completion) | ||
| } | ||
|
|
||
| public func push(_ module: Presentable?, animated: Bool) { | ||
| push(module, animated: animated, configurationClosure: nil, completion: nil) | ||
| } | ||
|
|
@@ -64,7 +74,12 @@ open class StackRouter: StackRoutable { | |
| push(module, animated: animated, configurationClosure: configurationClosure, completion: nil) | ||
| } | ||
|
|
||
|
|
||
| public func push(_ module: Presentable?, | ||
| animated: Bool, | ||
| completion: (() -> ())?) { | ||
|
|
||
| push(module, animated: animated, configurationClosure: nil, completion: completion) | ||
| } | ||
|
|
||
| public func push(_ module: Presentable?, | ||
| animated: Bool, | ||
|
|
@@ -200,10 +215,19 @@ open class StackRouter: StackRoutable { | |
| completions[controller]?() | ||
| completions.removeValue(forKey: controller) | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лишние пробелы |
||
| public func runCompletionsChain(of controllers: [UIViewController]) { | ||
| controllers.forEach { [weak self] controller in | ||
| self?.runCompletion(for: controller) | ||
| } | ||
| } | ||
|
|
||
| public func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { | ||
| guard let poppedViewController = navigationController.transitionCoordinator?.viewController(forKey: .from), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Можно добавить ссылку на источник проблемы и более подробное решение? Так как на первый взгляд неочевидно, что именно здесь пытаемся добиться.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В мои времена это делалось через |
||
| !navigationController.viewControllers.contains(poppedViewController) else { | ||
| return | ||
| } | ||
|
|
||
| runCompletion(for: poppedViewController) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
отступ поехал