瀏覽代碼

Add contact image help sheet and hint

Deniz Cengiz 1 年之前
父節點
當前提交
0e18ca8e51

+ 4 - 0
FreeAPS.xcodeproj/project.pbxproj

@@ -484,6 +484,7 @@
 		DD9ECB722CA9A0BA00AA7C45 /* RemoteControlConfigDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD9ECB6F2CA9A0BA00AA7C45 /* RemoteControlConfigDataFlow.swift */; };
 		DD9ECB742CA9A0C300AA7C45 /* RemoteControlConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD9ECB732CA9A0C300AA7C45 /* RemoteControlConfig.swift */; };
 		DDA6E2502D22187500C2988C /* ChartLegendView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDA6E24F2D22187500C2988C /* ChartLegendView.swift */; };
+		DDA6E3572D25988500C2988C /* ContactImageHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDA6E3562D25988500C2988C /* ContactImageHelpView.swift */; };
 		DDB37CC52D05048F00D99BF4 /* ContactImageStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB37CC42D05048F00D99BF4 /* ContactImageStorage.swift */; };
 		DDB37CC72D05127500D99BF4 /* FontExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB37CC62D05127500D99BF4 /* FontExtensions.swift */; };
 		DDCEBF5B2CC1B76400DF4C36 /* LiveActivity+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCEBF5A2CC1B76400DF4C36 /* LiveActivity+Helper.swift */; };
@@ -1187,6 +1188,7 @@
 		DD9ECB6F2CA9A0BA00AA7C45 /* RemoteControlConfigDataFlow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteControlConfigDataFlow.swift; sourceTree = "<group>"; };
 		DD9ECB732CA9A0C300AA7C45 /* RemoteControlConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteControlConfig.swift; sourceTree = "<group>"; };
 		DDA6E24F2D22187500C2988C /* ChartLegendView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChartLegendView.swift; sourceTree = "<group>"; };
+		DDA6E3562D25988500C2988C /* ContactImageHelpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactImageHelpView.swift; sourceTree = "<group>"; };
 		DDB37CC22D05044D00D99BF4 /* ContactTrickEntryStored+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContactTrickEntryStored+CoreDataClass.swift"; sourceTree = "<group>"; };
 		DDB37CC32D05044D00D99BF4 /* ContactTrickEntryStored+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContactTrickEntryStored+CoreDataProperties.swift"; sourceTree = "<group>"; };
 		DDB37CC42D05048F00D99BF4 /* ContactImageStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactImageStorage.swift; sourceTree = "<group>"; };
@@ -2997,6 +2999,7 @@
 		E592A3722CEEC038009A472C /* View */ = {
 			isa = PBXGroup;
 			children = (
+				DDA6E3562D25988500C2988C /* ContactImageHelpView.swift */,
 				E592A3712CEEC038009A472C /* ContactImageRootView.swift */,
 				BDC531112D1060FA00088832 /* ContactImageDetailView.swift */,
 				BDC531132D10611D00088832 /* AddContactImageSheet.swift */,
@@ -3547,6 +3550,7 @@
 				DDA6E2502D22187500C2988C /* ChartLegendView.swift in Sources */,
 				3811DEAF25C9D88300A708ED /* KeyValueStorage.swift in Sources */,
 				DDD6D4D32CDE90720029439A /* HbA1cDisplayUnit.swift in Sources */,
+				DDA6E3572D25988500C2988C /* ContactImageHelpView.swift in Sources */,
 				38FE826D25CC8461001FF17A /* NightscoutAPI.swift in Sources */,
 				388358C825EEF6D200E024B2 /* BasalProfileEntry.swift in Sources */,
 				3811DE0B25C9D32F00A708ED /* BaseView.swift in Sources */,

+ 1 - 17
FreeAPS/Sources/Modules/ContactImage/View/AddContactImageSheet.swift

@@ -164,23 +164,7 @@ struct AddContactImageSheet: View {
                 }
             }
             .sheet(isPresented: $state.isHelpSheetPresented) {
-                NavigationStack {
-                    List {
-                        Text("Lorem Ipsum Dolor Sit Amet")
-                    }
-                    .padding(.trailing, 10)
-                    .navigationBarTitle("Help", displayMode: .inline)
-
-                    Button { state.isHelpSheetPresented.toggle() }
-                    label: { Text("Got it!").frame(maxWidth: .infinity, alignment: .center) }
-                        .buttonStyle(.bordered)
-                        .padding(.top)
-                }
-                .padding()
-                .presentationDetents(
-                    [.fraction(0.9), .large],
-                    selection: $state.helpSheetDetent
-                )
+                ContactImageHelpView(state: state, helpSheetDetent: $state.helpSheetDetent)
             }
         }
     }

+ 1 - 17
FreeAPS/Sources/Modules/ContactImage/View/ContactImageDetailView.swift

@@ -133,23 +133,7 @@ struct ContactImageDetailView: View {
             }
         }
         .sheet(isPresented: $state.isHelpSheetPresented) {
-            NavigationStack {
-                List {
-                    Text("Lorem Ipsum Dolor Sit Amet")
-                }
-                .padding(.trailing, 10)
-                .navigationBarTitle("Help", displayMode: .inline)
-
-                Button { state.isHelpSheetPresented.toggle() }
-                label: { Text("Got it!").frame(maxWidth: .infinity, alignment: .center) }
-                    .buttonStyle(.bordered)
-                    .padding(.top)
-            }
-            .padding()
-            .presentationDetents(
-                [.fraction(0.9), .large],
-                selection: $state.helpSheetDetent
-            )
+            ContactImageHelpView(state: state, helpSheetDetent: $state.helpSheetDetent)
         }
     }
 

+ 75 - 0
FreeAPS/Sources/Modules/ContactImage/View/ContactImageHelpView.swift

@@ -0,0 +1,75 @@
+import SwiftUI
+
+struct ContactImageHelpView: View {
+    var state: ContactImage.StateModel
+    var helpSheetDetent: Binding<PresentationDetent>
+
+    var body: some View {
+        NavigationStack {
+            List {
+                DefinitionRow(
+                    term: "How Trio Manages Contact Images",
+                    definition: Text(
+                        "Trio will automatically assign a name like 'Trio 1' to any contact image you add, and a create an entry under your iOS Contacts. Use the 'Save' button at the bottom to save your customized contact image."
+                    )
+                ).listRowBackground(Color.gray.opacity(0.1))
+
+                DefinitionRow(
+                    term: "Preview Contact Image",
+                    definition: Text(
+                        "See a live preview of your contact image design at the top of the screen. Changes made to styles, layouts, or settings are instantly reflected."
+                    )
+                ).listRowBackground(Color.gray.opacity(0.1))
+
+                DefinitionRow(term: "Customize Layout and Style", definition: VStack(alignment: .leading) {
+                    Text("Choose from multiple layout options using the Layout Picker in the 'Style' section.")
+                    Text("Enable High Contrast Mode for better visibility in certain conditions.")
+                    Text("Available Layouts:")
+                    Text("• Default: Single 'primary' value with up to two smaller values ('Top', 'Bottom') above and below it.")
+                    Text("• Split: Divides values into two separate areas of same size.")
+                }).listRowBackground(Color.gray.opacity(0.1))
+
+                DefinitionRow(term: "Set Display Values", definition: VStack(alignment: .leading) {
+                    Text("Select what values to show on the contact image (e.g., glucose, trend, none) for the available slots:")
+                    Text("• None: No value displayed.")
+                    Text("• Glucose Reading: Current CGM provided glucose value.")
+                    Text("• Eventual Glucose: Glucose value as forecasted by the oref algorithm.")
+                    Text("• Glucose Delta: Change in glucose value.")
+                    Text("• Glucose Trend: Direction of glucose change.")
+                    Text("• COB: Carbs on Board.")
+                    Text("• IOB: Insulin on Board.")
+                    Text("• Loop Status: Indicates current loop status (green, yellow, red).")
+                    Text("• Last Loop Time: Time of the last algorithm run.")
+                }).listRowBackground(Color.gray.opacity(0.1))
+
+                DefinitionRow(term: "Adjust Ring Settings", definition: VStack(alignment: .leading) {
+                    Text("Add visual Rings around the contact image to highlight information.")
+                    Text("Fine-tune the ring’s Width and Gap to suit your design preferences.")
+                    Text("Available Rings:")
+                    Text("• Hidden: No ring displayed.")
+                    Text("• Loop Status: Indicates current loop status (green, yellow, red).")
+                }).listRowBackground(Color.gray.opacity(0.1))
+
+                DefinitionRow(term: "Customize Fonts", definition: VStack(alignment: .leading) {
+                    Text("Select font size, weight, and width to match your style:")
+                    Text("• Font Size: Adjust the main text size.")
+                    Text("• Secondary Font Size: Adjust text size for values in split layouts.")
+                    Text("• Font Weight: Control how bold the text appears.")
+                    Text("• Font Width: Choose between standard or expanded text spacing.")
+                }).listRowBackground(Color.gray.opacity(0.1))
+            }
+            .scrollContentBackground(.hidden)
+            .navigationBarTitle("Help", displayMode: .inline)
+
+            Button { state.isHelpSheetPresented.toggle() }
+            label: { Text("Got it!").frame(maxWidth: .infinity, alignment: .center) }
+                .buttonStyle(.bordered)
+                .padding(.top)
+        }
+        .padding()
+        .presentationDetents(
+            [.fraction(0.9), .large],
+            selection: helpSheetDetent
+        )
+    }
+}

+ 9 - 0
FreeAPS/Sources/Modules/ContactImage/View/ContactImageRootView.swift

@@ -74,6 +74,15 @@ extension ContactImage {
                     }
                     .onDelete(perform: onDelete)
                 }
+
+                Section {} header: {
+                    Text(
+                        "Add one or more contacts to your iOS Contacts to display real-time Trio metrics on your watch face. Be sure to grant Trio full access to your Contacts when prompted."
+                    )
+                    .textCase(nil)
+                    .foregroundStyle(.secondary)
+                }
+
             }.listRowBackground(Color.chart)
         }
 

+ 2 - 1
FreeAPS/Sources/Services/Network/Nightscout/NightscoutManager.swift

@@ -1205,7 +1205,8 @@ extension BaseNightscoutManager {
                 // Handle "Eventual BG X >= Y"
                 let parts = glucoseValueString.components(separatedBy: " >= ")
                 if parts.count == 2 {
-                    let firstValue = parts[0].replacingOccurrences(of: "Eventual BG", with: "").trimmingCharacters(in: .whitespaces)
+                    let firstValue = parts[0].replacingOccurrences(of: "Eventual BG", with: "")
+                        .trimmingCharacters(in: .whitespaces)
                     let secondValue = parts[1].trimmingCharacters(in: .whitespaces)
                     let formattedFirstValue = convertToMmolL(firstValue)
                     let formattedSecondValue = convertToMmolL(secondValue)