diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift index 9fba4eaa36..34a99eb705 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift @@ -17,9 +17,7 @@ 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 @@ -46,5 +44,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..cb1d7407ca 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift @@ -15,6 +15,7 @@ struct CaregiverAvatarCell: View { var body: some View { Button { // TODO: (@team) - Add caregiver selection logic w/ Firebase + self.rootOwnerViewModel.currentCaregiver = self.caregiver self.rootOwnerViewModel.isWelcomeViewPresented = false } label: { VStack(spacing: 10) { diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverPicker.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverPicker.swift index fe8a9d8bd8..3f659dfa7b 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverPicker.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverPicker.swift @@ -40,7 +40,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)