diff --git a/ConversationsClassic/View/Entering/WelcomeScreen.swift b/ConversationsClassic/View/Entering/WelcomeScreen.swift index 09b3be6..71951b2 100644 --- a/ConversationsClassic/View/Entering/WelcomeScreen.swift +++ b/ConversationsClassic/View/Entering/WelcomeScreen.swift @@ -19,6 +19,8 @@ struct WelcomeScreen: View { .tappablePadding(.symmetric(10)) { router.showScreen(.push) { _ in SettingsScreen() + .environment(\.settingsParent, .welcome) + .navigationBarHidden(true) } } } diff --git a/ConversationsClassic/View/Main/MainTabScreen.swift b/ConversationsClassic/View/Main/MainTabScreen.swift index e34311f..087fc8f 100644 --- a/ConversationsClassic/View/Main/MainTabScreen.swift +++ b/ConversationsClassic/View/Main/MainTabScreen.swift @@ -30,6 +30,7 @@ struct MainTabScreen: View { case .settings: SettingsScreen() + .environment(\.settingsParent, .main) } // Tab bar diff --git a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift index 9e6e7cd..e7f8723 100644 --- a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift +++ b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift @@ -1,8 +1,25 @@ 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 { @EnvironmentObject var clientsStore: ClientsStore @Environment(\.router) var router + @Environment(\.settingsParent) var parent var body: some View { ZStack { @@ -13,9 +30,21 @@ struct SettingsScreen: View { // Content VStack(spacing: 0) { // Header - SharedNavigationBar( - centerText: .init(text: L10n.Settings.Main.title) - ) + if parent == .main { + 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 {