Distance picker disabled in Closest mode; whole-country pool for nearest-first (radius never empties Closest)
This commit is contained in:
@@ -27,9 +27,15 @@ struct StationsView: View {
|
||||
List {
|
||||
Section {
|
||||
if let location {
|
||||
Text("\(sortMode == .closest ? "Closest" : "Cheapest") \(selectedFuel.displayName) within \(stationLimit) miles — tap a station for directions.")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
if sortMode == .closest {
|
||||
Text("Closest \(selectedFuel.displayName) stations — tap a station for directions.")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
} else {
|
||||
Text("Cheapest \(selectedFuel.displayName) within \(stationLimit) miles — tap a station for directions.")
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
} else {
|
||||
Text("\(sortMode == .closest ? "Closest" : "Cheapest") \(selectedFuel.displayName) — tap a station for directions.")
|
||||
.font(.footnote)
|
||||
@@ -57,13 +63,25 @@ struct StationsView: View {
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
// In Closest mode the whole country is the pool — the
|
||||
// radius is meaningless ("nearest" must never return an
|
||||
// empty state), so the picker is disabled but its value is
|
||||
// kept for when the user switches back to Cheapest.
|
||||
.disabled(sortMode == .closest)
|
||||
.opacity(sortMode == .closest ? 0.5 : 1)
|
||||
.onChange(of: stationLimit) { _, newValue in
|
||||
FuelStore.saveStationLimit(newValue)
|
||||
}
|
||||
.padding(.vertical, 2)
|
||||
Text("\(totalCount) stations within \(stationLimit) miles")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
if sortMode == .closest {
|
||||
Text("Distance only applies to Cheapest")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
} else {
|
||||
Text("\(totalCount) stations within \(stationLimit) miles")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
Section("Stations") {
|
||||
|
||||
Reference in New Issue
Block a user