Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion DebugScreen/Common/Models/Modules/ModuleType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
17 changes: 11 additions & 6 deletions DebugScreen/Flows/DebugScreenCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 11 additions & 3 deletions DebugScreen/Services/DebugScreenPresenterService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ final class ActionsSectionBuilder: SectionBuilder {
let defaultAction = getAction(style: .secondary)
let destructiveAction = getAction(style: .destructive)
let openScreenAction = getOpenScreenAction()
let pushScreenAction = getPushScreenAction()

let actionList = configureActionList()

blocks = [
.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)
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private extension MenuItemsSectionBuilder {
showsDisclosure: true
) {
let view = DestinationViewController()
DebugScreenPresenterService.shared.showCustomScreen(view)
DebugScreenPresenterService.shared.presentCustomScreen(view)
}

let multilineItem = DebugScreenMenuItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Actions.secondaryTitle" = "Secondary";
"Actions.destructiveTitle" = "Destructive";
"Actions.openScreenTitle" = "Open Screen";
"Actions.pushScreenTitle" = "Push Screen";

// MARK: - ActionList

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Actions.secondaryTitle" = "Вспомогательное";
"Actions.destructiveTitle" = "Удаление";
"Actions.openScreenTitle" = "Открытие экрана";
"Actions.pushScreenTitle" = "Пуш экрана";

// MARK: - ActionList

Expand Down