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: {
|
||||
|
||||
@@ -30,11 +30,11 @@ struct StationsView: View {
|
||||
Section {
|
||||
if let location {
|
||||
if sortMode == .closest {
|
||||
Text("Closest \(selectedFuel.displayName) stations — nearest first, best value within \(stationLimit) \(distanceUnit.label) · \(totalCount) stations")
|
||||
Text("Closest \(selectedFuel.displayName) stations — nearest first, best value within \(distanceUnit.displayMiles(stationLimit)) \(distanceUnit.label(for: Double(distanceUnit.displayMiles(stationLimit)))) · \(totalCount) stations")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
} else {
|
||||
Text("Cheapest \(selectedFuel.displayName) within \(stationLimit) \(distanceUnit.label) — \(totalCount) stations · tap a station for directions.")
|
||||
Text("Cheapest \(selectedFuel.displayName) within \(distanceUnit.displayMiles(stationLimit)) \(distanceUnit.label(for: Double(distanceUnit.displayMiles(stationLimit)))) — \(totalCount) stations · tap a station for directions.")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
@@ -55,7 +55,8 @@ struct StationsView: View {
|
||||
Section("Distance") {
|
||||
Picker("Distance", selection: $stationLimit) {
|
||||
ForEach(FuelStore.stationRadiusOptions, id: \.self) { miles in
|
||||
Text("\(miles) \(distanceUnit.label)").tag(miles)
|
||||
let shown = distanceUnit.displayMiles(miles)
|
||||
Text("\(shown) \(distanceUnit.label(for: Double(shown)))").tag(miles)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
|
||||
Reference in New Issue
Block a user