Widget config: Distance picker mirrors the app's units setting (5 mi = 8 km) via dynamic AppEnum displayRepresentation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user