@@ -51,7 +51,9 @@ struct BolusView: View {
5151
5252 private func roundedToStep( _ value: Double ) -> Double {
5353 guard stepU > 0 else { return value }
54- let stepped = ( value / stepU) . rounded ( ) * stepU
54+
55+ let stepped = ( value / stepU) . rounded ( . up) * stepU
56+
5557 let p = pow ( 10.0 , Double ( stepFractionDigits) )
5658 return ( stepped * p) . rounded ( ) / p
5759 }
@@ -87,6 +89,9 @@ struct BolusView: View {
8789 bolusFieldIsFocused = false
8890 DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.1 ) {
8991 if bolusAmount. doubleValue ( for: . internationalUnit( ) ) > 0.0 {
92+ let steppedAmount = roundedToStep ( self . bolusAmount. doubleValue ( for: . internationalUnit( ) ) )
93+ bolusAmount = HKQuantity ( unit: . internationalUnit( ) , doubleValue: steppedAmount)
94+
9095 alertType = . confirmBolus
9196 showAlert = true
9297 }
@@ -138,7 +143,7 @@ struct BolusView: View {
138143 title: Text ( " Old Calculation Warning " ) ,
139144 message: Text ( alertMessage ?? " " ) ,
140145 primaryButton: . default( Text ( " Use Anyway " ) ) {
141- if let rec = deviceRecBolus. value, rec >= stepU {
146+ if let rec = deviceRecBolus. value {
142147 applyRecommendedBolus ( rec)
143148 }
144149 } ,
@@ -156,7 +161,6 @@ struct BolusView: View {
156161 @ViewBuilder
157162 private func recommendedBlocks( now: Date ) -> some View {
158163 if let rec = deviceRecBolus. value,
159- rec >= stepU,
160164 let t = enactedOrSuggested. value
161165 {
162166 let ageSec = max ( 0 , now. timeIntervalSince1970 - t)
@@ -214,7 +218,6 @@ struct BolusView: View {
214218 }
215219
216220 private func applyRecommendedBolus( _ rec: Double ) {
217- guard rec >= stepU else { return }
218221 let maxU = maxBolus. value. doubleValue ( for: . internationalUnit( ) )
219222 let clamped = min ( rec, maxU)
220223 let stepped = roundedToStep ( clamped)
0 commit comments