diff --git a/Apps/LekaApp/Resources/Localizable.xcstrings b/Apps/LekaApp/Resources/Localizable.xcstrings index 1a1e34ea98..725c8dee41 100644 --- a/Apps/LekaApp/Resources/Localizable.xcstrings +++ b/Apps/LekaApp/Resources/Localizable.xcstrings @@ -2,6 +2,96 @@ "version": "1.0", "sourceLanguage": "en", "strings": { + "caregiver_settings_view.appearance_section.accent_color_row.title": { + "comment": "AccentColor Row title", + "extractionState": "extracted_with_value", + "localizations": { + "en": { + "stringUnit": { + "state": "new", + "value": "Color Theme" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Th\u00e8me de couleur" + } + } + } + }, + "caregiver_settings_view.appearance_section.appearance_row.title": { + "comment": "Appearance Row title", + "extractionState": "extracted_with_value", + "localizations": { + "en": { + "stringUnit": { + "state": "new", + "value": "Dark Mode" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Mode sombre" + } + } + } + }, + "caregiver_settings_view.close_button_label": { + "comment": "Close button label of Caregiver Settings View", + "extractionState": "extracted_with_value", + "localizations": { + "en": { + "stringUnit": { + "state": "new", + "value": "Close" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Fermer" + } + } + } + }, + "caregiver_settings_view.navigation_title": { + "comment": "The navigation title of Caregiver Settings View", + "extractionState": "extracted_with_value", + "localizations": { + "en": { + "stringUnit": { + "state": "new", + "value": "Profil of " + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Profil de " + } + } + } + }, + "caregiver_settings_view.save_button_label": { + "comment": "Save button label of Caregiver Settings View", + "extractionState": "extracted_with_value", + "localizations": { + "en": { + "stringUnit": { + "state": "new", + "value": "Save" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Enregistrer" + } + } + } + }, "lekaapp.TextFieldEmail.invalidEmailErrorLabel": { "comment": "TextFieldEmail invalid Email Error Label", "extractionState": "extracted_with_value", @@ -848,6 +938,42 @@ } } }, + "lekapp.sidebar.change_caregiver_profile.button_label": { + "comment": "The button label of caregiver profile picker", + "extractionState": "extracted_with_value", + "localizations": { + "en": { + "stringUnit": { + "state": "new", + "value": "Change profile" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "Changer de profil" + } + } + } + }, + "lekapp.sidebar.select_caregiver_profile.button_label": { + "comment": "The button label of caregiver profile picker when no profile is selected", + "extractionState": "extracted_with_value", + "localizations": { + "en": { + "stringUnit": { + "state": "new", + "value": "Select profile" + } + }, + "fr": { + "stringUnit": { + "state": "translated", + "value": "S\u00e9lectionnez un profil" + } + } + } + }, "main_view.sidebar.category_label.activities": { "comment": "The title of the category 'Activities'", "extractionState": "extracted_with_value", @@ -1136,60 +1262,6 @@ } } }, - "settings_view.appearance_section.accent_color_row.title": { - "comment": "AccentColor Row title", - "extractionState": "extracted_with_value", - "localizations": { - "en": { - "stringUnit": { - "state": "new", - "value": "Accent Color" - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "Couleur accentu\u00e9e" - } - } - } - }, - "settings_view.appearance_section.appearance_row.title": { - "comment": "Appearance Row title", - "extractionState": "extracted_with_value", - "localizations": { - "en": { - "stringUnit": { - "state": "new", - "value": "Dark mode" - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "Mode sombre" - } - } - } - }, - "settings_view.appearance_section.header": { - "comment": "Appearance section header", - "extractionState": "extracted_with_value", - "localizations": { - "en": { - "stringUnit": { - "state": "new", - "value": "Appearance" - } - }, - "fr": { - "stringUnit": { - "state": "translated", - "value": "Apparence" - } - } - } - }, "settings_view.close_button_label": { "comment": "Close button label of Settings View", "extractionState": "extracted_with_value", diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Models/CompanyModel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Models/CompanyModel.swift index 00cbd5daae..b1ce8f2780 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Models/CompanyModel.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Models/CompanyModel.swift @@ -27,10 +27,17 @@ protocol Profile: Identifiable, Hashable { struct Caregiver: Profile { // MARK: Lifecycle - init(name: String = "", avatar: String = "", professions: [Profession] = []) { + init(name: String = "", + avatar: String = "", + professions: [Profession] = [], + colorScheme: ColorScheme = .light, + accentColor: Color = DesignKitAsset.Colors.lekaDarkBlue.swiftUIColor) + { self.name = name self.avatar = avatar self.professions = professions + self.preferredColorScheme = colorScheme + self.preferredAccentColor = accentColor } // MARK: Internal @@ -39,6 +46,8 @@ struct Caregiver: Profile { var name: String var avatar: String var professions: [Profession] + var preferredColorScheme: ColorScheme + var preferredAccentColor: Color } // MARK: - Carereceiver diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/Process/AccountCreationProcess+Step4.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/Process/AccountCreationProcess+Step4.swift index 4ecb506db6..a5f77587be 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/Process/AccountCreationProcess+Step4.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AccountCreation/Process/AccountCreationProcess+Step4.swift @@ -20,6 +20,9 @@ extension AccountCreationProcess { Text(l10n.AccountCreationProcess.Step4.message) Button(String(l10n.AccountCreationProcess.Step4.discoverContentButton.characters)) { + if !self.rootOwnerViewModel.mockCaregiversSet.isEmpty { + self.rootOwnerViewModel.currentCaregiver = self.rootOwnerViewModel.mockCaregiversSet.last + } self.rootOwnerViewModel.isWelcomeViewPresented.toggle() } .buttonStyle(.bordered) diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AccentColorRow.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView+AccentColorRow.swift similarity index 76% rename from Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AccentColorRow.swift rename to Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView+AccentColorRow.swift index f32e2602ad..d52bb65625 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AccentColorRow.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView+AccentColorRow.swift @@ -8,15 +8,35 @@ import SwiftUI // swiftlint:disable nesting -// MARK: - SettingsView.AppearanceSection.AccentColorRow +// MARK: - CaregiverSettingsView.AccentColorRow -extension SettingsView.AppearanceSection { +extension CaregiverSettingsView { struct AccentColorRow: View { // MARK: Internal + @Binding var caregiver: Caregiver + + var body: some View { + HStack { + Text(l10n.CaregiverSettingsView.AccentColorRow.title) + + Spacer() + + ForEach(self.colors, id: \.self) { color in + ColorCircleView(color: color, isSelected: self.selectedColor == color) + .onTapGesture { + self.styleManager.accentColor = color + self.caregiver.preferredAccentColor = color + } + } + } + } + + // MARK: Private + // MARK: - ColorCircleView - struct ColorCircleView: View { + private struct ColorCircleView: View { let color: Color let isSelected: Bool @@ -32,24 +52,7 @@ extension SettingsView.AppearanceSection { } } - @ObservedObject var styleManager: StyleManager = .shared - - var body: some View { - HStack { - Text(l10n.SettingsView.AppearanceSection.AccentColorRow.title) - - Spacer() - - ForEach(self.colors, id: \.self) { color in - ColorCircleView(color: color, isSelected: self.selectedColor == color) - .onTapGesture { - self.styleManager.accentColor = color - } - } - } - } - - // MARK: Private + @ObservedObject private var styleManager: StyleManager = .shared private let colors: [Color] = [DesignKitAsset.Colors.lekaDarkBlue.swiftUIColor, .blue, .purple, .red, .orange, .yellow, .green, .gray] @@ -63,6 +66,6 @@ extension SettingsView.AppearanceSection { #Preview { Form { - SettingsView.AppearanceSection.AccentColorRow() + CaregiverSettingsView.AccentColorRow(caregiver: .constant(Caregiver())) } } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView+AppearanceRow.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView+AppearanceRow.swift new file mode 100644 index 0000000000..1f3efe97af --- /dev/null +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView+AppearanceRow.swift @@ -0,0 +1,43 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import DesignKit +import LocalizationKit +import SwiftUI + +// MARK: - CaregiverSettingsView.AppearanceRow + +extension CaregiverSettingsView { + struct AppearanceRow: View { + // MARK: Internal + + @Binding var caregiver: Caregiver + + var body: some View { + HStack(spacing: 10) { + Text(l10n.CaregiverSettingsView.AppearanceRow.title) + + Spacer() + + Toggle("", isOn: Binding( + get: { self.styleManager.colorScheme == .dark }, + set: { + self.styleManager.colorScheme = $0 ? .dark : .light + self.caregiver.preferredColorScheme = $0 ? .dark : .light + } + )) + } + } + + // MARK: Private + + @ObservedObject private var styleManager: StyleManager = .shared + } +} + +#Preview { + Form { + CaregiverSettingsView.AppearanceRow(caregiver: .constant(Caregiver())) + } +} diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView+l10n.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView+l10n.swift new file mode 100644 index 0000000000..8e3adc0050 --- /dev/null +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView+l10n.swift @@ -0,0 +1,27 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import LocalizationKit + +// swiftlint:disable line_length nesting + +extension l10n { + enum CaregiverSettingsView { + enum AppearanceRow { + static let title = LocalizedString("caregiver_settings_view.appearance_section.appearance_row.title", value: "Dark Mode", comment: "Appearance Row title") + } + + enum AccentColorRow { + static let title = LocalizedString("caregiver_settings_view.appearance_section.accent_color_row.title", value: "Color Theme", comment: "AccentColor Row title") + } + + static let navigationTitle = LocalizedString("caregiver_settings_view.navigation_title", value: "Profil of ", comment: "The navigation title of Caregiver Settings View") + + static let saveButtonLabel = LocalizedString("caregiver_settings_view.save_button_label", value: "Save", comment: "Save button label of Caregiver Settings View") + + static let closeButtonLabel = LocalizedString("caregiver_settings_view.close_button_label", value: "Close", comment: "Close button label of Caregiver Settings View") + } +} + +// swiftlint:enable line_length nesting diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView.swift new file mode 100644 index 0000000000..fe51874d29 --- /dev/null +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/CaregiverSettingsView/CaregiverSettingsView.swift @@ -0,0 +1,96 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import DesignKit +import LocalizationKit +import SwiftUI + +// MARK: - CaregiverSettingsView + +struct CaregiverSettingsView: View { + // MARK: Internal + + @State var modifiedCaregiver: Caregiver + + var body: some View { + NavigationStack { + VStack(spacing: 40) { + self.avatarNavigationLink + + TextFieldDefault(label: String(l10n.CaregiverCreation.caregiverNameLabel.characters), + entry: self.$modifiedCaregiver.name) + + self.professionNavigationLink + + AppearanceRow(caregiver: self.$modifiedCaregiver) + AccentColorRow(caregiver: self.$modifiedCaregiver) + } + .frame(maxWidth: 500) + .navigationTitle(String(l10n.CaregiverSettingsView.navigationTitle.characters) + self.modifiedCaregiver.name) + .navigationBarTitleDisplayMode(.inline) + .interactiveDismissDisabled() + .toolbar { + ToolbarItem(placement: .topBarLeading) { + Button(String(l10n.CaregiverSettingsView.closeButtonLabel.characters)) { + self.rootOwnerViewModel.isCaregiverSettingsViewPresented = false + } + } + ToolbarItem(placement: .topBarTrailing) { + Button(String(l10n.CaregiverSettingsView.saveButtonLabel.characters)) { + // TODO: (@mathieu) - Add Firestore logic + self.rootOwnerViewModel.isCaregiverSettingsViewPresented = false + self.rootOwnerViewModel.currentCaregiver = self.modifiedCaregiver + } + } + } + } + .preferredColorScheme(self.styleManager.colorScheme) + } + + // MARK: Private + + @ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared + @ObservedObject private var styleManager: StyleManager = .shared + + private var avatarNavigationLink: some View { + NavigationLink { + AvatarPicker(avatar: self.$modifiedCaregiver.avatar) + } label: { + VStack(spacing: 15) { + AvatarPicker.ButtonLabel(image: self.modifiedCaregiver.avatar) + Text(l10n.CaregiverCreation.avatarChoiceButton) + // TODO: (@ui/ux) - Design System - replace with Leka font + .font(.headline) + } + } + } + + private var professionNavigationLink: some View { + VStack(alignment: .leading) { + HStack { + Text(l10n.CaregiverCreation.professionLabel) + // TODO: (@ui/ux) - Design System - replace with Leka font + .font(.body) + + Spacer() + + NavigationLink { + ProfessionPicker(caregiver: self.$modifiedCaregiver) + } label: { + Label(String(l10n.CaregiverCreation.professionAddButton.characters), systemImage: "plus") + } + } + + if !self.modifiedCaregiver.professions.isEmpty { + ForEach(self.modifiedCaregiver.professions, id: \.self) { profession in + ProfessionPicker.ProfessionTag(profession: profession, caregiver: self.$modifiedCaregiver) + } + } + } + } +} + +#Preview { + CaregiverSettingsView(modifiedCaregiver: Caregiver()) +} diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/CaregiverSettingsLabel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/CaregiverSettingsLabel.swift new file mode 100644 index 0000000000..54b9531b84 --- /dev/null +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/CaregiverSettingsLabel.swift @@ -0,0 +1,133 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import DesignKit +import LocalizationKit +import RobotKit +import SwiftUI + +// MARK: - CaregiverSettingsLabel + +struct CaregiverSettingsLabel: View { + // MARK: Internal + + var body: some View { + VStack(alignment: .center, spacing: 10) { + if let caregiver = self.rootOwnerViewModel.currentCaregiver { + Button { + self.rootOwnerViewModel.isCaregiverSettingsViewPresented = true + } label: { + CaregiverProfileLabel(caregiver: caregiver) + } + + Button { + self.rootOwnerViewModel.isCaregiverPickerViewPresented = true + } label: { + Label(String(l10n.ChangeCaregiverProfile.buttonLabel.characters), systemImage: "person.2.circle") + } + .buttonStyle(.bordered) + } else { + Button { + self.rootOwnerViewModel.isCaregiverPickerViewPresented = true + } label: { + UnselectedProfileLabel() + } + } + } + .frame(maxWidth: .infinity) + } + + // MARK: Private + + @ObservedObject private var styleManager: StyleManager = .shared + @ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared +} + +// MARK: - CaregiverProfileLabel + +struct CaregiverProfileLabel: View { + // MARK: Internal + + let caregiver: Caregiver + + var body: some View { + VStack { + Image(self.caregiver.avatar, bundle: Bundle(for: DesignKitResources.self)) + .resizable() + .scaledToFit() + .frame(width: 80) + .clipShape(Circle()) + + Text(self.caregiver.name) + .foregroundStyle(self.styleManager.accentColor!) + .font(.headline) + .multilineTextAlignment(.center) + } + } + + // MARK: Private + + @ObservedObject private var styleManager: StyleManager = .shared +} + +// MARK: - UnselectedProfileLabel + +struct UnselectedProfileLabel: View { + // MARK: Internal + + var body: some View { + VStack { + Image(systemName: "person.crop.circle.badge.questionmark") + .resizable() + .scaledToFit() + .frame(width: 80) + .foregroundStyle(self.styleManager.accentColor!) + + Text(l10n.SelectCaregiverProfile.buttonLabel) + .foregroundStyle(self.styleManager.accentColor!) + .font(.headline) + .multilineTextAlignment(.center) + } + } + + // MARK: Private + + @ObservedObject private var styleManager: StyleManager = .shared +} + +// MARK: - l10n.ChangeCaregiverProfile + +// swiftlint:disable line_length + +extension l10n { + enum ChangeCaregiverProfile { + static let buttonLabel = LocalizedString("lekapp.sidebar.change_caregiver_profile.button_label", value: "Change profile", comment: "The button label of caregiver profile picker") + } + + enum SelectCaregiverProfile { + static let buttonLabel = LocalizedString("lekapp.sidebar.select_caregiver_profile.button_label", value: "Select profile", comment: "The button label of caregiver profile picker when no profile is selected") + } +} + +// swiftlint:enable line_length + +#Preview { + NavigationSplitView(sidebar: { + List { + CaregiverSettingsLabel() + + Button {} label: { + RobotConnectionLabel() + } + .listRowInsets(EdgeInsets(top: 0, leading: -8, bottom: -8, trailing: -8)) + + Section("Information") { + Label("What's new?", systemImage: "lightbulb.max") + Label("Resources", systemImage: "book.and.wrench") + } + } + }, detail: { + EmptyView() + }) +} diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift index b29c606012..15cb2d3410 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift @@ -23,7 +23,9 @@ struct MainView: View { var body: some View { NavigationSplitView { List(selection: self.$navigation.selectedCategory) { - if !self.rootOwnerViewModel.isCompanyConnected { + if self.rootOwnerViewModel.isCompanyConnected { + CaregiverSettingsLabel() + } else { NoAccountConnectedLabel() } @@ -46,27 +48,22 @@ struct MainView: View { CategoryLabel(category: .stories) } - HStack { - Spacer() - VStack(spacing: 20) { + VStack(alignment: .center, spacing: 20) { + if self.rootOwnerViewModel.isCompanyConnected { Button { self.rootOwnerViewModel.isSettingsViewPresented = true } label: { SettingsLabel() } - - Text("My Leka App - Version \(Bundle.version!) (\(Bundle.buildNumber!))") - .foregroundColor(.gray) - .font(.caption2) } - Spacer() - } - HStack { - Spacer() + Text("My Leka App - Version \(Bundle.version!) (\(Bundle.buildNumber!))") + .foregroundColor(.gray) + .font(.caption2) + LekaLogo(width: 50) - Spacer() } + .frame(maxWidth: .infinity) } // TODO: (@ladislas) remove if not necessary // .disabled(navigation.disableUICompletly) @@ -113,9 +110,15 @@ struct MainView: View { .fullScreenCover(isPresented: self.$viewModel.isRobotConnectionPresented) { RobotConnectionView(viewModel: RobotConnectionViewModel()) } + .fullScreenCover(isPresented: self.$rootOwnerViewModel.isCaregiverPickerViewPresented) { + CaregiverPicker() + } .sheet(isPresented: self.$rootOwnerViewModel.isSettingsViewPresented) { SettingsView() } + .sheet(isPresented: self.$rootOwnerViewModel.isCaregiverSettingsViewPresented) { + CaregiverSettingsView(modifiedCaregiver: self.rootOwnerViewModel.currentCaregiver!) + } } } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift index 9fba4eaa36..8dad9a9923 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift @@ -17,12 +17,12 @@ class RootOwnerViewModel: ObservableObject { static let shared = RootOwnerViewModel() @Published var currentCompany: Company? - - @Published var bufferCaregiver = Caregiver() - @Published var bufferCarereceiver = Carereceiver() + @Published var currentCaregiver: Caregiver? @Published var isWelcomeViewPresented = true @Published var isSettingsViewPresented = false + @Published var isCaregiverSettingsViewPresented = false + @Published var isCaregiverPickerViewPresented = false @Published var showConfirmCredentialsChange: Bool = false @Published var showConfirmDisconnection: Bool = false @@ -30,11 +30,11 @@ class RootOwnerViewModel: ObservableObject { @Published var mockCaregiversSet: [Caregiver] = [ Caregiver(name: "Chantal", avatar: DesignKitAsset.Avatars.avatarsBoy4f.name, professions: [Caregiver.Profession.motorTherapist]), - Caregiver(name: "Gaëtan", avatar: DesignKitAsset.Avatars.avatarsLekaSunglassesBlue.name, professions: [Caregiver.Profession.occupationalTherapist]), + Caregiver(name: "Gaëtan", avatar: DesignKitAsset.Avatars.avatarsLekaSunglassesBlue.name, professions: [Caregiver.Profession.occupationalTherapist], colorScheme: .dark, accentColor: .green), Caregiver(name: "Fabrizio", avatar: DesignKitAsset.Avatars.avatarsPictogramsAnimalsFarmBirdYellow0071.name, professions: [Caregiver.Profession.speechTherapist]), Caregiver(name: "Hakima", avatar: DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsPearYellow00FC.name, professions: [Caregiver.Profession.other(profession: "chirurgien")]), Caregiver(name: "Eric", avatar: DesignKitAsset.Avatars.avatarsBoy2a.name, professions: [Caregiver.Profession.motorTherapist]), - Caregiver(name: "Razmo", avatar: DesignKitAsset.Avatars.avatarsBoy3b.name, professions: [Caregiver.Profession.motorTherapist]), + Caregiver(name: "Razmo", avatar: DesignKitAsset.Avatars.avatarsBoy3b.name, professions: [Caregiver.Profession.motorTherapist], colorScheme: .dark, accentColor: .orange), Caregiver(name: "Corinne", avatar: DesignKitAsset.Avatars.avatarsGirl1d.name, professions: [Caregiver.Profession.motorTherapist]), Caregiver(name: "Alphonso", avatar: DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsAppleRed0101.name, professions: [Caregiver.Profession.motorTherapist]), Caregiver(name: "Gargantua", avatar: DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsCherryRed00FF.name, professions: [Caregiver.Profession.motorTherapist]), @@ -46,5 +46,6 @@ class RootOwnerViewModel: ObservableObject { func disconnect() { self.currentCompany = nil + self.currentCaregiver = nil } } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/ProfessionPicker/ProfessionPicker+Tag.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/ProfessionPicker/ProfessionPicker+Tag.swift index 3271bc1e1b..75eed8d7b4 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/ProfessionPicker/ProfessionPicker+Tag.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/ProfessionPicker/ProfessionPicker+Tag.swift @@ -9,6 +9,7 @@ extension ProfessionPicker { struct ProfessionTag: View { @ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared @State var profession: Caregiver.Profession + @Binding var caregiver: Caregiver var body: some View { Button { @@ -19,7 +20,7 @@ extension ProfessionPicker { Image(systemName: "multiply.square.fill") .onTapGesture { - self.rootOwnerViewModel.bufferCaregiver.professions.removeAll(where: { self.profession == $0 }) + self.caregiver.professions.removeAll(where: { self.profession == $0 }) } } } @@ -31,5 +32,8 @@ extension ProfessionPicker { } #Preview { - ProfessionPicker.ProfessionTag(profession: Caregiver.Profession.occupationalTherapist) + ProfessionPicker.ProfessionTag( + profession: Caregiver.Profession.occupationalTherapist, + caregiver: .constant(Caregiver(professions: [Caregiver.Profession.occupationalTherapist, Caregiver.Profession.motorTherapist])) + ) } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/ProfessionPicker/ProfessionPicker.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/ProfessionPicker/ProfessionPicker.swift index c650457896..2474b4833f 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/ProfessionPicker/ProfessionPicker.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/ProfessionPicker/ProfessionPicker.swift @@ -11,12 +11,13 @@ import SwiftUI struct ProfessionPicker: View { // MARK: Internal + @Binding var caregiver: Caregiver @Environment(\.dismiss) var dismiss var body: some View { ListView(selectedProfessions: self.$selectedProfessions) .onAppear { - self.selectedProfessions = self.rootOwnerViewModel.bufferCaregiver.professions + self.selectedProfessions = self.caregiver.professions } .safeAreaInset(edge: .bottom) { TextFieldDefault(label: String(l10n.ProfessionPicker.otherLabel.characters), entry: self.$otherProfessionText) @@ -30,7 +31,7 @@ struct ProfessionPicker: View { .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button { - self.rootOwnerViewModel.bufferCaregiver.professions = self.selectedProfessions + self.caregiver.professions = self.selectedProfessions self.dismiss() } label: { Label(String(l10n.ProfessionPicker.validateButton.characters), systemImage: "checkmark.circle") @@ -42,7 +43,6 @@ struct ProfessionPicker: View { // MARK: Private - @ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared @State private var otherProfessionText: String = "" @State private var selectedProfessions: [Caregiver.Profession] = [] } @@ -50,5 +50,5 @@ struct ProfessionPicker: View { // MARK: - ProfessionPicker_Previews #Preview { - ProfessionPicker() + ProfessionPicker(caregiver: .constant(Caregiver())) } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift index 95c8c4cfc2..8b1fddeab3 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift @@ -9,13 +9,18 @@ struct CaregiverAvatarCell: View { // MARK: Internal @ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared + @ObservedObject private var styleManager: StyleManager = .shared let caregiver: Caregiver var body: some View { Button { // TODO: (@team) - Add caregiver selection logic w/ Firebase + self.rootOwnerViewModel.currentCaregiver = self.caregiver + self.styleManager.colorScheme = self.caregiver.preferredColorScheme + self.styleManager.accentColor = self.caregiver.preferredAccentColor self.rootOwnerViewModel.isWelcomeViewPresented = false + self.rootOwnerViewModel.isCaregiverPickerViewPresented = false } label: { VStack(spacing: 10) { Image(self.caregiver.avatar, bundle: Bundle(for: DesignKitResources.self)) diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverPicker.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverPicker.swift index fe8a9d8bd8..a45ca47413 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverPicker.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverPicker.swift @@ -12,23 +12,25 @@ struct CaregiverPicker: View { // MARK: Internal var body: some View { - VStack { - ScrollView(showsIndicators: false) { - LazyVGrid(columns: self.columns, spacing: 40) { - ForEach(self.rootOwnerViewModel.mockCaregiversSet) { caregiver in - CaregiverAvatarCell(caregiver: caregiver) - } + NavigationStack { + VStack { + ScrollView(showsIndicators: false) { + LazyVGrid(columns: self.columns, spacing: 40) { + ForEach(self.rootOwnerViewModel.mockCaregiversSet) { caregiver in + CaregiverAvatarCell(caregiver: caregiver) + } - // ? Last item is Add profile button - self.addCaregiverButton + // ? Last item is Add profile button + self.addCaregiverButton + } + .padding() } - .padding() } - } - .padding(.horizontal, 50) - .navigationTitle(String(l10n.CaregiverPicker.title.characters)) - .sheet(isPresented: self.$isCaregiverCreationPresented) { - CreateCaregiverView(isPresented: self.$isCaregiverCreationPresented) {} + .padding(.horizontal, 50) + .navigationTitle(String(l10n.CaregiverPicker.title.characters)) + .sheet(isPresented: self.$isCaregiverCreationPresented) { + CreateCaregiverView(isPresented: self.$isCaregiverCreationPresented) {} + } } } @@ -40,7 +42,6 @@ struct CaregiverPicker: View { @State private var selected: String = "" @State private var isCaregiverCreationPresented: Bool = false - @State private var navigateToTeacherCreation: Bool = false private var addCaregiverButton: some View { Button { diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCaregiverView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCaregiverView.swift index bcca72a778..7c64730a1d 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCaregiverView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCaregiverView.swift @@ -12,6 +12,7 @@ struct CreateCaregiverView: View { // MARK: Internal @Binding var isPresented: Bool + @State private var newCaregiver = Caregiver() var onDismissAction: () -> Void var body: some View { @@ -21,7 +22,7 @@ struct CreateCaregiverView: View { self.avatarNavigationLink TextFieldDefault(label: String(l10n.CaregiverCreation.caregiverNameLabel.characters), - entry: self.$rootOwnerViewModel.bufferCaregiver.name) + entry: self.$newCaregiver.name) .frame(width: 400) self.professionNavigationLink @@ -33,9 +34,9 @@ struct CreateCaregiverView: View { } // TODO: (@team) : add the caregiver profile to the account // TODO: (@team) : assign the caregiver profile as the current selected one - self.rootOwnerViewModel.mockCaregiversSet.append(self.rootOwnerViewModel.bufferCaregiver) + self.rootOwnerViewModel.mockCaregiversSet.append(self.newCaregiver) } - .disabled(self.rootOwnerViewModel.bufferCaregiver.name.isEmpty) + .disabled(self.newCaregiver.name.isEmpty) .buttonStyle(.borderedProminent) } .padding() @@ -50,10 +51,10 @@ struct CreateCaregiverView: View { private var avatarNavigationLink: some View { NavigationLink { - AvatarPicker(avatar: self.$rootOwnerViewModel.bufferCaregiver.avatar) + AvatarPicker(avatar: self.$newCaregiver.avatar) } label: { VStack(spacing: 15) { - AvatarPicker.ButtonLabel(image: self.rootOwnerViewModel.bufferCaregiver.avatar) + AvatarPicker.ButtonLabel(image: self.newCaregiver.avatar) Text(l10n.CaregiverCreation.avatarChoiceButton) // TODO: (@ui/ux) - Design System - replace with Leka font .font(.headline) @@ -71,15 +72,15 @@ struct CreateCaregiverView: View { Spacer() NavigationLink { - ProfessionPicker() + ProfessionPicker(caregiver: self.$newCaregiver) } label: { Label(String(l10n.CaregiverCreation.professionAddButton.characters), systemImage: "plus") } } - if !self.rootOwnerViewModel.bufferCaregiver.professions.isEmpty { - ForEach(self.rootOwnerViewModel.bufferCaregiver.professions, id: \.self) { profession in - ProfessionPicker.ProfessionTag(profession: profession) + if !self.newCaregiver.professions.isEmpty { + ForEach(self.newCaregiver.professions, id: \.self) { profession in + ProfessionPicker.ProfessionTag(profession: profession, caregiver: self.$newCaregiver) } } } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCarereceiverView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCarereceiverView.swift index 049b884438..130e56f27d 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCarereceiverView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCarereceiverView.swift @@ -12,6 +12,7 @@ struct CreateCarereceiverView: View { // MARK: Internal @Binding var isPresented: Bool + @State private var newCarereceiver = Carereceiver() var onDismissAction: () -> Void var body: some View { @@ -21,7 +22,7 @@ struct CreateCarereceiverView: View { self.avatarNavigationLink TextFieldDefault(label: String(l10n.CarereceiverCreation.carereceiverNameLabel.characters), - entry: self.$rootOwnerViewModel.bufferCarereceiver.name) + entry: self.$newCarereceiver.name) .frame(width: 400) Button(String(l10n.CarereceiverCreation.registerProfilButton.characters)) { @@ -32,7 +33,7 @@ struct CreateCarereceiverView: View { // TODO: (@team) : add the carereceiver profile to the account // TODO: (@team) : assign the carereceiver profile as the current selected one } - .disabled(self.rootOwnerViewModel.bufferCarereceiver.name.isEmpty) + .disabled(self.newCarereceiver.name.isEmpty) .buttonStyle(.borderedProminent) } .padding() @@ -47,10 +48,10 @@ struct CreateCarereceiverView: View { private var avatarNavigationLink: some View { NavigationLink { - AvatarPicker(avatar: self.$rootOwnerViewModel.bufferCarereceiver.avatar) + AvatarPicker(avatar: self.$newCarereceiver.avatar) } label: { VStack(spacing: 15) { - AvatarPicker.ButtonLabel(image: self.rootOwnerViewModel.bufferCarereceiver.avatar) + AvatarPicker.ButtonLabel(image: self.newCarereceiver.avatar) Text(l10n.CarereceiverCreation.avatarChoiceButton) // TODO: (@ui/ux) - Design System - replace with Leka font .font(.headline) diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AppearanceRow.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AppearanceRow.swift deleted file mode 100644 index 14c696ca26..0000000000 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AppearanceRow.swift +++ /dev/null @@ -1,42 +0,0 @@ -// Leka - iOS Monorepo -// Copyright APF France handicap -// SPDX-License-Identifier: Apache-2.0 - -import DesignKit -import LocalizationKit -import SwiftUI - -// MARK: - SettingsView.AppearanceSection - -extension SettingsView.AppearanceSection { - struct AppearanceRow: View { - // MARK: Internal - - @ObservedObject var styleManager: StyleManager = .shared - - var body: some View { - HStack(spacing: 10) { - Text(l10n.SettingsView.AppearanceSection.AppearanceRow.title) - - Spacer() - - Toggle("", isOn: Binding( - get: { self.styleManager.colorScheme == .dark }, - set: { self.styleManager.colorScheme = $0 ? .dark : .light } - )) - } - } - - // MARK: Private - - private var selectedColorScheme: ColorScheme { - self.styleManager.colorScheme - } - } -} - -#Preview { - Form { - SettingsView.AppearanceSection() - } -} diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection.swift deleted file mode 100644 index e4ca0e28df..0000000000 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection.swift +++ /dev/null @@ -1,26 +0,0 @@ -// Leka - iOS Monorepo -// Copyright APF France handicap -// SPDX-License-Identifier: Apache-2.0 - -import DesignKit -import LocalizationKit -import SwiftUI - -// MARK: - SettingsView.AppearanceSection - -extension SettingsView { - struct AppearanceSection: View { - var body: some View { - Section(String(l10n.SettingsView.AppearanceSection.header.characters)) { - AppearanceRow() - AccentColorRow() - } - } - } -} - -#Preview { - Form { - SettingsView.AppearanceSection() - } -} diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+l10n.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+l10n.swift index 3152e077ac..98480fdde3 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+l10n.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+l10n.swift @@ -8,18 +8,6 @@ import LocalizationKit extension l10n { enum SettingsView { - enum AppearanceSection { - enum AppearanceRow { - static let title = LocalizedString("settings_view.appearance_section.appearance_row.title", value: "Dark mode", comment: "Appearance Row title") - } - - enum AccentColorRow { - static let title = LocalizedString("settings_view.appearance_section.accent_color_row.title", value: "Accent Color", comment: "AccentColor Row title") - } - - static let header = LocalizedString("settings_view.appearance_section.header", value: "Appearance", comment: "Appearance section header") - } - enum CredentialsSection { enum ChangeCredentials { static let buttonLabel = LocalizedString("settings_view.credentials_section.change_credentials.button_label", value: "Change email and password", comment: "Change credentials button label") diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift index 4098d4dac7..3ed84de520 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift @@ -15,12 +15,8 @@ struct SettingsView: View { var body: some View { NavigationStack { Form { - AppearanceSection() - - if self.rootOwnerViewModel.isCompanyConnected { - CredentialsSection() - AccountSection() - } + CredentialsSection() + AccountSection() } .navigationTitle(String(l10n.SettingsView.navigationTitle.characters)) .navigationBarTitleDisplayMode(.inline)