Преглед на файлове

Format bolus amount on watch according to bolusIncrement

Mike Plante преди 1 година
родител
ревизия
2448b7be9c
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4 2
      Trio Watch App Extension/Views/BolusInputView.swift

+ 4 - 2
Trio Watch App Extension/Views/BolusInputView.swift

@@ -74,8 +74,10 @@ struct BolusInputView: View {
                         Spacer()
 
                         // Display the current carb amount
-                        // TODO: format this properly using state.bolusIncrement
-                        Text(String(format: "%.2f U", bolusAmount * Double(truncating: state.bolusIncrement as NSNumber)))
+                        let bolusIncrement = Double(truncating: state.bolusIncrement as NSNumber)
+                        let adjustedBolusAmount = floor(bolusAmount / bolusIncrement) * bolusIncrement
+
+                        Text(String(format: "%.2f U", adjustedBolusAmount))
                             .fontWeight(.bold)
                             .font(.system(.title2, design: .rounded))
                             .foregroundColor(bolusAmount > 0.0 && bolusAmount >= effectiveBolusLimit ? .loopRed : .primary)