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

Profile switching #2002

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
28 changes: 26 additions & 2 deletions Loop/Views/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public struct SettingsView: View {
@ObservedObject var viewModel: SettingsViewModel
@ObservedObject var versionUpdateViewModel: VersionUpdateViewModel

@State private var profilesIsPresented: Bool = false
@State private var pumpChooserIsPresented: Bool = false
@State private var cgmChooserIsPresented: Bool = false
@State private var favoriteFoodsIsPresented: Bool = false
Expand Down Expand Up @@ -201,7 +202,11 @@ extension SettingsView {
}
}
}


private var isAnySheetPresented: Bool {
therapySettingsIsPresented || profilesIsPresented
}

private var configurationSection: some View {
Section(header: SectionHeader(label: NSLocalizedString("Configuration", comment: "The title of the Configuration section in settings"))) {
LargeButton(action: { self.therapySettingsIsPresented = true },
Expand All @@ -224,7 +229,26 @@ extension SettingsView {
.environment(\.guidanceColors, self.guidanceColors)
.environment(\.insulinTintColor, self.insulinTintColor)
}

LargeButton(action: { self.profilesIsPresented = true },
includeArrow: true,
imageView: AnyView(Image(systemName: "arrow.triangle.2.circlepath").font(.system(size: 30, weight: .bold))),
label: NSLocalizedString("Profiles", comment: "Title text for button to Profiles"),
descriptiveText: NSLocalizedString("Switch between profiles for different scenarios", comment: "Descriptive text for Profiles"))
.sheet(isPresented: $profilesIsPresented) {
ProfileView(viewModel: ProfileViewModel(therapySettings: self.viewModel.therapySettings(),
sensitivityOverridesEnabled: FeatureFlags.sensitivityOverridesEnabled,
adultChildInsulinModelSelectionEnabled: FeatureFlags.adultChildInsulinModelSelectionEnabled,
delegate: self.viewModel.therapySettingsViewModelDelegate))
.environmentObject(displayGlucosePreference)
.environment(\.dismissAction, self.dismiss)
.environment(\.appName, self.appName)
.environment(\.chartColorPalette, .primary)
.environment(\.carbTintColor, self.carbTintColor)
.environment(\.glucoseTintColor, self.glucoseTintColor)
.environment(\.guidanceColors, self.guidanceColors)
.environment(\.insulinTintColor, self.insulinTintColor)
}

ForEach(pluginMenuItems.filter {$0.section == .configuration}) { item in
item.view
}
Expand Down