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:
@@ -23,8 +23,9 @@ enum FuelPriceProvider {
|
||||
|
||||
// MARK: - Sample provider (default for the scaffold)
|
||||
|
||||
/// Ships realistic stations around Cambridge (52.2053, 0.1218) so the app and
|
||||
/// widget render meaningful data with zero setup. Prices in pence/litre.
|
||||
/// Ships realistic stations around Halifax, West Yorkshire (53.7270, -1.8575)
|
||||
/// so the app and widget render meaningful distances for the user with zero
|
||||
/// setup. Prices in pence/litre.
|
||||
struct SampleFuelProvider: FuelPriceProviding {
|
||||
func fetchStations(near lat: Double?, lng: Double?, fuel: FuelType) async throws -> [FuelStation] {
|
||||
try await Task.sleep(nanoseconds: 300_000_000) // simulate fetch
|
||||
@@ -32,45 +33,45 @@ struct SampleFuelProvider: FuelPriceProviding {
|
||||
}
|
||||
|
||||
static let sampleStations: [FuelStation] = [
|
||||
FuelStation(id: "s1", name: "Shell Cambridge Retail Park", brand: "Shell",
|
||||
address: "12 Retail Park Way", postcode: "CB1 3EW",
|
||||
lat: 52.1955, lng: 0.1380,
|
||||
prices: [.e10: 142.9, .e5: 149.9, .diesel: 148.9],
|
||||
priceUpdated: nil),
|
||||
FuelStation(id: "s2", name: "Tesco Express Hills Road", brand: "Tesco",
|
||||
address: "245 Hills Road", postcode: "CB2 8RP",
|
||||
lat: 52.1809, lng: 0.1398,
|
||||
FuelStation(id: "h1", name: "Tesco Express Halifax", brand: "Tesco",
|
||||
address: "12 Clare Road", postcode: "HX1 2HX",
|
||||
lat: 53.7200, lng: -1.8630,
|
||||
prices: [.e10: 138.9, .e5: 146.9, .diesel: 145.9],
|
||||
priceUpdated: nil),
|
||||
FuelStation(id: "s3", name: "BP Milton Road", brand: "BP",
|
||||
address: "161 Milton Road", postcode: "CB4 1XE",
|
||||
lat: 52.2160, lng: 0.1410,
|
||||
prices: [.e10: 140.9, .diesel: 147.9],
|
||||
FuelStation(id: "h2", name: "Shell Skircoat Road", brand: "Shell",
|
||||
address: "245 Skircoat Road", postcode: "HX3 0HP",
|
||||
lat: 53.7120, lng: -1.8710,
|
||||
prices: [.e10: 142.9, .e5: 149.9, .diesel: 148.9],
|
||||
priceUpdated: nil),
|
||||
FuelStation(id: "s4", name: "Morrisons Newmarket Road", brand: "Morrisons",
|
||||
address: "Newmarket Road", postcode: "CB5 8AA",
|
||||
lat: 52.2164, lng: 0.1599,
|
||||
FuelStation(id: "h3", name: "Morrisons Halifax", brand: "Morrisons",
|
||||
address: "Haugh Shaw Road", postcode: "HX1 3TU",
|
||||
lat: 53.7265, lng: -1.8580,
|
||||
prices: [.e10: 137.9, .e5: 144.9, .diesel: 144.9],
|
||||
priceUpdated: nil),
|
||||
FuelStation(id: "s5", name: "Sainsbury's Coldhams Lane", brand: "Sainsbury's",
|
||||
address: "Coldhams Lane", postcode: "CB1 3HY",
|
||||
lat: 52.2025, lng: 0.1589,
|
||||
prices: [.e10: 139.9, .e5: 147.9, .diesel: 146.9],
|
||||
FuelStation(id: "h4", name: "BP Queensbury", brand: "BP",
|
||||
address: "316 High Street, Queensbury", postcode: "BD13 2NB",
|
||||
lat: 53.7550, lng: -1.8450,
|
||||
prices: [.e10: 140.9, .diesel: 147.9],
|
||||
priceUpdated: nil),
|
||||
FuelStation(id: "s6", name: "Esso Cherry Hinton", brand: "Esso",
|
||||
address: "Cherry Hinton Road", postcode: "CB1 9AP",
|
||||
lat: 52.1854, lng: 0.1657,
|
||||
FuelStation(id: "h5", name: "Asda Halifax", brand: "Asda",
|
||||
address: "Ovenden Way", postcode: "HX2 8DD",
|
||||
lat: 53.7340, lng: -1.8890,
|
||||
prices: [.e10: 136.9, .e5: 143.9, .diesel: 143.9],
|
||||
priceUpdated: nil),
|
||||
FuelStation(id: "h6", name: "Esso Sowerby Bridge", brand: "Esso",
|
||||
address: "Wharf Street", postcode: "HX6 2AH",
|
||||
lat: 53.7080, lng: -1.9080,
|
||||
prices: [.e10: 141.9, .e5: 148.9, .diesel: 147.9],
|
||||
priceUpdated: nil),
|
||||
FuelStation(id: "s7", name: "Gulf Fen Road", brand: "Gulf",
|
||||
address: "Fen Road", postcode: "CB4 1UN",
|
||||
lat: 52.2201, lng: 0.1470,
|
||||
prices: [.e10: 143.9, .e5: 151.9, .diesel: 149.9],
|
||||
FuelStation(id: "h7", name: "Sainsbury's Elland", brand: "Sainsbury's",
|
||||
address: "Southgate", postcode: "HX5 0PA",
|
||||
lat: 53.6860, lng: -1.8380,
|
||||
prices: [.e10: 139.9, .e5: 147.9, .diesel: 146.9],
|
||||
priceUpdated: nil),
|
||||
FuelStation(id: "s8", name: "Asda Beehive Centre", brand: "Asda",
|
||||
address: "Coldhams Lane", postcode: "CB1 3ER",
|
||||
lat: 52.1995, lng: 0.1641,
|
||||
prices: [.e10: 136.9, .e5: 143.9, .diesel: 143.9],
|
||||
FuelStation(id: "h8", name: "Gulf Brighouse", brand: "Gulf",
|
||||
address: "Bradford Road", postcode: "HD6 1RW",
|
||||
lat: 53.7000, lng: -1.7850,
|
||||
prices: [.e10: 143.9, .e5: 151.9, .diesel: 149.9],
|
||||
priceUpdated: nil),
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user