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:
FuelBoard Contributor
2026-08-12 20:58:05 +01:00
parent 04b233bf9a
commit fcb83f1eed
6 changed files with 82 additions and 20 deletions
+23 -3
View File
@@ -13,9 +13,13 @@ import WidgetKit
struct SettingsView: View {
@Binding var distanceUnit: DistanceUnit
/// Whether the "cheapest nearby" Live Activity is shown on the Lock Screen
/// / Dynamic Island. Mirrors the app list's TOP badge (selected fuel +
/// distance radius) and re-updates as the user drives.
/// / Dynamic Island. Tracks its OWN fuel + radius (below) independent of
/// the Stations tab.
@Binding var liveActivityEnabled: Bool
/// Fuel the Live Activity tracks (independent of the Stations tab).
@Binding var liveActivityFuel: FuelType
/// Search radius (miles, 5/10/15) the Live Activity uses.
@Binding var liveActivityRadiusMiles: Int
/// The fuel + radius currently configured for alerts (mirrors the Alerts
/// tab) so the test notification matches what real alerts will say.
var alertsFuel: FuelType = .e10
@@ -72,10 +76,26 @@ struct SettingsView: View {
Section {
Toggle("Live Activity", isOn: $liveActivityEnabled)
Picker("Fuel", selection: $liveActivityFuel) {
ForEach(FuelType.allCases) { fuel in
Text(fuel.displayName).tag(fuel)
}
}
.onChange(of: liveActivityFuel) { _, newValue in
FuelStore.saveLiveActivityFuel(newValue)
}
Picker("Distance", selection: $liveActivityRadiusMiles) {
ForEach(FuelStore.stationRadiusOptions, id: \.self) { miles in
Text("\(miles) \(distanceUnit.label)").tag(miles)
}
}
.onChange(of: liveActivityRadiusMiles) { _, newValue in
FuelStore.saveLiveActivityRadiusMiles(newValue)
}
} header: {
Text("Live Activity")
} footer: {
Text("Shows the cheapest station for your selected fuel within your chosen distance on the Lock Screen and Dynamic Island. Updates as you drive; tap to open directions. Live Activities can be disabled in System Settings → Live Activities.")
Text("Shows the cheapest station for the fuel and distance you pick here on the Lock Screen and Dynamic Island — independent of the Stations tab. Updates as you drive; tap to open directions. Live Activities can be disabled in System Settings → Live Activities.")
}
.onChange(of: liveActivityEnabled) { _, newValue in
FuelStore.saveLiveActivityEnabled(newValue)