Skip to content

Commit c3dc801

Browse files
committed
[#710] Add full-screen route presentation
1 parent 631b716 commit c3dc801

5 files changed

Lines changed: 42 additions & 3 deletions

File tree

template/Modules/Domain/Sources/UseCases/CheckForceUpdateUseCase.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public struct CheckForceUpdateUseCase: CheckForceUpdateUseCaseProtocol, Sendable
3030
}
3131
}
3232

33-
private extension CheckForceUpdateUseCase {
33+
public extension CheckForceUpdateUseCase {
3434

3535
static func defaultCurrentVersion() -> AppVersion {
3636
let string = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
enum AppRoute: Hashable {
1+
enum AppRoute: Hashable, Identifiable {
22

33
case settings
4+
5+
var id: String {
6+
switch self {
7+
case .settings:
8+
return "settings"
9+
}
10+
}
411
}

template/Tuist/Interfaces/SwiftUI/Sources/Presentation/Coordinators/AppRouter.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ import SwiftUI
44
final class AppRouter: ObservableObject {
55

66
@Published var path: [AppRoute] = []
7+
@Published var fullScreenRoute: AppRoute?
78

89
func push(_ route: AppRoute) {
910
path.append(route)
1011
}
1112

13+
func presentFullScreen(_ route: AppRoute) {
14+
fullScreenRoute = route
15+
}
16+
1217
func pop() {
1318
guard !path.isEmpty else { return }
1419

@@ -18,4 +23,8 @@ final class AppRouter: ObservableObject {
1823
func popToRoot() {
1924
path.removeAll()
2025
}
26+
27+
func dismissFullScreen() {
28+
fullScreenRoute = nil
29+
}
2130
}

template/Tuist/Interfaces/SwiftUI/Sources/Presentation/Modules/Home/HomeView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ struct HomeView: View {
44

55
var onSignOut: () -> Void = {}
66
var onShowSettings: () -> Void = {}
7+
var onPresentSettings: () -> Void = {}
78

89
var body: some View {
910
VStack(spacing: 20) {
@@ -19,6 +20,9 @@ struct HomeView: View {
1920
Button("Open Settings", action: onShowSettings)
2021
.buttonStyle(.bordered)
2122

23+
Button("Present Settings Full Screen", action: onPresentSettings)
24+
.buttonStyle(.bordered)
25+
2226
Button("Sign Out", action: onSignOut)
2327
.buttonStyle(.borderedProminent)
2428
}

template/Tuist/Interfaces/SwiftUI/Sources/Presentation/Modules/Landing/LandingView.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ struct LandingView: View {
2929
case .signedIn:
3030
HomeView(
3131
onSignOut: signOut,
32-
onShowSettings: showSettings
32+
onShowSettings: showSettings,
33+
onPresentSettings: presentSettings
3334
)
3435
case .forceUpdateRequired:
3536
ForceUpdateView(onUpdate: openAppStore)
@@ -40,6 +41,7 @@ struct LandingView: View {
4041
await viewModel.restoreSessionIfNeeded()
4142
}
4243
}
44+
.fullScreenCover(item: $router.fullScreenRoute, content: fullScreenDestination)
4345
}
4446

4547
private func continueWithDemoSession() {
@@ -52,13 +54,18 @@ struct LandingView: View {
5254
Task {
5355
await viewModel.signOut()
5456
router.popToRoot()
57+
router.dismissFullScreen()
5558
}
5659
}
5760

5861
private func showSettings() {
5962
router.push(.settings)
6063
}
6164

65+
private func presentSettings() {
66+
router.presentFullScreen(.settings)
67+
}
68+
6269
private func openAppStore() {
6370
openURL(Constants.appStoreURL)
6471
}
@@ -70,4 +77,16 @@ struct LandingView: View {
7077
SettingsView()
7178
}
7279
}
80+
81+
@ViewBuilder
82+
private func fullScreenDestination(for route: AppRoute) -> some View {
83+
NavigationStack {
84+
destination(for: route)
85+
.toolbar {
86+
ToolbarItem(placement: .cancellationAction) {
87+
Button("Close", action: router.dismissFullScreen)
88+
}
89+
}
90+
}
91+
}
7392
}

0 commit comments

Comments
 (0)