From a1c3d7648a944f38a31c30374a86013751c8caf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bj=C3=B6rkert?= Date: Thu, 14 Sep 2023 13:02:10 +0200 Subject: [PATCH] SettingsView --- Loop/Views/SettingsView.swift | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Loop/Views/SettingsView.swift b/Loop/Views/SettingsView.swift index af584097e0..58aa75df69 100644 --- a/Loop/Views/SettingsView.swift +++ b/Loop/Views/SettingsView.swift @@ -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 @@ -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 }, @@ -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 }