فهرست منبع

Refactor meal settings

Deniz Cengiz 1 سال پیش
والد
کامیت
122a161b8d

+ 9 - 9
FreeAPS.xcodeproj/project.pbxproj

@@ -1399,43 +1399,43 @@
 		3811DE0325C9D31700A708ED /* Modules */ = {
 			isa = PBXGroup;
 			children = (
-				DDF847DB2C5C28550049BB3B /* LiveActivitySettings */,
-				DD09D4792C5986BA003FEA5D /* CalendarEventSettings */,
-				DD17454C2C55CA0200211FAC /* GeneralSettings */,
-				DD1745422C55C5C400211FAC /* AutosensSettings */,
 				DD1745382C55BF8B00211FAC /* AlgorithmAdvancedSettings */,
-				DD17452C2C55AE3500211FAC /* TargetBehavoir */,
-				DD17451E2C55520000211FAC /* SMBSettings */,
+				DD1745422C55C5C400211FAC /* AutosensSettings */,
 				672F63EEAE27400625E14BAD /* AutotuneConfig */,
 				A42F1FEDFFD0DDE00AAD54D3 /* BasalProfileEditor */,
 				3811DE0425C9D32E00A708ED /* Base */,
 				C2C98283C436DB934D7E7994 /* Bolus */,
 				BD7DA9A32AE06DBA00601B20 /* BolusCalculatorConfig */,
+				DD09D4792C5986BA003FEA5D /* CalendarEventSettings */,
 				CEE9A64D2BBB411C00EB5194 /* Calibrations */,
 				F75CB57ED6971B46F8756083 /* CGM */,
 				0610F7D6D2EC00E3BA1569F0 /* ConfigEditor */,
 				E42231DBF0DBE2B4B92D1B15 /* CREditor */,
 				9E56E3626FAD933385101B76 /* DataTable */,
 				195D80B22AF696EE00D25097 /* DynamicSettings */,
-				19D466A129AA2B0A004D5F33 /* MealSettings */,
+				DD17454C2C55CA0200211FAC /* GeneralSettings */,
+				F66B236E00924A05D6A9F9DF /* GlucoseNotificationSettings */,
 				F90692CD274B99850037068D /* HealthKit */,
 				3811DE2725C9D49500A708ED /* Home */,
 				19E1F7E629D0828B005C8D20 /* IconConfig */,
 				D8F047E14D567F2B5DBEFD96 /* ISFEditor */,
+				DDF847DB2C5C28550049BB3B /* LiveActivitySettings */,
 				3811DE1A25C9D48300A708ED /* Main */,
 				5031FE61F63C2A8A8B7674DD /* ManualTempBasal */,
+				19D466A129AA2B0A004D5F33 /* MealSettings */,
 				D533BF261CDC1C3F871E7BFD /* NightscoutConfig */,
-				F66B236E00924A05D6A9F9DF /* GlucoseNotificationSettings */,
 				DDD163032C4C67B400CD525A /* OverrideConfig */,
 				3E1C41D9301B7058AA7BF5EA /* PreferencesEditor */,
 				99C01B871ACAB3F32CE755C7 /* PumpConfig */,
 				E493126EA71765130F64CCE5 /* PumpSettingsEditor */,
 				3811DE3825C9D4A100A708ED /* Settings */,
 				110AEDEA2C51A0AE00615CC9 /* ShortcutsConfig */,
+				DD17451E2C55520000211FAC /* SMBSettings */,
 				29B478DF61BF8D270F7D8954 /* Snooze */,
 				19F95FF129F10F9C00314DDC /* Stat */,
-				190EBCC229FF134900BA767D /* UserInterfaceSettings */,
+				DD17452C2C55AE3500211FAC /* TargetBehavoir */,
 				6517011F19F244F64E1FF14B /* TargetsEditor */,
+				190EBCC229FF134900BA767D /* UserInterfaceSettings */,
 				CE94597C29E9E1CD0047C9C6 /* WatchConfig */,
 			);
 			path = Modules;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 143 - 47
FreeAPS/Sources/Modules/MealSettings/View/MealSettingsRootView.swift


+ 70 - 36
FreeAPS/Sources/Modules/ShortcutsConfig/View/ShortcutsConfigView.swift

@@ -6,52 +6,86 @@ import UIKit
 extension ShortcutsConfig {
     struct RootView: BaseView {
         let resolver: Resolver
+
         @StateObject var state = StateModel()
 
+        @State private var shouldDisplayHint: Bool = false
+        @State var hintDetent = PresentationDetent.large
+        @State var selectedVerboseHint: String?
+        @State var hintLabel: String?
+        @State private var decimalPlaceholder: Decimal = 0.0
+        @State private var booleanPlaceholder: Bool = false
+
+        @Environment(\.colorScheme) var colorScheme
+
+        private var color: LinearGradient {
+            colorScheme == .dark ? LinearGradient(
+                gradient: Gradient(colors: [
+                    Color.bgDarkBlue,
+                    Color.bgDarkerDarkBlue
+                ]),
+                startPoint: .top,
+                endPoint: .bottom
+            )
+                :
+                LinearGradient(
+                    gradient: Gradient(colors: [Color.gray.opacity(0.1)]),
+                    startPoint: .top,
+                    endPoint: .bottom
+                )
+        }
+
         var body: some View {
             Form {
-                Section(header: Text("Shortcuts", tableName: "ShortcutsDetail")) {
-                    Text(
-                        "The application lets you create automations using shortcuts. Go to the Shortcuts application to create new automations.",
-                        tableName: "ShortcutsDetail"
-                    )
-                    Button(String(localized: "Open Shortcuts app", table: "ShortcutsDetail")) {
-                        openShortcutsApp()
+                Section(
+                    header: Text("Shortcuts Integration"),
+                    content: {
+                        Text(
+                            "Trio lets you create automations using iOS Shortcuts. Go to the Shortcuts app to create new automations."
+                        )
                     }
-                }
+                ).listRowBackground(Color.chart)
 
-                Section(header: Text("Options", tableName: "ShorcutsDetail")) {
-                    Toggle(
-                        String(localized: "Allow bolusing with Shortcuts", table: "ShortcutsDetail"),
-                        isOn: $state.allowBolusByShortcuts
-                    )
+                Section {
+                    Button {
+                        UIApplication.shared.open(URL(string: "shortcuts://")!)
+                    }
+                    label: { Label("Open iOS Shortcuts", systemImage: "arrow.triangle.branch").font(.title3).padding() }
+                        .frame(maxWidth: .infinity, alignment: .center)
+                        .buttonStyle(.bordered)
                 }
+                .listRowBackground(Color.clear)
+
+                SettingInputSection(
+                    decimalValue: $decimalPlaceholder,
+                    booleanValue: $state.allowBolusByShortcuts,
+                    shouldDisplayHint: $shouldDisplayHint,
+                    selectedVerboseHint: Binding(
+                        get: { selectedVerboseHint },
+                        set: {
+                            selectedVerboseHint = $0
+                            hintLabel = "Allow Bolusing with Shortcuts"
+                        }
+                    ),
+                    type: .boolean,
+                    label: "Allow Bolusing with Shortcuts",
+                    miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
+                    verboseHint: "Allow Bolusing with Shortcuts… bla bla bla"
+                )
+            }
+            .sheet(isPresented: $shouldDisplayHint) {
+                SettingInputHintView(
+                    hintDetent: $hintDetent,
+                    shouldDisplayHint: $shouldDisplayHint,
+                    hintLabel: hintLabel ?? "",
+                    hintText: selectedVerboseHint ?? "",
+                    sheetTitle: "Help"
+                )
             }
+            .scrollContentBackground(.hidden).background(color)
             .onAppear(perform: configureView)
-            .navigationTitle(String(localized: "Shortcuts config", table: "ShortcutsDetail"))
+            .navigationTitle("Shortcuts")
             .navigationBarTitleDisplayMode(.automatic)
         }
-
-        private func openShortcutsApp() {
-            let shortcutsURL = URL(string: "shortcuts://")!
-
-            if UIApplication.shared.canOpenURL(shortcutsURL) {
-                UIApplication.shared.open(shortcutsURL, options: [:], completionHandler: { success in
-                    if !success {
-                        state.router.alertMessage
-                            .send(MessageContent(
-                                content: String(localized: "Unable to open the app", table: "ShortcutsDetail"),
-                                type: .warning
-                            ))
-                    }
-                })
-            } else {
-                router.alertMessage
-                    .send(MessageContent(
-                        content: String(localized: "Unable to open the app", table: "ShortcutsDetail"),
-                        type: .warning
-                    ))
-            }
-        }
     }
 }