From fd3dc1a74c28f6d621c467dce5b0a158e452f3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D1=82=D1=91=D0=BC=D0=BA=D0=B8=D0=BD=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20=D0=92=D0=BB?= =?UTF-8?q?=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Fri, 20 Feb 2026 10:11:02 +0300 Subject: [PATCH 1/2] Add pushCustomScreen --- DebugScreen/Common/Models/Modules/ModuleType.swift | 2 ++ DebugScreen/Flows/DebugScreenCoordinator.swift | 6 ++++++ .../Services/DebugScreenPresenterService.swift | 10 +++++++++- .../Builders/ActionsSectionBuilder.swift | 12 +++++++++++- .../Library/Resources/Strings/Strings.swift | 2 ++ .../Resources/Strings/en.lproj/Localizable.strings | 1 + .../Resources/Strings/ru.lproj/Localizable.strings | 1 + 7 files changed, 32 insertions(+), 2 deletions(-) diff --git a/DebugScreen/Common/Models/Modules/ModuleType.swift b/DebugScreen/Common/Models/Modules/ModuleType.swift index 7876c15..9f5f3b7 100644 --- a/DebugScreen/Common/Models/Modules/ModuleType.swift +++ b/DebugScreen/Common/Models/Modules/ModuleType.swift @@ -14,6 +14,8 @@ enum ModuleType { case alert(model: AlertModel) /// Module to present any view controller by action button tap case customScreen(_ screen: UIViewController) + /// Module to push any view controller onto the debug screen navigation stack + case pushCustomScreen(_ screen: UIViewController) /// Module to open local file by selected filepath case fileViewer(model: FileViewerModel) /// Module to present information table screen. diff --git a/DebugScreen/Flows/DebugScreenCoordinator.swift b/DebugScreen/Flows/DebugScreenCoordinator.swift index 6d244a9..e58f341 100644 --- a/DebugScreen/Flows/DebugScreenCoordinator.swift +++ b/DebugScreen/Flows/DebugScreenCoordinator.swift @@ -30,6 +30,8 @@ final class DebugScreenCoordinator: BaseCoordinator { showAlert(with: model) case .customScreen(let screen): showCustomScreen(screen) + case .pushCustomScreen(let screen): + pushCustomScreen(screen) case .fileViewer(let model): showFile(with: model) case .infoTable(let model): @@ -121,6 +123,10 @@ private extension DebugScreenCoordinator { router.present(view) } + func pushCustomScreen(_ screen: UIViewController) { + router.push(screen) + } + func configureActionSheetItem(with model: Action) -> UIAlertAction { let style: UIAlertAction.Style = model.style == .destructive ? .destructive : .default let action = UIAlertAction(title: model.title, style: style) { _ in diff --git a/DebugScreen/Services/DebugScreenPresenterService.swift b/DebugScreen/Services/DebugScreenPresenterService.swift index 2bfaebe..42cc764 100644 --- a/DebugScreen/Services/DebugScreenPresenterService.swift +++ b/DebugScreen/Services/DebugScreenPresenterService.swift @@ -45,13 +45,21 @@ 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)) } + /// 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(.pushCustomScreen(view)) + } + /// Open log file. /// Can be showed only when debug screen is open. public func openLogFile() { diff --git a/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/ActionsSectionBuilder.swift b/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/ActionsSectionBuilder.swift index 0677a64..1da9b88 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) @@ -56,6 +58,14 @@ private extension ActionsSectionBuilder { return action } + func getPushScreenAction() -> DebugScreenAction { + let action: DebugScreenAction = .init(title: L10n.Actions.pushScreenTitle) { + let view = DestinationViewController() + DebugScreenPresenterService.shared.pushCustomScreen(view) + } + return action + } + func configureActionList() -> DebugScreenActionList { let actions = getActionListModels() let actionList: DebugScreenActionList = .init(title: L10n.ActionList.title, 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 From f3b3d5f5b7d1b5f1343ee9663181486fd8f3f183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=BE=D1=82=D1=91=D0=BC=D0=BA=D0=B8=D0=BD=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20=D0=92=D0=BB?= =?UTF-8?q?=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Fri, 20 Feb 2026 19:32:36 +0300 Subject: [PATCH 2/2] Add CustomScreenPresentationMethod --- .../Common/Models/Modules/ModuleType.swift | 12 +++++++--- .../Flows/DebugScreenCoordinator.swift | 23 +++++++++---------- .../DebugScreenPresenterService.swift | 6 ++--- .../Builders/ActionsSectionBuilder.swift | 2 +- .../Builders/MenuItemsSectionBuilder.swift | 2 +- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/DebugScreen/Common/Models/Modules/ModuleType.swift b/DebugScreen/Common/Models/Modules/ModuleType.swift index 9f5f3b7..7b08c90 100644 --- a/DebugScreen/Common/Models/Modules/ModuleType.swift +++ b/DebugScreen/Common/Models/Modules/ModuleType.swift @@ -13,11 +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) - /// Module to push any view controller onto the debug screen navigation stack - case pushCustomScreen(_ 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 e58f341..adf2df3 100644 --- a/DebugScreen/Flows/DebugScreenCoordinator.swift +++ b/DebugScreen/Flows/DebugScreenCoordinator.swift @@ -28,10 +28,8 @@ final class DebugScreenCoordinator: BaseCoordinator { switch module { case .alert(let model): showAlert(with: model) - case .customScreen(let screen): - showCustomScreen(screen) - case .pushCustomScreen(let screen): - pushCustomScreen(screen) + case .customScreen(let screen, let method): + showCustomScreen(screen, method: method) case .fileViewer(let model): showFile(with: model) case .infoTable(let model): @@ -117,14 +115,15 @@ private extension DebugScreenCoordinator { router.push(view) } - func showCustomScreen(_ screen: UIViewController) { - let view = BaseNavigationController(rootViewController: screen) - view.modalPresentationStyle = .overFullScreen - router.present(view) - } - - func pushCustomScreen(_ screen: UIViewController) { - router.push(screen) + 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 42cc764..af0a858 100644 --- a/DebugScreen/Services/DebugScreenPresenterService.swift +++ b/DebugScreen/Services/DebugScreenPresenterService.swift @@ -48,8 +48,8 @@ public final class DebugScreenPresenterService { /// 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. @@ -57,7 +57,7 @@ public final class DebugScreenPresenterService { /// Can be used only when debug screen is open. /// - Parameter view: Screen to display. public func pushCustomScreen(_ view: UIViewController) { - openModule(.pushCustomScreen(view)) + 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 1da9b88..776534a 100644 --- a/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/ActionsSectionBuilder.swift +++ b/Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/ActionsSectionBuilder.swift @@ -53,7 +53,7 @@ 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 } 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(