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:
@@ -12,6 +12,11 @@ import Security
|
||||
|
||||
// MARK: - Fuel types
|
||||
|
||||
struct Coordinate: Equatable, Codable {
|
||||
let lat: Double
|
||||
let lng: Double
|
||||
}
|
||||
|
||||
enum FuelType: String, Codable, CaseIterable, Identifiable {
|
||||
case e10 // Unleaded 95 (E10)
|
||||
case e5 // Premium 97/98 (E5)
|
||||
@@ -94,11 +99,11 @@ struct FuelStore {
|
||||
|
||||
// MARK: Last known location ("lat,lng,unixTime")
|
||||
|
||||
static func loadLocation() -> (lat: Double, lng: Double, date: Date)? {
|
||||
static func loadLocation() -> Coordinate? {
|
||||
let raw = loadString(service: locationKey)
|
||||
let parts = raw?.split(separator: ",").compactMap { Double($0) }
|
||||
guard let parts, parts.count == 3 else { return nil }
|
||||
return (parts[0], parts[1], Date(timeIntervalSince1970: parts[2]))
|
||||
return Coordinate(lat: parts[0], lng: parts[1])
|
||||
}
|
||||
|
||||
static func saveLocation(lat: Double, lng: Double, date: Date = Date()) {
|
||||
|
||||
Reference in New Issue
Block a user