Tabs (Stations/Favourites/Alerts): favourites with cheapest-first ranking, proximity geofence alerts (favourites priority, 3km default radius, 1h dedup), Always location + background mode
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import SwiftUI
|
||||
|
||||
/// Alerts tab — enables the cheapest-station proximity alerts and shows what's
|
||||
/// being monitored.
|
||||
struct AlertsView: View {
|
||||
@Binding var enabled: Bool
|
||||
@Binding var radius: Double
|
||||
let monitoredCount: Int
|
||||
let lastAlert: String?
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List {
|
||||
Section {
|
||||
Toggle("Cheapest-station alerts", isOn: $enabled)
|
||||
} footer: {
|
||||
Text("When you approach a station that is the cheapest within the radius, FuelBoard sends a notification — even with the app closed.")
|
||||
}
|
||||
|
||||
if enabled {
|
||||
Section("Trigger radius") {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack {
|
||||
Text("Radius")
|
||||
Spacer()
|
||||
Text("\(Int(radius)) km")
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
}
|
||||
Slider(value: $radius, in: 1...10, step: 1)
|
||||
}
|
||||
}
|
||||
|
||||
Section("Monitoring") {
|
||||
if monitoredCount == 0 {
|
||||
Text("No stations monitored yet — open the Stations tab to load prices first.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
} else {
|
||||
LabeledContent("Geofenced stations", value: "\(monitoredCount)")
|
||||
Text("Your favourites get priority, then the closest stations fill the rest (18 max, iOS region limit).")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
Text("Alerts are checked against the cheapest station within \(Int(radius)) km for the selected fuel. Each station alerts at most once per hour.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
if let lastAlert {
|
||||
Section("Last alert") {
|
||||
Label(lastAlert, systemImage: "bell.badge.fill")
|
||||
.font(.footnote)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Alerts")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user