Просмотр исходного кода

add descriptions from onboarding view

Marvin Polscheit 7 месяцев назад
Родитель
Сommit
55fd2c8d6e

+ 10 - 0
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -19504,6 +19504,16 @@
         }
       }
     },
+    "45 %@ / %@ = %@ %@" : {
+      "localizations" : {
+        "en" : {
+          "stringUnit" : {
+            "state" : "new",
+            "value" : "45 %1$@ / %2$@ = %3$@ %4$@"
+          }
+        }
+      }
+    },
     "50% is half effect:" : {
       "localizations" : {
         "bg" : {

+ 2 - 2
Trio/Sources/Modules/BasalProfileEditor/View/BasalProfileEditorRootView.swift

@@ -179,10 +179,10 @@ extension BasalProfileEditor {
                                 )
                                 .padding(.horizontal)
 
-                                Spacer(minLength: 20)
-
                                 // Total daily basal calculation
                                 if !state.items.isEmpty {
+                                    Spacer(minLength: 20)
+
                                     VStack(alignment: .leading, spacing: 0) {
                                         HStack {
                                             Text("Total")

+ 49 - 1
Trio/Sources/Modules/CarbRatioEditor/View/CarbRatioEditorRootView.swift

@@ -124,7 +124,55 @@ extension CarbRatioEditor {
                                     }
                                 )
                                 .padding(.horizontal)
-                                .id(bottomID)
+
+                                // Example calculation based on first carb ratio
+                                if !state.items.isEmpty {
+                                    Spacer(minLength: 20)
+
+                                    VStack(alignment: .leading, spacing: 8) {
+                                        Text("Example Calculation")
+                                            .font(.headline)
+                                            .padding(.horizontal)
+
+                                        VStack(alignment: .leading, spacing: 8) {
+                                            Text("For 45g of carbs, you would need:")
+                                                .font(.subheadline)
+                                                .padding(.horizontal)
+
+                                            let insulinNeeded = 45 /
+                                                Double(truncating: state.rateValues[state.items.first!.rateIndex] as NSNumber)
+                                            Text(
+                                                "45 \(String(localized: "g", comment: "Gram abbreviation")) / \(formatter.string(from: state.rateValues[state.items.first!.rateIndex] as NSNumber) ?? "--") = \(String(format: "%.1f", insulinNeeded)) \(String(localized: "U", comment: "Insulin unit abbreviation"))"
+                                            )
+                                            .font(.system(.body, design: .monospaced))
+                                            .foregroundColor(.orange)
+                                            .padding()
+                                            .frame(maxWidth: .infinity, alignment: .center)
+                                            .background(Color.chart.opacity(0.65))
+                                            .cornerRadius(10)
+                                        }
+                                    }
+
+                                    Spacer(minLength: 20)
+
+                                    // Information about the carb ratio
+                                    VStack(alignment: .leading, spacing: 8) {
+                                        Text("What This Means")
+                                            .font(.headline)
+                                            .padding(.horizontal)
+
+                                        VStack(alignment: .leading, spacing: 4) {
+                                            Text("• A ratio of 10 g/U means 1 unit of insulin covers 10g of carbs")
+                                            Text("• A lower number means you need more insulin for the same amount of carbs")
+                                            Text("• A higher number means you need less insulin for the same amount of carbs")
+                                            Text("• Different times of day may require different ratios")
+                                        }
+                                        .font(.caption)
+                                        .foregroundColor(.secondary)
+                                        .padding(.horizontal)
+                                    }
+                                    .id(bottomID)
+                                }
                             }
                         }
                     }

+ 57 - 1
Trio/Sources/Modules/ISFEditor/View/ISFEditorRootView.swift

@@ -128,7 +128,63 @@ extension ISFEditor {
                                     }
                                 )
                                 .padding(.horizontal)
-                                .id(bottomID)
+
+                                // Example calculation based on first ISF
+                                if !state.items.isEmpty {
+                                    Spacer(minLength: 20)
+
+                                    VStack(alignment: .leading, spacing: 8) {
+                                        Text("Example Calculation")
+                                            .font(.headline)
+                                            .padding(.horizontal)
+
+                                        VStack(alignment: .leading, spacing: 8) {
+                                            let aboveTarget = state.units == .mgdL ? Decimal(40) : 40.asMmolL
+                                            let firstIsfRate: Decimal = state.rateValues[state.items.first?.rateIndex ?? 0]
+                                            let isfValue = state.units == .mgdL ? firstIsfRate : firstIsfRate.asMmolL
+                                            let insulinNeeded = aboveTarget / isfValue
+
+                                            Text(
+                                                "If you are \(numberFormatter.string(from: aboveTarget as NSNumber) ?? "--") \(state.units.rawValue) above target:"
+                                            )
+                                            .font(.subheadline)
+                                            .padding(.horizontal)
+
+                                            Text(
+                                                "\(aboveTarget.description) \(state.units.rawValue) / \(isfValue.description) \(state.units.rawValue)/\(String(localized: "U", comment: "Insulin unit abbreviation")) = \(String(format: "%.1f", Double(insulinNeeded))) \(String(localized: "U", comment: "Insulin unit abbreviation"))"
+                                            )
+                                            .font(.system(.body, design: .monospaced))
+                                            .foregroundColor(.cyan)
+                                            .padding()
+                                            .frame(maxWidth: .infinity, alignment: .center)
+                                            .background(Color.chart.opacity(0.65))
+                                            .cornerRadius(10)
+                                        }
+                                    }
+
+                                    Spacer(minLength: 20)
+
+                                    // Information about ISF
+                                    VStack(alignment: .leading, spacing: 8) {
+                                        Text("What This Means")
+                                            .font(.headline)
+                                            .padding(.horizontal)
+
+                                        VStack(alignment: .leading, spacing: 4) {
+                                            let isfValue =
+                                                "\(state.units == .mgdL ? Decimal(50) : 50.asMmolL)\(state.units.rawValue)"
+                                            Text(
+                                                "• An ISF of \(isfValue) means 1 U lowers your glucose by \(isfValue)"
+                                            )
+                                            Text("• A lower number means you're more sensitive to insulin")
+                                            Text("• A higher number means you're less sensitive to insulin")
+                                        }
+                                        .font(.caption)
+                                        .foregroundColor(.secondary)
+                                        .padding(.horizontal)
+                                    }
+                                    .id(bottomID)
+                                }
                             }
                         }
                     }