From e6fda0edf820de577355cd68eebb2e5a16336538 Mon Sep 17 00:00:00 2001 From: Maxim Sorokin Date: Tue, 10 Nov 2020 21:39:26 +0300 Subject: [PATCH] [Add] choice of modalPresentationStyle --- .../Routable/Modal/ModalRoutable.swift | 2 ++ .../Classes/Routable/Modal/ModalRouter.swift | 21 +++++++++++++++---- .../Classes/Routable/Stack/StackRouter.swift | 8 +++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/TICoordinatorKit/Classes/Routable/Modal/ModalRoutable.swift b/TICoordinatorKit/Classes/Routable/Modal/ModalRoutable.swift index 8aa8e4c..7292c22 100644 --- a/TICoordinatorKit/Classes/Routable/Modal/ModalRoutable.swift +++ b/TICoordinatorKit/Classes/Routable/Modal/ModalRoutable.swift @@ -28,6 +28,8 @@ public protocol ModalRoutable: Presentable { func present(_ module: Presentable?) func present(_ module: Presentable?, animated: Bool) + func present(_ module: Presentable?, modalPresentationStyle: UIModalPresentationStyle?) + func present(_ module: Presentable?, modalPresentationStyle: UIModalPresentationStyle?, animated: Bool) func dismissModule() func dismissModule(animated: Bool, completion: (() -> ())?) diff --git a/TICoordinatorKit/Classes/Routable/Modal/ModalRouter.swift b/TICoordinatorKit/Classes/Routable/Modal/ModalRouter.swift index 13f4b8b..e0e193a 100644 --- a/TICoordinatorKit/Classes/Routable/Modal/ModalRouter.swift +++ b/TICoordinatorKit/Classes/Routable/Modal/ModalRouter.swift @@ -39,8 +39,16 @@ public final class ModalRouter: ModalRoutable { public func present(_ module: Presentable?) { present(module, animated: true) } + + public func present(_ module: Presentable?, modalPresentationStyle: UIModalPresentationStyle?) { + present(module, modalPresentationStyle: modalPresentationStyle, animated: true) + } public func present(_ module: Presentable?, animated: Bool) { + present(module, modalPresentationStyle: nil, animated: true) + } + + public func present(_ module: Presentable?, modalPresentationStyle: UIModalPresentationStyle?, animated: Bool) { guard let controller = module?.toPresent() else { return } @@ -133,11 +141,16 @@ public final class ModalRouter: ModalRoutable { // MARK: - Private methods - private func presentOn(_ source: UIViewController?, target: UIViewController, animated: Bool) { + private func presentOn(_ source: UIViewController?, + target: UIViewController, + modalPresentationStyle: UIModalPresentationStyle? = nil, + animated: Bool) { -// if target.modalPresentationStyle != .custom { -// target.modalPresentationStyle = .overFullScreen -// } + if let modalPresentationStyle = modalPresentationStyle { + target.modalPresentationStyle = modalPresentationStyle + } else if target.modalPresentationStyle != .custom { + target.modalPresentationStyle = .overFullScreen + } target.modalPresentationCapturesStatusBarAppearance = true source?.present(target, animated: animated, completion: nil) diff --git a/TICoordinatorKit/Classes/Routable/Stack/StackRouter.swift b/TICoordinatorKit/Classes/Routable/Stack/StackRouter.swift index 167063a..b443941 100644 --- a/TICoordinatorKit/Classes/Routable/Stack/StackRouter.swift +++ b/TICoordinatorKit/Classes/Routable/Stack/StackRouter.swift @@ -128,6 +128,14 @@ open class StackRouter: StackRoutable { public func present(_ module: Presentable?, animated: Bool) { modalRouter?.present(module, animated: animated) } + + public func present(_ module: Presentable?, modalPresentationStyle: UIModalPresentationStyle?) { + modalRouter?.present(module, modalPresentationStyle: modalPresentationStyle) + } + + public func present(_ module: Presentable?, modalPresentationStyle: UIModalPresentationStyle?, animated: Bool) { + modalRouter?.present(module, modalPresentationStyle: modalPresentationStyle, animated: animated) + } public func dismissModule() { modalRouter?.dismissModule()