Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ (LekaApp): Keep current profile when displaying picker from settings #708

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
}
.frame(maxWidth: .infinity)
}
// TODO: (@ladislas) remove if not necessary

Check warning on line 79 in Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift

View workflow job for this annotation

GitHub Actions / swiftlint

TODOs should be resolved ((@ladislas) remove if not nece...) (todo)
// .disabled(navigation.disableUICompletly)
} detail: {
NavigationStack(path: self.$navigation.path) {
Expand Down Expand Up @@ -125,7 +125,7 @@
.fullScreenCover(isPresented: self.$viewModel.isRobotConnectionPresented) {
RobotConnectionView(viewModel: RobotConnectionViewModel())
}
// TODO: (@team) - Update this onReceive when caregiver are managed by AccountKit

Check warning on line 128 in Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift

View workflow job for this annotation

GitHub Actions / swiftlint

TODOs should be resolved ((@team) - Update this onReceiv...) (todo)
.onReceive(self.rootOwnerViewModel.$currentCaregiver) { caregiver in
if !self.authManagerViewModel.isUserLoggedOut {
self.isCaregiverPickerPresented = (caregiver == nil)
Expand All @@ -140,7 +140,7 @@
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))
}
Loading