Settings Debug: device coordinates + in-range station indicator

- Debug section now shows the last device fix (lat/lng to 5dp) and its age.
- In-range indicator uses the SAME criteria as live alerts: stations selling
  the monitored fuel within the alert radius of the fix. Green dot + count
  when in range, red when none, grey while waiting for a fix.
- Shows the cheapest in-range station (name, distance, price).
- ProximityMonitor recomputes the snapshot on every location/stations
  change and on Debug-section appear; ContentView passes the live status.
- SettingsView extracted to its own property to keep TabView body within
  the compiler type-check budget. 35 tests pass.
This commit is contained in:
FuelBoard Contributor
2026-08-12 14:33:52 +01:00
parent 07521b1c98
commit 126fdbde62
4 changed files with 173 additions and 10 deletions
+9
View File
@@ -326,6 +326,15 @@ struct FuelStore {
return Coordinate(lat: parts[0], lng: parts[1])
}
/// Location + the timestamp it was saved, for debug display (fix age).
static func loadLocationWithDate() -> (coordinate: Coordinate, date: Date)? {
let raw = loadString(service: locationKey)
let parts = raw?.split(separator: ",").compactMap { Double($0) }
guard let parts, parts.count == 3 else { return nil }
return (Coordinate(lat: parts[0], lng: parts[1]),
Date(timeIntervalSince1970: parts[2]))
}
static func saveLocation(lat: Double, lng: Double, date: Date = Date()) {
saveString("\(lat),\(lng),\(date.timeIntervalSince1970)", service: locationKey)
}