Skip to content

Commit

Permalink
♻️ (LekaApp): Keep current profile when displaying picker from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Feb 22, 2024
1 parent abfb434 commit eb731a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct MainView: View {
ActivityView(activity: activity)
}
.sheet(isPresented: self.$rootOwnerViewModel.isSettingsViewPresented) {
SettingsView()
SettingsView(isCaregiverPickerPresented: self.$isCaregiverPickerPresented)
}
.sheet(isPresented: self.$rootOwnerViewModel.isEditCaregiverViewPresented) {
EditCaregiverView(modifiedCaregiver: self.rootOwnerViewModel.currentCaregiver!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ extension SettingsView {
struct ProfilesSection: View {
// MARK: Internal

@Binding var isCaregiverPickerPresented: Bool

var body: some View {
Section(String(l10n.SettingsView.ProfilesSection.header.characters)) {
Button {
self.rootOwnerViewModel.isSettingsViewPresented = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
self.rootOwnerViewModel.currentCaregiver = nil
self.isCaregiverPickerPresented = true
}
} label: {
Label(String(l10n.SettingsView.ProfilesSection.switchProfileButtonLabel.characters), systemImage: "person.2.gobackward")
Expand All @@ -32,5 +34,5 @@ extension SettingsView {
}

#Preview {
SettingsView.ProfilesSection()
SettingsView.ProfilesSection(isCaregiverPickerPresented: .constant(false))
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import SwiftUI
// MARK: - SettingsView

struct SettingsView: View {
@ObservedObject var rootOwnerViewModel: RootOwnerViewModel = .shared
@ObservedObject var styleManager: StyleManager = .shared
@ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared
@ObservedObject private var styleManager: StyleManager = .shared
@Binding var isCaregiverPickerPresented: Bool

var body: some View {
NavigationStack {
Form {
CredentialsSection()
ProfilesSection()
ProfilesSection(isCaregiverPickerPresented: self.$isCaregiverPickerPresented)
AccountSection()
}
.navigationTitle(String(l10n.SettingsView.navigationTitle.characters))
Expand All @@ -34,5 +35,5 @@ struct SettingsView: View {
}

#Preview {
SettingsView()
SettingsView(isCaregiverPickerPresented: .constant(false))
}

0 comments on commit eb731a5

Please sign in to comment.