Explorar el Código

suffix -> units, make color field consistent with textColor

1. suffix -> units
2. make color field consistent with textColor in name and optionality
Aidan Lane hace 10 meses
padre
commit
2fd3e357c3

+ 1 - 1
Trio/Sources/Modules/Calibrations/View/CalibrationsRootView.swift

@@ -49,7 +49,7 @@ extension Calibrations {
                                 text: $state.newCalibration,
                                 placeholder: "0",
                                 numberFormatter: manualGlucoseFormatter,
-                                suffixText: state.units.rawValue
+                                unitsText: state.units.rawValue
                             )
                         }
                         Button {

+ 3 - 3
Trio/Sources/Modules/DataTable/View/CarbEntryEditorView.swift

@@ -139,7 +139,7 @@ struct CarbEntryEditorView: View {
                             placeholder: "0",
                             keyboardType: .numberPad,
                             numberFormatter: mealFormatter,
-                            suffixText: "g"
+                            unitsText: "g"
                         )
                     }
 
@@ -151,7 +151,7 @@ struct CarbEntryEditorView: View {
                                 placeholder: "0",
                                 keyboardType: .numberPad,
                                 numberFormatter: mealFormatter,
-                                suffixText: "g"
+                                unitsText: "g"
                             )
                         }
 
@@ -162,7 +162,7 @@ struct CarbEntryEditorView: View {
                                 placeholder: "0",
                                 keyboardType: .numberPad,
                                 numberFormatter: mealFormatter,
-                                suffixText: "g"
+                                unitsText: "g"
                             )
                         }
                     }

+ 1 - 1
Trio/Sources/Modules/DataTable/View/DataTableRootView.swift

@@ -441,7 +441,7 @@ extension DataTable {
                                     keyboardType: state.units == .mgdL ? .numberPad : .decimalPad,
                                     numberFormatter: manualGlucoseFormatter,
                                     initialFocus: true,
-                                    suffixText: state.units.rawValue
+                                    unitsText: state.units.rawValue
                                 )
                             }
                         }.listRowBackground(Color.chart)

+ 1 - 1
Trio/Sources/Modules/ManualTempBasal/View/ManualTempBasalRootView.swift

@@ -28,7 +28,7 @@ extension ManualTempBasal {
                             placeholder: "0",
                             numberFormatter: formatter,
                             initialFocus: true,
-                            suffixText: "U/hr"
+                            unitsText: "U/hr"
                         )
                     }
                     Picker(selection: $state.durationIndex, label: Text("Duration")) {

+ 3 - 3
Trio/Sources/Modules/Treatments/View/MealPreset/AddMealPresetView.swift

@@ -76,7 +76,7 @@ struct AddMealPresetView: View {
                 placeholder: "0",
                 keyboardType: .numberPad,
                 numberFormatter: mealFormatter,
-                suffixText: "g"
+                unitsText: "g"
             )
         }
     }
@@ -90,7 +90,7 @@ struct AddMealPresetView: View {
                 placeholder: "0",
                 keyboardType: .numberPad,
                 numberFormatter: mealFormatter,
-                suffixText: "g"
+                unitsText: "g"
             )
         }
         HStack {
@@ -101,7 +101,7 @@ struct AddMealPresetView: View {
                 placeholder: "0",
                 keyboardType: .numberPad,
                 numberFormatter: mealFormatter,
-                suffixText: "g"
+                unitsText: "g"
             )
         }
     }

+ 4 - 4
Trio/Sources/Modules/Treatments/View/TreatmentsRootView.swift

@@ -94,7 +94,7 @@ extension Treatments {
                         showArrows: true,
                         previousTextField: { focusedField = previousField(from: .protein) },
                         nextTextField: { focusedField = nextField(from: .protein) },
-                        suffixText: "g"
+                        unitsText: "g"
                     )
                     .focused($focusedField, equals: .protein)
                 }
@@ -111,7 +111,7 @@ extension Treatments {
                         showArrows: true,
                         previousTextField: { focusedField = previousField(from: .fat) },
                         nextTextField: { focusedField = nextField(from: .fat) },
-                        suffixText: "g"
+                        unitsText: "g"
                     )
                     .focused($focusedField, equals: .fat)
                 }
@@ -130,7 +130,7 @@ extension Treatments {
                     showArrows: true,
                     previousTextField: { focusedField = previousField(from: .carbs) },
                     nextTextField: { focusedField = nextField(from: .carbs) },
-                    suffixText: "g"
+                    unitsText: "g"
                 )
                 .focused($focusedField, equals: .carbs)
                 .onChange(of: state.carbs) {
@@ -332,7 +332,7 @@ extension Treatments {
                                     showArrows: true,
                                     previousTextField: { focusedField = previousField(from: .bolus) },
                                     nextTextField: { focusedField = nextField(from: .bolus) },
-                                    suffixText: "U"
+                                    unitsText: "U"
                                 ).focused($focusedField, equals: .bolus)
                                     .onChange(of: state.amount) {
                                         Task {

+ 8 - 8
Trio/Sources/Views/TextFieldWithToolBar.swift

@@ -18,8 +18,8 @@ public struct TextFieldWithToolBar: View {
     var previousTextField: (() -> Void)?
     var nextTextField: (() -> Void)?
     var initialFocus: Bool
-    var suffixText: String?
-    var suffixForegroundColor: Color?
+    var unitsText: String?
+    var unitsTextColor: Color
 
     @FocusState private var isFocused: Bool
     @State private var localText: String = ""
@@ -43,8 +43,8 @@ public struct TextFieldWithToolBar: View {
         previousTextField: (() -> Void)? = nil,
         nextTextField: (() -> Void)? = nil,
         initialFocus: Bool = false,
-        suffixText: String? = nil,
-        suffixForegroundColor: Color = .secondary
+        unitsText: String? = nil,
+        unitsTextColor: Color = .secondary
     ) {
         _text = text
         self.placeholder = placeholder
@@ -63,8 +63,8 @@ public struct TextFieldWithToolBar: View {
         self.previousTextField = previousTextField
         self.nextTextField = nextTextField
         self.initialFocus = initialFocus
-        self.suffixText = suffixText
-        self.suffixForegroundColor = suffixForegroundColor
+        self.unitsText = unitsText
+        self.unitsTextColor = unitsTextColor
     }
 
     public var body: some View {
@@ -210,8 +210,8 @@ public struct TextFieldWithToolBar: View {
                     // Set initial focus if requested
                     isFocused = initialFocus
                 }
-            if suffixText != nil {
-                Text(suffixText ?? "").foregroundColor(suffixForegroundColor ?? .secondary)
+            if unitsText != nil {
+                Text(unitsText ?? "").foregroundColor(unitsTextColor)
                     .onTapGesture {
                         isFocused = true
                     }