Location-driven results: widget fetches its own location (async, cache fallback), app auto-requests on first launch, Halifax sample stations

This commit is contained in:
FuelBoard Contributor
2026-08-11 14:03:41 +01:00
parent b0a5b5a326
commit 4f5f1999a9
6 changed files with 171 additions and 56 deletions
+5 -5
View File
@@ -2,11 +2,6 @@ import SwiftUI
import CoreLocation
import WidgetKit
struct Coordinate: Equatable {
let lat: Double
let lng: Double
}
struct ContentView: View {
@Environment(\.scenePhase) private var scenePhase
@@ -111,6 +106,11 @@ struct ContentView: View {
}
}
.onAppear {
// Auto-request location on first launch so the widget gets a
// fresh fix without the user hunting for the button.
if FuelStore.loadLocation() == nil {
locationManager.requestUpdate()
}
Task { await refresh() }
}
.onChange(of: scenePhase) { _, newPhase in