From f7a8e96fcb54b8348375009d24d4bb943f868fd9 Mon Sep 17 00:00:00 2001 From: Hugo Pezziardi Date: Fri, 19 Jan 2024 17:13:14 +0100 Subject: [PATCH] :sparkles: (LekaApp): Add SettingsView --- .../Views/MainView/RootOwnerViewModel.swift | 4 ++ .../Views/Settings/SettingsView.swift | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift index ff4f0f04c7..ee178d8c44 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift @@ -23,6 +23,10 @@ class RootOwnerViewModel: ObservableObject { @Published var showConfirmDisconnection: Bool = false @Published var showConfirmDeleteAccount: Bool = false + var isCompanyConnected: Bool { + !self.currentCompany.email.isEmpty && !self.currentCompany.password.isEmpty + } + func disconnect() { self.currentCompany = Company(email: "", password: "", caregivers: [], carereceivers: []) self.isWelcomeViewPresented = true diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift new file mode 100644 index 0000000000..8c2a5cc67c --- /dev/null +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift @@ -0,0 +1,40 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import DesignKit +import LocalizationKit +import SwiftUI + +// MARK: - SettingsView + +struct SettingsView: View { + @ObservedObject var rootOwnerViewModel: RootOwnerViewModel = .shared + @ObservedObject var styleManager: StyleManager = .shared + + var body: some View { + NavigationStack { + Form { + AppearanceSection() + + if self.rootOwnerViewModel.isCompanyConnected { + CredentialsSection() + AccountSection() + } + } + .navigationTitle(String(l10n.SettingsView.navigationTitle.characters)) + .toolbar { + ToolbarItem(placement: .topBarTrailing) { + Button(String(l10n.SettingsView.closeButtonLabel.characters)) { + self.rootOwnerViewModel.isSettingsViewPresented = false + } + } + } + } + .preferredColorScheme(self.styleManager.colorScheme) + } +} + +#Preview { + SettingsView() +}