feat: honour Tap station action in widgets
Small widgetURL and medium list Links route through StationTapAction via FuelStation.tapDestinationURL: Open map keeps the Maps URL, More info uses a fuelboard://station deep link (stationID plus coordinate/name fallback). Deep link carries fallback coords; ContentView presents the detail sheet when the station is cached, else the map sheet. Live Activity detailURL upgraded to the same rich link.
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
// in Settings → Live Activity (INDEPENDENT of the Stations-tab selection).
|
||||
// Everything dynamic lives in ContentState so updates — including a fuel
|
||||
// change — apply to the running activity without needing to restart it.
|
||||
// Tapping the activity opens Apple Maps driving directions (maps://).
|
||||
// Tapping the activity honours Settings → Tap station: Open map opens Apple
|
||||
// Maps driving directions (maps://), More info opens the detail sheet in
|
||||
// the app (fuelboard://station).
|
||||
|
||||
import ActivityKit
|
||||
import Foundation
|
||||
|
||||
@@ -99,7 +99,7 @@ struct FuelPriceWidgetContent: View {
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
|
||||
.modifier(WidgetURLModifier(url: isWidget ? station.widgetDirectionsURL : nil))
|
||||
.modifier(WidgetURLModifier(url: isWidget ? station.tapDestinationURL : nil))
|
||||
}
|
||||
|
||||
/// How many station rows each family can fit: medium widgets are short
|
||||
@@ -129,7 +129,7 @@ struct FuelPriceWidgetContent: View {
|
||||
}
|
||||
ForEach(entry.stations.prefix(maxRows)) { station in
|
||||
if isWidget {
|
||||
Link(destination: station.widgetDirectionsURL ?? URL(string: "maps://")!) {
|
||||
Link(destination: station.tapDestinationURL ?? URL(string: "maps://")!) {
|
||||
row(station, cheapest: cheapest)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
|
||||
@@ -271,6 +271,30 @@ struct FuelStation: Identifiable, Codable, Equatable {
|
||||
URL(string: "maps://?daddr=\(lat),\(lng)&t=d")
|
||||
}
|
||||
|
||||
/// In-app deep link to this station's More info sheet. Carries the
|
||||
/// stationID plus coordinate/name fallback so the app can still show the
|
||||
/// map sheet when the station has left the cache.
|
||||
var detailDeepLinkURL: URL? {
|
||||
var components = URLComponents()
|
||||
components.scheme = "fuelboard"
|
||||
components.host = "station"
|
||||
components.queryItems = [
|
||||
URLQueryItem(name: "stationID", value: id),
|
||||
URLQueryItem(name: "lat", value: String(lat)),
|
||||
URLQueryItem(name: "lng", value: String(lng)),
|
||||
URLQueryItem(name: "name", value: name),
|
||||
]
|
||||
return components.url
|
||||
}
|
||||
|
||||
/// Widget/Live Activity tap destination honouring Settings → Tap station:
|
||||
/// Open map → Apple Maps directions; More info → in-app detail deep link.
|
||||
var tapDestinationURL: URL? {
|
||||
FuelStore.loadStationTapAction() == .showDetails
|
||||
? detailDeepLinkURL
|
||||
: widgetDirectionsURL
|
||||
}
|
||||
|
||||
/// Name of the bundled brand logo asset, or nil if unknown.
|
||||
/// Normalizes messy raw brand strings ("SHELL LEEDS ROAD" → "shell").
|
||||
var brandImageName: String? {
|
||||
|
||||
Reference in New Issue
Block a user