Labels: pluralize miles (1 mile) and show true distances in the chosen unit (5 mi = 8 km) across Alerts/Stations pickers + captions
This commit is contained in:
@@ -32,8 +32,16 @@ struct AlertsView: View {
|
||||
/// The Stations-tab search distance shown in the user's unit, e.g.
|
||||
/// "5 miles" or "8 km" — for the "Follow search" rows.
|
||||
private var searchInUnitLabel: String {
|
||||
let km = Double(stationLimit) * 1.60934 // stationLimit is always miles
|
||||
return "\(Int(distanceUnit.fromKM(km).rounded())) \(distanceUnit.label)"
|
||||
let shown = distanceUnit.displayMiles(stationLimit) // stationLimit is always miles
|
||||
return "\(shown) \(distanceUnit.label(for: Double(shown)))"
|
||||
}
|
||||
|
||||
/// A miles value (5/10/15) shown truthfully in the user's unit, e.g.
|
||||
/// "5 miles" (miles unit) or "8 km" (km unit) — picker labels must match
|
||||
/// what the option really means.
|
||||
private func distanceLabel(forMiles miles: Int) -> String {
|
||||
let shown = distanceUnit.displayMiles(miles)
|
||||
return "\(shown) \(distanceUnit.label(for: Double(shown)))"
|
||||
}
|
||||
|
||||
private enum AlertRadiusChoice: Hashable {
|
||||
@@ -102,7 +110,7 @@ struct AlertsView: View {
|
||||
Picker("Radius", selection: alertChoice) {
|
||||
Text("Follow search (\(searchInUnitLabel))").tag(AlertRadiusChoice.followSearch)
|
||||
ForEach(FuelStore.alertRadiusOptions, id: \.self) { value in
|
||||
Text("\\(value) \\(distanceUnit.label)").tag(AlertRadiusChoice.fixed(value))
|
||||
Text("\(value) \(distanceUnit.label(for: Double(value)))").tag(AlertRadiusChoice.fixed(value))
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
@@ -146,7 +154,7 @@ struct AlertsView: View {
|
||||
Picker("Distance", selection: laChoice) {
|
||||
Text("Follow search (\(searchInUnitLabel))").tag(LADistanceChoice.followSearch)
|
||||
ForEach(FuelStore.stationRadiusOptions, id: \.self) { miles in
|
||||
Text("\\(miles) \\(distanceUnit.label)").tag(LADistanceChoice.fixed(miles))
|
||||
Text(distanceLabel(forMiles: miles)).tag(LADistanceChoice.fixed(miles))
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
|
||||
Reference in New Issue
Block a user