Default station taps to the detail sheet

The default tap action was Directions: tapping a row handed straight off to
Apple Maps. That leaves the app with no way back, and on a fresh install it
hides everything the row already knows — address, distance, the Worth the Drive
breakdown — behind a jump to another app. The detail sheet shows the same
station with Directions one tap away inside it, so it is the better default to
land on. Directions remains available, both in the sheet and by picking it in
Settings.

The fallback in loadStationTapAction is the whole change. Every consumer — row
taps, the notification path in ProximityMonitor, Station.tapDestinationURL for
widgets — already resolves the setting at the point of use rather than caching
it, so none needed touching and none can drift away from the others.

An explicit choice is not overridden: the fallback applies only when nothing is
stored, and the only writer is the Settings picker. Anyone who deliberately
chose Directions keeps it.

Comments that existed to explain the old default are corrected rather than left
contradicting the code — the section comment and the enum doc in FuelStore, and
the FB_DETAIL_DEBUG hook's rationale in ContentView. That hook is now near
redundant since the default is the sheet; it is kept because it still overrides
a stored Directions on a simulator.

The default itself is still untested: loadStationTapAction reads the keychain
before defaults, and the SwiftPM suite never touches the keychain today, so a
test would risk an access prompt hanging the run.

Tests: 278 pass.
This commit is contained in:
FuelBoard Contributor
2026-10-19 16:28:47 +01:00
parent fcd1fb8572
commit 29e299d558
2 changed files with 10 additions and 8 deletions
+4 -3
View File
@@ -1054,9 +1054,10 @@ struct ContentView: View {
sortMode = .worthTheDrive sortMode = .worthTheDrive
} }
// QA temp: `FB_DETAIL_DEBUG=1` (DEBUG builds only) forces // QA temp: `FB_DETAIL_DEBUG=1` (DEBUG builds only) forces
// "Tap station = More info". The stored default is open-Apple-Maps, // "Tap station = More info". The default is already the detail
// so on a simulator a tap bounces out to Maps with no way back and // sheet, so this only matters on a simulator whose store has
// the Worth the Drive detail section can't be checked at all. // "Directions" saved — it overrides the stored choice either way,
// which keeps the Worth the Drive detail section reachable.
if ProcessInfo.processInfo.environment["FB_DETAIL_DEBUG"] == "1" { if ProcessInfo.processInfo.environment["FB_DETAIL_DEBUG"] == "1" {
stationTapAction = .showDetails stationTapAction = .showDetails
} }
+6 -5
View File
@@ -245,8 +245,8 @@ enum PriceDisplayStyle: String, Codable, CaseIterable, Identifiable {
// MARK: - Station tap action // MARK: - Station tap action
/// What happens when a station row is tapped in the Stations/Favourites tabs: /// What happens when a station row is tapped in the Stations/Favourites tabs:
/// open Apple Maps directions immediately (historic behaviour, default), or /// open Apple Maps directions immediately, or show a detail sheet (name,
/// show a detail sheet (name, address, distance, Directions button). /// address, distance, Directions button) — the default.
enum StationTapAction: String, Codable, CaseIterable, Identifiable { enum StationTapAction: String, Codable, CaseIterable, Identifiable {
case openMap // tap → Apple Maps directions straight away case openMap // tap → Apple Maps directions straight away
case showDetails // tap → detail sheet, Directions button inside case showDetails // tap → detail sheet, Directions button inside
@@ -801,8 +801,9 @@ struct FuelStore {
saveString(style.rawValue, service: priceDisplayStyleKey) saveString(style.rawValue, service: priceDisplayStyleKey)
} }
// MARK: Station tap action — open map vs detail sheet. Stored raw value; // MARK: Station tap action — detail sheet vs open map. Stored raw value;
// default open map preserves the historic tap behaviour for existing installs. // the default is the detail sheet, so a tap always lands somewhere the app
// can come back from. Directions still one tap away, inside the sheet.
static let stationTapActionKey = "fuelboard.stationTapAction" static let stationTapActionKey = "fuelboard.stationTapAction"
@@ -810,7 +811,7 @@ struct FuelStore {
if let raw = loadString(service: stationTapActionKey), let action = StationTapAction(rawValue: raw) { if let raw = loadString(service: stationTapActionKey), let action = StationTapAction(rawValue: raw) {
return action return action
} }
return .openMap return .showDetails
} }
static func saveStationTapAction(_ action: StationTapAction) { static func saveStationTapAction(_ action: StationTapAction) {