This commit is contained in:
fmodf 2024-10-17 19:20:03 +02:00
parent 473cf3b30b
commit 633b4fa2b0
3 changed files with 35 additions and 3 deletions

View file

@ -19,6 +19,8 @@ struct WelcomeScreen: View {
.tappablePadding(.symmetric(10)) { .tappablePadding(.symmetric(10)) {
router.showScreen(.push) { _ in router.showScreen(.push) { _ in
SettingsScreen() SettingsScreen()
.environment(\.settingsParent, .welcome)
.navigationBarHidden(true)
} }
} }
} }

View file

@ -30,6 +30,7 @@ struct MainTabScreen: View {
case .settings: case .settings:
SettingsScreen() SettingsScreen()
.environment(\.settingsParent, .main)
} }
// Tab bar // Tab bar

View file

@ -1,8 +1,25 @@
import SwiftUI import SwiftUI
enum SettingsScreenParent {
case main
case welcome
}
struct SettingsScreenParentKey: EnvironmentKey {
static let defaultValue = SettingsScreenParent.main
}
extension EnvironmentValues {
var settingsParent: SettingsScreenParent {
get { self[SettingsScreenParentKey.self] }
set { self[SettingsScreenParentKey.self] = newValue }
}
}
struct SettingsScreen: View { struct SettingsScreen: View {
@EnvironmentObject var clientsStore: ClientsStore @EnvironmentObject var clientsStore: ClientsStore
@Environment(\.router) var router @Environment(\.router) var router
@Environment(\.settingsParent) var parent
var body: some View { var body: some View {
ZStack { ZStack {
@ -13,9 +30,21 @@ struct SettingsScreen: View {
// Content // Content
VStack(spacing: 0) { VStack(spacing: 0) {
// Header // Header
SharedNavigationBar( if parent == .main {
centerText: .init(text: L10n.Settings.Main.title) SharedNavigationBar(
) centerText: .init(text: L10n.Settings.Main.title)
)
} else {
SharedNavigationBar(
leftButton: .init(
image: Image(systemName: "chevron.left"),
action: {
router.dismissScreen()
}
),
centerText: .init(text: L10n.Settings.Main.title)
)
}
// List // List
List { List {