Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion WatchApp Extension/ComplicationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ final class ComplicationController: NSObject, CLKComplicationDataSource {

// MARK: - Timeline Population

private lazy var formatter = NumberFormatter()
// private lazy var formatter = NumberFormatter()

func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: (@escaping (CLKComplicationTimelineEntry?) -> Void)) {

let formatter = NumberFormatter(); formatter.usesSignificantDigits = true; formatter.minimumSignificantDigits = 2; formatter.maximumSignificantDigits = 3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this display with mg/dl?

Need to avoid repeating this code three times.



switch complication.family {
case .modularSmall:
if let context = ExtensionDelegate.shared().lastContext,
Expand All @@ -69,6 +72,9 @@ final class ComplicationController: NSObject, CLKComplicationDataSource {

func getTimelineEntries(for complication: CLKComplication, after date: Date, limit: Int, withHandler handler: (@escaping ([CLKComplicationTimelineEntry]?) -> Void)) {
// Call the handler with the timeline entries after to the given date

let formatter = NumberFormatter(); formatter.usesSignificantDigits = true; formatter.minimumSignificantDigits = 2; formatter.maximumSignificantDigits = 3

if let context = ExtensionDelegate.shared().lastContext,
let glucose = context.glucose,
let unit = context.preferredGlucoseUnit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class StatusInterfaceController: WKInterfaceController, ContextUpdatable {
loopHUDImage.setLoopImage(.Unknown)
}

let numberFormatter = NumberFormatter()
let numberFormatter = NumberFormatter(); numberFormatter.usesSignificantDigits=true; numberFormatter.minimumSignificantDigits = 2; numberFormatter.maximumSignificantDigits = 3

if let glucose = context?.glucose, let unit = context?.preferredGlucoseUnit {
let glucoseValue = glucose.doubleValue(for: unit)
Expand Down