[Add] choice of modalPresentationStyle

This commit is contained in:
Maxim Sorokin 2020-11-10 21:39:26 +03:00
parent 2224b4e4c6
commit e6fda0edf8
3 changed files with 27 additions and 4 deletions

View File

@ -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: (() -> ())?)

View File

@ -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)

View File

@ -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()