Files
fuelboard/FuelBoard/AlertsView.swift
T

62 lines
2.5 KiB
Swift

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")
}
}
}