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
+13 -2
View File
@@ -21,6 +21,7 @@ struct ContentView: View {
@State private var stationLimit: Int = FuelStore.loadStationLimit()
@State private var distanceUnit: DistanceUnit = FuelStore.loadDistanceUnit()
@State private var priceDisplayStyle: PriceDisplayStyle = FuelStore.loadPriceDisplayStyle()
@State private var stationTapAction: StationTapAction = FuelStore.loadStationTapAction()
@State private var favourites: [FavouriteEntry] = FuelStore.loadFavourites()
@State private var alertsEnabled: Bool = FuelStore.loadAlertsEnabled()
@State private var alertsRadius: Double = FuelStore.loadAlertsRadius()
@@ -742,6 +743,7 @@ struct ContentView: View {
topStationID: topStationID,
location: location,
favouriteIDs: favouriteIDs,
stationTapAction: stationTapAction,
onToggleFavourite: toggleFavourite,
onRefresh: { await refresh(force: true) }
)
@@ -756,6 +758,7 @@ struct ContentView: View {
location: location,
distanceUnit: distanceUnit,
priceDisplayStyle: priceDisplayStyle,
stationTapAction: stationTapAction,
onToggleFavourite: toggleFavourite,
onReorder: reorderFavourites,
onHistoryUnavailable: { if dataStatus == .live { dataStatus = .connectionProblem } },
@@ -794,6 +797,7 @@ struct ContentView: View {
tipStore: tipStore,
distanceUnit: $distanceUnit,
priceDisplayStyle: $priceDisplayStyle,
stationTapAction: $stationTapAction,
dataRefreshMode: $dataRefreshMode,
alertsFuel: alertsFuel,
alertsRadiusKM: alertsRadius,
@@ -931,7 +935,9 @@ struct StationRow: View {
let baselinePrice: Double?
let isTopResult: Bool
let isFavourite: Bool
var tapAction: StationTapAction = .openMap
var onToggleFavourite: () -> Void = {}
var onShowDetails: (FuelStation) -> Void = { _ in }
private var ragColor: Color {
guard let price = station.prices[fuel], let baselinePrice else { return .gray }
@@ -1030,8 +1036,13 @@ struct StationRow: View {
}
.contentShape(Rectangle())
.onTapGesture {
if let url = station.mapsDirectionsURL {
UIApplication.shared.open(url)
switch tapAction {
case .openMap:
if let url = station.mapsDirectionsURL {
UIApplication.shared.open(url)
}
case .showDetails:
onShowDetails(station)
}
}
}