Prechádzať zdrojové kódy

Use same buttons in both bolus views

Jon Mårtensson 2 rokov pred
rodič
commit
020290aef1

+ 7 - 4
FreeAPS/Sources/Modules/Bolus/View/AlternativeBolusCalcRootView.swift

@@ -147,10 +147,9 @@ extension Bolus {
                         }
                         label: { Text(exceededMaxBolus ? "Max Bolus exceeded!" : "Enact bolus") }
                             .frame(maxWidth: .infinity, alignment: .center)
-                            .foregroundColor(exceededMaxBolus ? .loopRed : .accentColor)
-                            .disabled(
-                                state.amount <= 0 || state.amount > state.maxBolus
-                            )
+                            .disabled(disabled)
+                            .listRowBackground(!disabled ? Color(.systemBlue) : Color(.systemGray4))
+                            .tint(.white)
                     }
                 }
                 if state.amount <= 0 {
@@ -265,6 +264,10 @@ extension Bolus {
             )
         }
 
+        private var disabled: Bool {
+            state.amount <= 0 || state.amount > state.maxBolus
+        }
+
         var changed: Bool {
             ((meal.first?.carbs ?? 0) > 0) || ((meal.first?.fat ?? 0) > 0) || ((meal.first?.protein ?? 0) > 0)
         }

+ 7 - 3
FreeAPS/Sources/Modules/Bolus/View/DefaultBolusCalcRootView.swift

@@ -103,9 +103,9 @@ extension Bolus {
                             }
                             label: { Text(!(state.amount > state.maxBolus) ? "Enact bolus" : "Max Bolus exceeded!") }
                                 .frame(maxWidth: .infinity, alignment: .center)
-                                .disabled(
-                                    state.amount <= 0 || state.amount > state.maxBolus
-                                )
+                                .disabled(disabled)
+                                .listRowBackground(!disabled ? Color(.systemBlue) : Color(.systemGray4))
+                                .tint(.white)
                         }
                     }
                 }
@@ -163,6 +163,10 @@ extension Bolus {
             }
         }
 
+        var disabled: Bool {
+            state.amount <= 0 || state.amount > state.maxBolus
+        }
+
         var predictionChart: some View {
             ZStack {
                 PredictionView(