Files
fuelboard/FuelBoard/AlertsView.swift
T
FuelBoard Contributor fb79cf0788 Add first-launch onboarding with location + notification permission prompts
- OnboardingView: 4-page flow (welcome + features, location, notifications, done)
- Triggers system prompts in-context via OnboardingPermissionPrompter
- Shown at initial launch only (FuelStore.onboardingCompleted flag, app-group defaults)
- Test hook: 'Show onboarding (testing)' button at bottom of Alerts tab
2026-08-12 07:10:54 +01:00

76 lines
3.1 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 onShowOnboarding: () -> Void = {}
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)
}
}
}
// Testing hook — in production onboarding shows once at first
// launch; this button re-opens it to verify the flow.
Section {
Button {
onShowOnboarding()
} label: {
Label("Show onboarding (testing)", systemImage: "flag.fill")
.font(.footnote)
}
} footer: {
Text("Testing only — onboarding normally appears once on first launch.")
}
}
.navigationTitle("Alerts")
}
}
}