diff --git a/DebugScreen/Common/Models/Modules/ModuleType.swift b/DebugScreen/Common/Models/Modules/ModuleType.swift index 7876c15..7b08c90 100644 --- a/DebugScreen/Common/Models/Modules/ModuleType.swift +++ b/DebugScreen/Common/Models/Modules/ModuleType.swift @@ -13,9 +13,17 @@ enum ModuleType { /// Module to present alert with message case alert(model: AlertModel) /// Module to present any view controller by action button tap - case customScreen(_ screen: UIViewController) + case customScreen(_ screen: UIViewController, method: CustomScreenPresentationMethod) /// Module to open local file by selected filepath case fileViewer(model: FileViewerModel) /// Module to present information table screen. case infoTable(model: InfoTableModel) } + +/// Defines how a custom screen should be presented from the debug menu +enum CustomScreenPresentationMethod { + /// Present modally over the current screen + case present + /// Push onto the debug screen navigation stack + case push +} diff --git a/DebugScreen/Flows/DebugScreenCoordinator.swift b/DebugScreen/Flows/DebugScreenCoordinator.swift index 6d244a9..adf2df3 100644 --- a/DebugScreen/Flows/DebugScreenCoordinator.swift +++ b/DebugScreen/Flows/DebugScreenCoordinator.swift @@ -28,8 +28,8 @@ final class DebugScreenCoordinator: BaseCoordinator { switch module { case .alert(let model): showAlert(with: model) - case .customScreen(let screen): - showCustomScreen(screen) + case .customScreen(let screen, let method): + showCustomScreen(screen, method: method) case .fileViewer(let model): showFile(with: model) case .infoTable(let model): @@ -115,10 +115,15 @@ private extension DebugScreenCoordinator { router.push(view) } - func showCustomScreen(_ screen: UIViewController) { - let view = BaseNavigationController(rootViewController: screen) - view.modalPresentationStyle = .overFullScreen - router.present(view) + func showCustomScreen(_ screen: UIViewController, method: CustomScreenPresentationMethod) { + switch method { + case .present: + let view = BaseNavigationController(rootViewController: screen) + view.modalPresentationStyle = .overFullScreen + router.present(view) + case .push: + router.push(screen) + } } func configureActionSheetItem(with model: Action) -> UIAlertAction { diff --git a/DebugScreen/Services/DebugScreenPresenterService.swift b/DebugScreen/Services/DebugScreenPresenterService.swift index 2bfaebe..af0a858 100644 --- a/DebugScreen/Services/DebugScreenPresenterService.swift +++ b/DebugScreen/Services/DebugScreenPresenterService.swift @@ -45,11 +45,19 @@ public final class DebugScreenPresenterService { openModule(.alert(model: model)) } - /// Show custom view controller. + /// Show custom view controller modally. /// Can be showed only when debug screen is open. /// - Parameter view: Screen to display. - public func showCustomScreen(_ view: UIViewController) { - openModule(.customScreen(view)) + public func presentCustomScreen(_ view: UIViewController) { + openModule(.customScreen(view, method: .present)) + } + + /// Push custom view controller onto the debug screen navigation stack. + /// Provides a standard back button to return to the debug menu. + /// Can be used only when debug screen is open. + /// - Parameter view: Screen to display. + public func pushCustomScreen(_ view: UIViewController) { + openModule(.customScreen(view, method: .push)) } /// Open log file. diff --git a/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/ActionsSectionBuilder.swift b/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/ActionsSectionBuilder.swift index 0677a64..776534a 100644 --- a/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/ActionsSectionBuilder.swift +++ b/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/ActionsSectionBuilder.swift @@ -18,6 +18,7 @@ final class ActionsSectionBuilder: SectionBuilder { let defaultAction = getAction(style: .secondary) let destructiveAction = getAction(style: .destructive) let openScreenAction = getOpenScreenAction() + let pushScreenAction = getPushScreenAction() let actionList = configureActionList() @@ -25,7 +26,8 @@ final class ActionsSectionBuilder: SectionBuilder { .actionList(model: actionList), .action(model: defaultAction), .action(model: destructiveAction), - .action(model: openScreenAction) + .action(model: openScreenAction), + .action(model: pushScreenAction) ] return .init(title: L10n.Actions.header, blocks: blocks) @@ -51,7 +53,15 @@ private extension ActionsSectionBuilder { func getOpenScreenAction() -> DebugScreenAction { let action: DebugScreenAction = .init(title: L10n.Actions.openScreenTitle) { let view = DestinationViewController() - DebugScreenPresenterService.shared.showCustomScreen(view) + DebugScreenPresenterService.shared.presentCustomScreen(view) + } + return action + } + + func getPushScreenAction() -> DebugScreenAction { + let action: DebugScreenAction = .init(title: L10n.Actions.pushScreenTitle) { + let view = DestinationViewController() + DebugScreenPresenterService.shared.pushCustomScreen(view) } return action } diff --git a/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/MenuItemsSectionBuilder.swift b/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/MenuItemsSectionBuilder.swift index b3b1b7e..0c7f5ab 100644 --- a/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/MenuItemsSectionBuilder.swift +++ b/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/MenuItemsSectionBuilder.swift @@ -35,7 +35,7 @@ private extension MenuItemsSectionBuilder { showsDisclosure: true ) { let view = DestinationViewController() - DebugScreenPresenterService.shared.showCustomScreen(view) + DebugScreenPresenterService.shared.presentCustomScreen(view) } let multilineItem = DebugScreenMenuItem( diff --git a/Example/DebugScreenExample/Library/Resources/Strings/Strings.swift b/Example/DebugScreenExample/Library/Resources/Strings/Strings.swift index 74dd00d..c963b9b 100644 --- a/Example/DebugScreenExample/Library/Resources/Strings/Strings.swift +++ b/Example/DebugScreenExample/Library/Resources/Strings/Strings.swift @@ -27,6 +27,8 @@ internal enum L10n { internal static let header = L10n.tr("Localizable", "Actions.header") /// Открытие экрана internal static let openScreenTitle = L10n.tr("Localizable", "Actions.openScreenTitle") + /// Пуш экрана + internal static let pushScreenTitle = L10n.tr("Localizable", "Actions.pushScreenTitle") /// Вспомогательное internal static let secondaryTitle = L10n.tr("Localizable", "Actions.secondaryTitle") } diff --git a/Example/DebugScreenExample/Library/Resources/Strings/en.lproj/Localizable.strings b/Example/DebugScreenExample/Library/Resources/Strings/en.lproj/Localizable.strings index 856a2d1..5897f3f 100644 --- a/Example/DebugScreenExample/Library/Resources/Strings/en.lproj/Localizable.strings +++ b/Example/DebugScreenExample/Library/Resources/Strings/en.lproj/Localizable.strings @@ -12,6 +12,7 @@ "Actions.secondaryTitle" = "Secondary"; "Actions.destructiveTitle" = "Destructive"; "Actions.openScreenTitle" = "Open Screen"; +"Actions.pushScreenTitle" = "Push Screen"; // MARK: - ActionList diff --git a/Example/DebugScreenExample/Library/Resources/Strings/ru.lproj/Localizable.strings b/Example/DebugScreenExample/Library/Resources/Strings/ru.lproj/Localizable.strings index b7363da..3021441 100644 --- a/Example/DebugScreenExample/Library/Resources/Strings/ru.lproj/Localizable.strings +++ b/Example/DebugScreenExample/Library/Resources/Strings/ru.lproj/Localizable.strings @@ -12,6 +12,7 @@ "Actions.secondaryTitle" = "Вспомогательное"; "Actions.destructiveTitle" = "Удаление"; "Actions.openScreenTitle" = "Открытие экрана"; +"Actions.pushScreenTitle" = "Пуш экрана"; // MARK: - ActionList