diff --git a/FuelBoardWidgets/WidgetConfigIntent.swift b/FuelBoardWidgets/WidgetConfigIntent.swift index bb28dca..afed7a2 100644 --- a/FuelBoardWidgets/WidgetConfigIntent.swift +++ b/FuelBoardWidgets/WidgetConfigIntent.swift @@ -48,6 +48,16 @@ enum WidgetDistance: String, AppEnum, CaseIterable, Codable { .fifteen: "15 miles", ] + /// Mirror the app's units setting: the Edit-Widget picker labels show the + /// real distance in the user's chosen unit — "5 miles" in miles mode, + /// "8 km" in km mode (same stored value, labelled truthfully). Keeps the + /// widget config consistent with the Stations/Alerts pickers. + var displayRepresentation: DisplayRepresentation { + let unit = FuelStore.loadDistanceUnit() + let shown = unit.displayMiles(miles) + return DisplayRepresentation(stringLiteral: "\(shown) \(unit.label(for: Double(shown)))") + } + var miles: Int { switch self { case .five: return 5