Kaynağa Gözat

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

Deniz Cengiz 1 yıl önce
ebeveyn
işleme
82c7cbfbd2

+ 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)