Add cheapest-favourite price-drop alerts

This commit is contained in:
FuelBoard Contributor
2026-08-17 16:33:46 +01:00
parent 63084322f6
commit 6f0fc43085
4 changed files with 276 additions and 64 deletions
+15
View File
@@ -12,6 +12,8 @@ struct AlertsView: View {
@Binding var enabled: Bool
@Binding var radius: Double // stored in km (monitor + storage)
@Binding var fuel: FuelType // the fuel alerts monitor for
@Binding var favouriteDropEnabled: Bool
@Binding var favouriteDropFuel: FuelType
/// Whether alerts mirror the Stations-tab search distance (capped at 8 mi).
@Binding var followsSearch: Bool
/// Whether the "cheapest nearby" Live Activity is shown on the Lock Screen
@@ -157,6 +159,19 @@ struct AlertsView: View {
Text("When you approach a station that is the cheapest within the radius, FuelBoard sends a notification — even with the app closed. Nearby stations selling \(fuel.displayName.lowercased()) are watched — favourites get priority — and each station alerts at most once per hour. Follow search mirrors the Stations-tab distance, capped at 8 miles for reliable geofencing. Smaller radii ping more often but later; larger radii ping rarely in town but earlier from afar.")
}
Section {
Toggle("Cheapest-favourite price-drop alerts", isOn: $favouriteDropEnabled)
Picker("Fuel", selection: $favouriteDropFuel) {
ForEach(FuelType.allCases) { fuel in
Text(fuel.displayName).tag(fuel)
}
}
} header: {
Text("Favourite price-drop alerts")
} footer: {
Text("Watches your cheapest saved favourite for the fuel you pick here. FuelBoard alerts when a different favourite becomes the cheapest, or when your current cheapest favourite drops by at least 1.0p. This is separate from the nearby-geofence alert, so you can monitor favourites without extra location noise.")
}
if enabled, let lastAlert {
Section("Last alert") {
Label(lastAlert, systemImage: "bell.badge.fill")