feat: station tap action toggle (open map vs more info)

Settings → Units gains a Tap station picker: Open map (default,
historic behaviour — tap opens Apple Maps directions) or More info
(tap shows a detail sheet with name, address, distance from current
location, and a Directions button). Applies to Stations and
Favourites tabs; persisted keychain-first as
fuelboard.stationTapAction. Stations footer hint follows the setting.
This commit is contained in:
FuelBoard Contributor
2026-09-14 22:03:20 +01:00
parent ac44cb4ce7
commit cc948dac3a
7 changed files with 148 additions and 7 deletions
+35
View File
@@ -208,6 +208,25 @@ enum PriceDisplayStyle: String, Codable, CaseIterable, Identifiable {
}
}
// MARK: - Station tap action
/// What happens when a station row is tapped in the Stations/Favourites tabs:
/// open Apple Maps directions immediately (historic behaviour, default), or
/// show a detail sheet (name, address, distance, Directions button).
enum StationTapAction: String, Codable, CaseIterable, Identifiable {
case openMap // tap Apple Maps directions straight away
case showDetails // tap detail sheet, Directions button inside
var id: String { rawValue }
var displayName: String {
switch self {
case .openMap: return "Open map"
case .showDetails: return "More info"
}
}
}
// MARK: - Station model
struct FuelStation: Identifiable, Codable, Equatable {
@@ -542,6 +561,22 @@ struct FuelStore {
saveString(style.rawValue, service: priceDisplayStyleKey)
}
// MARK: Station tap action open map vs detail sheet. Stored raw value;
// default open map preserves the historic tap behaviour for existing installs.
static let stationTapActionKey = "fuelboard.stationTapAction"
static func loadStationTapAction() -> StationTapAction {
if let raw = loadString(service: stationTapActionKey), let action = StationTapAction(rawValue: raw) {
return action
}
return .openMap
}
static func saveStationTapAction(_ action: StationTapAction) {
saveString(action.rawValue, service: stationTapActionKey)
}
/// Superscript digit glyphs for the pounds & pence format's small raised
/// third digit (the forecourt style: "£1.29").
private static let superscriptDigits: [Character] = ["", "¹", "²", "³", "", "", "", "", "", ""]