Live Activity: own fuel + distance config, independent of Stations tab
- Settings → Live Activity now has Fuel and Distance pickers (5/10/15, unit-aware) stored under fuelboard.liveActivityFuel / liveActivityRadiusMiles - LiveActivityManager uses these instead of the Stations-tab selectedFuel / stationLimit; Stations changes no longer re-target the pill - Fuel moved from Activity attributes into ContentState so changing fuel in Settings updates the RUNNING activity in place (no end+restart needed) - Stations tab stays a pure data-interrogation + favourites surface
This commit is contained in:
@@ -5,20 +5,21 @@
|
||||
// is deliberately NOT symlinked into FuelBoardTests/Sources — the SPM test
|
||||
// target runs on macOS where ActivityKit does not exist.
|
||||
//
|
||||
// The activity mirrors the app's TOP badge: the cheapest station selling the
|
||||
// app's selected fuel within the app's chosen distance radius. Tapping the
|
||||
// activity opens Apple Maps driving directions to that station (maps://).
|
||||
// The activity tracks the cheapest station for the fuel + radius configured
|
||||
// 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://).
|
||||
|
||||
import ActivityKit
|
||||
import Foundation
|
||||
|
||||
/// Attributes are fixed at request time. Here they pin the FUEL being
|
||||
/// tracked; everything that can change while driving (station, price,
|
||||
/// distance) lives in ContentState so updates don't need a new activity.
|
||||
/// Attributes are fixed at request time. Kept empty: the fuel itself lives in
|
||||
/// ContentState so a fuel change in Settings updates the running activity
|
||||
/// in place instead of requiring an end + restart.
|
||||
struct FuelBoardLiveActivityAttributes: ActivityAttributes {
|
||||
var fuel: FuelType
|
||||
|
||||
public struct ContentState: Codable, Hashable {
|
||||
var fuel: FuelType
|
||||
var stationID: String
|
||||
var stationName: String
|
||||
var brand: String
|
||||
|
||||
Reference in New Issue
Block a user