Skip to content

Commit fd3dc1a

Browse files
author
Потёмкин Александр Владимирович
committed
Add pushCustomScreen
1 parent 3b826fd commit fd3dc1a

7 files changed

Lines changed: 32 additions & 2 deletions

File tree

DebugScreen/Common/Models/Modules/ModuleType.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ enum ModuleType {
1414
case alert(model: AlertModel)
1515
/// Module to present any view controller by action button tap
1616
case customScreen(_ screen: UIViewController)
17+
/// Module to push any view controller onto the debug screen navigation stack
18+
case pushCustomScreen(_ screen: UIViewController)
1719
/// Module to open local file by selected filepath
1820
case fileViewer(model: FileViewerModel)
1921
/// Module to present information table screen.

DebugScreen/Flows/DebugScreenCoordinator.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ final class DebugScreenCoordinator: BaseCoordinator {
3030
showAlert(with: model)
3131
case .customScreen(let screen):
3232
showCustomScreen(screen)
33+
case .pushCustomScreen(let screen):
34+
pushCustomScreen(screen)
3335
case .fileViewer(let model):
3436
showFile(with: model)
3537
case .infoTable(let model):
@@ -121,6 +123,10 @@ private extension DebugScreenCoordinator {
121123
router.present(view)
122124
}
123125

126+
func pushCustomScreen(_ screen: UIViewController) {
127+
router.push(screen)
128+
}
129+
124130
func configureActionSheetItem(with model: Action) -> UIAlertAction {
125131
let style: UIAlertAction.Style = model.style == .destructive ? .destructive : .default
126132
let action = UIAlertAction(title: model.title, style: style) { _ in

DebugScreen/Services/DebugScreenPresenterService.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,21 @@ public final class DebugScreenPresenterService {
4545
openModule(.alert(model: model))
4646
}
4747

48-
/// Show custom view controller.
48+
/// Show custom view controller modally.
4949
/// Can be showed only when debug screen is open.
5050
/// - Parameter view: Screen to display.
5151
public func showCustomScreen(_ view: UIViewController) {
5252
openModule(.customScreen(view))
5353
}
5454

55+
/// Push custom view controller onto the debug screen navigation stack.
56+
/// Provides a standard back button to return to the debug menu.
57+
/// Can be used only when debug screen is open.
58+
/// - Parameter view: Screen to display.
59+
public func pushCustomScreen(_ view: UIViewController) {
60+
openModule(.pushCustomScreen(view))
61+
}
62+
5563
/// Open log file.
5664
/// Can be showed only when debug screen is open.
5765
public func openLogFile() {

Example/DebugScreenExample/App/DebugScreenConfiguration/Builders/ActionsSectionBuilder.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ final class ActionsSectionBuilder: SectionBuilder {
1818
let defaultAction = getAction(style: .secondary)
1919
let destructiveAction = getAction(style: .destructive)
2020
let openScreenAction = getOpenScreenAction()
21+
let pushScreenAction = getPushScreenAction()
2122

2223
let actionList = configureActionList()
2324

2425
blocks = [
2526
.actionList(model: actionList),
2627
.action(model: defaultAction),
2728
.action(model: destructiveAction),
28-
.action(model: openScreenAction)
29+
.action(model: openScreenAction),
30+
.action(model: pushScreenAction)
2931
]
3032

3133
return .init(title: L10n.Actions.header, blocks: blocks)
@@ -56,6 +58,14 @@ private extension ActionsSectionBuilder {
5658
return action
5759
}
5860

61+
func getPushScreenAction() -> DebugScreenAction {
62+
let action: DebugScreenAction = .init(title: L10n.Actions.pushScreenTitle) {
63+
let view = DestinationViewController()
64+
DebugScreenPresenterService.shared.pushCustomScreen(view)
65+
}
66+
return action
67+
}
68+
5969
func configureActionList() -> DebugScreenActionList {
6070
let actions = getActionListModels()
6171
let actionList: DebugScreenActionList = .init(title: L10n.ActionList.title,

Example/DebugScreenExample/Library/Resources/Strings/Strings.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ internal enum L10n {
2727
internal static let header = L10n.tr("Localizable", "Actions.header")
2828
/// Открытие экрана
2929
internal static let openScreenTitle = L10n.tr("Localizable", "Actions.openScreenTitle")
30+
/// Пуш экрана
31+
internal static let pushScreenTitle = L10n.tr("Localizable", "Actions.pushScreenTitle")
3032
/// Вспомогательное
3133
internal static let secondaryTitle = L10n.tr("Localizable", "Actions.secondaryTitle")
3234
}

Example/DebugScreenExample/Library/Resources/Strings/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"Actions.secondaryTitle" = "Secondary";
1313
"Actions.destructiveTitle" = "Destructive";
1414
"Actions.openScreenTitle" = "Open Screen";
15+
"Actions.pushScreenTitle" = "Push Screen";
1516

1617
// MARK: - ActionList
1718

Example/DebugScreenExample/Library/Resources/Strings/ru.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"Actions.secondaryTitle" = "Вспомогательное";
1313
"Actions.destructiveTitle" = "Удаление";
1414
"Actions.openScreenTitle" = "Открытие экрана";
15+
"Actions.pushScreenTitle" = "Пуш экрана";
1516

1617
// MARK: - ActionList
1718

0 commit comments

Comments
 (0)