Skip to content

Commit f3b3d5f

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

5 files changed

Lines changed: 25 additions & 20 deletions

File tree

DebugScreen/Common/Models/Modules/ModuleType.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ enum ModuleType {
1313
/// Module to present alert with message
1414
case alert(model: AlertModel)
1515
/// Module to present any view controller by action button tap
16-
case customScreen(_ screen: UIViewController)
17-
/// Module to push any view controller onto the debug screen navigation stack
18-
case pushCustomScreen(_ screen: UIViewController)
16+
case customScreen(_ screen: UIViewController, method: CustomScreenPresentationMethod)
1917
/// Module to open local file by selected filepath
2018
case fileViewer(model: FileViewerModel)
2119
/// Module to present information table screen.
2220
case infoTable(model: InfoTableModel)
2321
}
22+
23+
/// Defines how a custom screen should be presented from the debug menu
24+
enum CustomScreenPresentationMethod {
25+
/// Present modally over the current screen
26+
case present
27+
/// Push onto the debug screen navigation stack
28+
case push
29+
}

DebugScreen/Flows/DebugScreenCoordinator.swift

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ final class DebugScreenCoordinator: BaseCoordinator {
2828
switch module {
2929
case .alert(let model):
3030
showAlert(with: model)
31-
case .customScreen(let screen):
32-
showCustomScreen(screen)
33-
case .pushCustomScreen(let screen):
34-
pushCustomScreen(screen)
31+
case .customScreen(let screen, let method):
32+
showCustomScreen(screen, method: method)
3533
case .fileViewer(let model):
3634
showFile(with: model)
3735
case .infoTable(let model):
@@ -117,14 +115,15 @@ private extension DebugScreenCoordinator {
117115
router.push(view)
118116
}
119117

120-
func showCustomScreen(_ screen: UIViewController) {
121-
let view = BaseNavigationController(rootViewController: screen)
122-
view.modalPresentationStyle = .overFullScreen
123-
router.present(view)
124-
}
125-
126-
func pushCustomScreen(_ screen: UIViewController) {
127-
router.push(screen)
118+
func showCustomScreen(_ screen: UIViewController, method: CustomScreenPresentationMethod) {
119+
switch method {
120+
case .present:
121+
let view = BaseNavigationController(rootViewController: screen)
122+
view.modalPresentationStyle = .overFullScreen
123+
router.present(view)
124+
case .push:
125+
router.push(screen)
126+
}
128127
}
129128

130129
func configureActionSheetItem(with model: Action) -> UIAlertAction {

DebugScreen/Services/DebugScreenPresenterService.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ public final class DebugScreenPresenterService {
4848
/// Show custom view controller modally.
4949
/// Can be showed only when debug screen is open.
5050
/// - Parameter view: Screen to display.
51-
public func showCustomScreen(_ view: UIViewController) {
52-
openModule(.customScreen(view))
51+
public func presentCustomScreen(_ view: UIViewController) {
52+
openModule(.customScreen(view, method: .present))
5353
}
5454

5555
/// Push custom view controller onto the debug screen navigation stack.
5656
/// Provides a standard back button to return to the debug menu.
5757
/// Can be used only when debug screen is open.
5858
/// - Parameter view: Screen to display.
5959
public func pushCustomScreen(_ view: UIViewController) {
60-
openModule(.pushCustomScreen(view))
60+
openModule(.customScreen(view, method: .push))
6161
}
6262

6363
/// Open log file.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private extension ActionsSectionBuilder {
5353
func getOpenScreenAction() -> DebugScreenAction {
5454
let action: DebugScreenAction = .init(title: L10n.Actions.openScreenTitle) {
5555
let view = DestinationViewController()
56-
DebugScreenPresenterService.shared.showCustomScreen(view)
56+
DebugScreenPresenterService.shared.presentCustomScreen(view)
5757
}
5858
return action
5959
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private extension MenuItemsSectionBuilder {
3535
showsDisclosure: true
3636
) {
3737
let view = DestinationViewController()
38-
DebugScreenPresenterService.shared.showCustomScreen(view)
38+
DebugScreenPresenterService.shared.presentCustomScreen(view)
3939
}
4040

4141
let multilineItem = DebugScreenMenuItem(

0 commit comments

Comments
 (0)