feat: honour Tap station action on notification and Live Activity taps
Notification body/action taps route through StationTapAction: Open map opens Apple Maps (existing); More info presents the in-app detail sheet (falls back to the map sheet when the station is not in cache). Live Activity Lock Screen card and island station row pick their Link destination the same way: Maps URL for Open map, fuelboard://station deep link for More info, handled in FuelBoardApp and observed by ContentView. Also adds the small non-interactive map preview above the Directions button in the More info sheet.
This commit is contained in:
@@ -84,7 +84,7 @@ private struct FuelBoardLiveActivityView: View {
|
||||
@State private var slotWidth: CGFloat = 400
|
||||
|
||||
var body: some View {
|
||||
Link(destination: context.state.mapsURL) {
|
||||
Link(destination: tapDestination) {
|
||||
Group {
|
||||
// Branch on the ACTUAL proposed width. iPhone/iPad offer the
|
||||
// full Lock Screen width (>= threshold) → rich card, no matter
|
||||
@@ -210,9 +210,26 @@ private struct FuelBoardLiveActivityStationView: View {
|
||||
let context: ActivityViewContext<FuelBoardLiveActivityAttributes>
|
||||
|
||||
var body: some View {
|
||||
Text("\(context.state.stationName) · \(context.state.distanceText)")
|
||||
.font(.caption)
|
||||
.lineLimit(1)
|
||||
Link(destination: FuelBoardLiveActivityTap.tapDestination(for: context.state)) {
|
||||
Text("\(context.state.stationName) · \(context.state.distanceText)")
|
||||
.font(.caption)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Tap routing shared by the Lock Screen card and the island: honours
|
||||
/// Settings → Tap station (Open map → Maps, More info → in-app detail).
|
||||
enum FuelBoardLiveActivityTap {
|
||||
static func tapDestination(for state: FuelBoardLiveActivityAttributes.ContentState) -> URL {
|
||||
FuelStore.loadStationTapAction() == .showDetails ? state.detailURL : state.mapsURL
|
||||
}
|
||||
}
|
||||
|
||||
private extension FuelBoardLiveActivityView {
|
||||
/// Lock Screen tap honours Settings → Tap station.
|
||||
var tapDestination: URL {
|
||||
FuelBoardLiveActivityTap.tapDestination(for: context.state)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,4 +252,10 @@ extension FuelBoardLiveActivityAttributes.ContentState {
|
||||
var mapsURL: URL {
|
||||
URL(string: "maps://?daddr=\(lat),\(lng)&t=d")!
|
||||
}
|
||||
|
||||
/// In-app deep link to the station's detail sheet, used when
|
||||
/// Settings → Tap station = More info.
|
||||
var detailURL: URL {
|
||||
URL(string: "fuelboard://station?stationID=\(stationID)")!
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user