Explorar o código

Merge branch 'watch' of github.com:polscm32/Trio-dev into watch

Deniz Cengiz hai 1 ano
pai
achega
82c7cbfbd2
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  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)