Skip to content

Commit 93c7428

Browse files
author
Rick Pasetto
authored
LOOP-1160: Show '--' if there's no iob or cob (instead of 0) (#201)
1 parent 2b55b4b commit 93c7428

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Loop/Views/BolusEntryView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,18 @@ struct LabeledQuantity: View {
484484
}
485485

486486
var valueText: Text {
487+
guard let quantity = quantity else {
488+
return Text("--")
489+
}
490+
487491
let formatter = QuantityFormatter()
488492
formatter.setPreferredNumberFormatter(for: unit)
489493

490494
if let maxFractionDigits = maxFractionDigits {
491495
formatter.numberFormatter.maximumFractionDigits = maxFractionDigits
492496
}
493497

494-
guard let string = formatter.string(from: quantity ?? HKQuantity(unit: unit, doubleValue: 0), for: unit) else {
498+
guard let string = formatter.string(from: quantity, for: unit) else {
495499
assertionFailure("Unable to format \(String(describing: quantity)) \(unit)")
496500
return Text("")
497501
}

0 commit comments

Comments
 (0)