@@ -43,7 +43,7 @@ class StatusViewController: UIViewController, NCWidgetProviding {
4343 // the wrong units and that could be very harmful. So unless there's a preferred
4444 // unit, assume that none of the rest of the data is reliable.
4545 guard
46- let preferredUnitDisplayString = context. preferredUnitDisplayString
46+ let preferredUnitString = context. preferredUnitString
4747 else {
4848 completionHandler ( NCUpdateResult . failed)
4949 return
@@ -52,7 +52,7 @@ class StatusViewController: UIViewController, NCWidgetProviding {
5252 if let glucose = context. latestGlucose {
5353 glucoseHUD. set ( glucoseQuantity: glucose. quantity,
5454 at: glucose. startDate,
55- unitDisplayString : preferredUnitDisplayString ,
55+ unitString : preferredUnitString ,
5656 from: glucose. sensor)
5757 }
5858
@@ -74,14 +74,16 @@ class StatusViewController: UIViewController, NCWidgetProviding {
7474 loopCompletionHUD. lastLoopCompleted = loop. lastCompleted
7575 }
7676
77- if let eventualGlucose = context. eventualGlucose {
78- let quantity = HKQuantity ( unit: HKUnit ( from: preferredUnitDisplayString) ,
79- doubleValue: eventualGlucose. rounded ( ) )
77+ let preferredUnit = HKUnit ( from: preferredUnitString)
78+ let formatter = NumberFormatter . glucoseFormatter ( for: preferredUnit)
79+ if let eventualGlucose = context. eventualGlucose,
80+ let eventualGlucoseNumberString = formatter. string ( from: NSNumber ( value: eventualGlucose) ) {
8081 subtitleLabel. text = String (
8182 format: NSLocalizedString (
82- " Eventually %@ " ,
83- comment: " The subtitle format describing eventual glucose. (1: localized glucose value description) " ) ,
84- String ( describing: quantity) )
83+ " Eventually %1$@ %2$@ " ,
84+ comment: " The subtitle format describing eventual glucose. (1: localized glucose value description) (2: localized glucose units description) " ) ,
85+ eventualGlucoseNumberString,
86+ preferredUnit. glucoseUnitDisplayString)
8587 subtitleLabel. alpha = 1
8688 } else {
8789 subtitleLabel. alpha = 0
0 commit comments