Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abc737eb2d | ||
|
|
3d5c999dc2 | ||
|
|
d899409b78 | ||
|
|
8bbcb0b4dc | ||
|
|
767080a983 | ||
|
|
7a84364238 |
@@ -30,7 +30,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2</string>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSLocalNetworkUsageDescription</key>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.1</string>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2</string>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
|
||||
@@ -406,7 +406,7 @@
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
DEVELOPMENT_TEAM = F3BE6NE7U3;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
@@ -472,7 +472,7 @@
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
DEVELOPMENT_TEAM = F3BE6NE7U3;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
@@ -537,7 +537,7 @@
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
DEVELOPMENT_TEAM = F3BE6NE7U3;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
@@ -602,7 +602,7 @@
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 2;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
DEVELOPMENT_TEAM = F3BE6NE7U3;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
@@ -699,7 +699,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = Config/App.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
DEVELOPMENT_TEAM = F3BE6NE7U3;
|
||||
GENERATE_INFOPLIST_FILE = NO;
|
||||
INFOPLIST_FILE = "Config/App-Info.plist";
|
||||
@@ -707,7 +707,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 1.0.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.apt.fuelboard;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -722,7 +722,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_ENTITLEMENTS = Config/App.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
DEVELOPMENT_TEAM = F3BE6NE7U3;
|
||||
GENERATE_INFOPLIST_FILE = NO;
|
||||
INFOPLIST_FILE = "Config/App-Info.plist";
|
||||
@@ -730,7 +730,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 1.0.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.apt.fuelboard;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -745,7 +745,7 @@
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Config/Widget.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
DEVELOPMENT_TEAM = F3BE6NE7U3;
|
||||
GENERATE_INFOPLIST_FILE = NO;
|
||||
INFOPLIST_FILE = "Config/Widget-Info.plist";
|
||||
@@ -754,7 +754,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 1.0.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.apt.fuelboard.widgets;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
@@ -770,7 +770,7 @@
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Config/Widget.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
CURRENT_PROJECT_VERSION = 3;
|
||||
DEVELOPMENT_TEAM = F3BE6NE7U3;
|
||||
GENERATE_INFOPLIST_FILE = NO;
|
||||
INFOPLIST_FILE = "Config/Widget-Info.plist";
|
||||
@@ -779,7 +779,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
MARKETING_VERSION = 1.0.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.apt.fuelboard.widgets;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
|
||||
@@ -46,9 +46,11 @@ final class WatchSyncManager: NSObject, WCSessionDelegate {
|
||||
if let favourites = try? JSONEncoder().encode(FuelStore.loadFavourites()) {
|
||||
context[FuelStore.favouritesKey] = favourites
|
||||
}
|
||||
if let stations = try? JSONEncoder().encode(FuelStore.loadStations()) {
|
||||
context[FuelStore.stationsKey] = stations
|
||||
}
|
||||
// Do NOT send the full station dump to watchOS via WatchConnectivity.
|
||||
// The UK dataset is megabytes large and exceeds application-context
|
||||
// payload limits, which prevents any snapshot from arriving. The
|
||||
// favourites payload already carries station snapshots + prices, so the
|
||||
// watch can render favourites without the full list.
|
||||
|
||||
context[FuelStore.fuelKey] = FuelStore.loadSelectedFuel().rawValue
|
||||
context[FuelStore.distanceUnitKey] = FuelStore.loadDistanceUnit().rawValue
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../Shared/DataRefreshMode.swift
|
||||
@@ -1,5 +1,6 @@
|
||||
import SwiftUI
|
||||
import Foundation
|
||||
import MapKit
|
||||
|
||||
private enum WatchFuelType: String, CaseIterable, Identifiable, Codable {
|
||||
case e10
|
||||
@@ -102,6 +103,8 @@ private struct WatchFavouriteRow: Identifiable {
|
||||
let priceText: String
|
||||
let distanceText: String?
|
||||
let isCheapest: Bool
|
||||
let latitude: Double
|
||||
let longitude: Double
|
||||
}
|
||||
|
||||
private enum WatchRefreshState {
|
||||
@@ -109,6 +112,7 @@ private enum WatchRefreshState {
|
||||
case stale(lastUpdated: String)
|
||||
case checking
|
||||
case requested(lastUpdated: String)
|
||||
case checkedNoNewData(lastUpdated: String)
|
||||
case needsPhone
|
||||
case noData
|
||||
|
||||
@@ -117,7 +121,8 @@ private enum WatchRefreshState {
|
||||
case .idle(let lastUpdated): return "Updated \(lastUpdated)"
|
||||
case .stale(let lastUpdated): return "Cache from \(lastUpdated)"
|
||||
case .checking: return "Checking…"
|
||||
case .requested(let lastUpdated): return "Requested · \(lastUpdated)"
|
||||
case .requested(let lastUpdated): return "Updated · \(lastUpdated)"
|
||||
case .checkedNoNewData(let lastUpdated): return "No newer data · \(lastUpdated)"
|
||||
case .needsPhone: return "Refresh on iPhone"
|
||||
case .noData: return "No cached prices yet"
|
||||
}
|
||||
@@ -129,6 +134,7 @@ private enum WatchRefreshState {
|
||||
case .stale: return .yellow
|
||||
case .checking: return .yellow
|
||||
case .requested: return .green
|
||||
case .checkedNoNewData: return .secondary
|
||||
case .needsPhone: return .orange
|
||||
case .noData: return .secondary
|
||||
}
|
||||
@@ -140,6 +146,7 @@ private enum WatchRefreshState {
|
||||
case .stale: return "exclamationmark.circle"
|
||||
case .checking: return "arrow.triangle.2.circlepath"
|
||||
case .requested: return "checkmark.circle"
|
||||
case .checkedNoNewData: return "clock.badge.exclamationmark"
|
||||
case .needsPhone: return "iphone"
|
||||
case .noData: return "tray"
|
||||
}
|
||||
@@ -283,14 +290,30 @@ struct ContentView: View {
|
||||
@State private var distanceUnit: WatchDistanceUnit = WatchFuelCache.loadDistanceUnit()
|
||||
@State private var priceStyle: WatchPriceStyle = WatchFuelCache.loadPriceStyle()
|
||||
|
||||
private var displayedFuels: [WatchFuelType] {
|
||||
let fuels = Set(favourites.map(\.fuel))
|
||||
let sorted = fuels.sorted { $0.sortRank < $1.sortRank }
|
||||
return sorted.isEmpty ? [fuel] : sorted
|
||||
}
|
||||
|
||||
private var hasAnyFavourites: Bool {
|
||||
!favourites.isEmpty
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
TabView(selection: $fuel) {
|
||||
ForEach(WatchFuelType.allCases) { fuelCase in
|
||||
fuelPage(for: fuelCase)
|
||||
.tag(fuelCase)
|
||||
Group {
|
||||
if hasAnyFavourites {
|
||||
TabView(selection: $fuel) {
|
||||
ForEach(displayedFuels) { fuelCase in
|
||||
fuelPage(for: fuelCase)
|
||||
.tag(fuelCase)
|
||||
}
|
||||
}
|
||||
.tabViewStyle(.verticalPage)
|
||||
} else {
|
||||
emptyStateView
|
||||
}
|
||||
}
|
||||
.tabViewStyle(.verticalPage)
|
||||
.onAppear {
|
||||
reloadFromCache()
|
||||
WatchSyncManager.shared.requestSnapshot()
|
||||
@@ -301,6 +324,7 @@ struct ContentView: View {
|
||||
.onChange(of: scenePhase) { _, newPhase in
|
||||
if newPhase == .active {
|
||||
reloadFromCache()
|
||||
WatchSyncManager.shared.requestSnapshot()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,8 +341,6 @@ struct ContentView: View {
|
||||
|
||||
if let cheapest {
|
||||
cheapestCard(for: fuelCase, favourite: cheapest)
|
||||
} else {
|
||||
emptyCheapestCard(for: fuelCase)
|
||||
}
|
||||
|
||||
statusRow
|
||||
@@ -340,14 +362,8 @@ struct ContentView: View {
|
||||
Text("Favourites")
|
||||
.font(.headline)
|
||||
|
||||
if rows.isEmpty {
|
||||
Text("No favourites for \(fuelCase.displayName.lowercased()) yet.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
} else {
|
||||
ForEach(rows) { row in
|
||||
favouriteRow(row, fuel: fuelCase)
|
||||
}
|
||||
ForEach(rows) { row in
|
||||
favouriteRow(row, fuel: fuelCase)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,7 +388,9 @@ struct ContentView: View {
|
||||
name: favourite.station.name,
|
||||
priceText: priceText,
|
||||
distanceText: distanceText,
|
||||
isCheapest: favourite.id == cheapest?.id
|
||||
isCheapest: favourite.id == cheapest?.id,
|
||||
latitude: favourite.station.lat,
|
||||
longitude: favourite.station.lng
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -392,44 +410,76 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func cheapestCard(for fuel: WatchFuelType, favourite: WatchFavouriteEntry) -> some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text("Cheapest favourite")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
Text(favourite.station.name)
|
||||
.font(.headline)
|
||||
.lineLimit(2)
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text(favourite.station.prices[fuel].map { WatchFuelCache.priceText($0, style: priceStyle) } ?? "—")
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
Spacer()
|
||||
if let location = lastLocation {
|
||||
Text(distanceUnit.format(km: favourite.station.distanceKM(to: location)))
|
||||
private var emptyStateView: some View {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
HStack(alignment: .center, spacing: 8) {
|
||||
Image(systemName: "fuelpump.fill")
|
||||
.foregroundStyle(Color(red: 48/255.0, green: 209/255.0, blue: 88/255.0))
|
||||
Text("FuelBoard")
|
||||
.font(.headline)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
statusRow
|
||||
|
||||
Button {
|
||||
runCheckNow()
|
||||
} label: {
|
||||
HStack {
|
||||
Image(systemName: refreshState.icon)
|
||||
Text("Check now")
|
||||
.fontWeight(.semibold)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(Color(red: 48/255.0, green: 209/255.0, blue: 88/255.0))
|
||||
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text("No favourites yet")
|
||||
.font(.headline)
|
||||
Text("Add favourites on iPhone and they’ll appear here.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.padding(10)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(Color.white.opacity(0.06), in: RoundedRectangle(cornerRadius: 14, style: .continuous))
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 12)
|
||||
}
|
||||
.padding(10)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(fuel.color.opacity(0.15), in: RoundedRectangle(cornerRadius: 14, style: .continuous))
|
||||
}
|
||||
|
||||
private func emptyCheapestCard(for fuel: WatchFuelType) -> some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text("Cheapest favourite")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
Text("No favourite saved")
|
||||
.font(.headline)
|
||||
Text("Add favourites on iPhone to see them here.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
private func cheapestCard(for fuel: WatchFuelType, favourite: WatchFavouriteEntry) -> some View {
|
||||
Button {
|
||||
openMaps(latitude: favourite.station.lat, longitude: favourite.station.lng)
|
||||
} label: {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text("Cheapest favourite")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
Text(favourite.station.name)
|
||||
.font(.headline)
|
||||
.lineLimit(2)
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text(favourite.station.prices[fuel].map { WatchFuelCache.priceText($0, style: priceStyle) } ?? "—")
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
Spacer()
|
||||
if let location = lastLocation {
|
||||
Text(distanceUnit.format(km: favourite.station.distanceKM(to: location)))
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(10)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.contentShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
|
||||
}
|
||||
.padding(10)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.buttonStyle(.plain)
|
||||
.background(fuel.color.opacity(0.15), in: RoundedRectangle(cornerRadius: 14, style: .continuous))
|
||||
}
|
||||
|
||||
@@ -441,34 +491,40 @@ struct ContentView: View {
|
||||
}
|
||||
|
||||
private func favouriteRow(_ favourite: WatchFavouriteRow, fuel: WatchFuelType) -> some View {
|
||||
HStack(spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
HStack(spacing: 4) {
|
||||
Text(favourite.name)
|
||||
.font(.caption)
|
||||
.fontWeight(favourite.isCheapest ? .semibold : .regular)
|
||||
.lineLimit(1)
|
||||
if favourite.isCheapest {
|
||||
Text("TOP")
|
||||
.font(.system(size: 9, weight: .bold))
|
||||
.padding(.horizontal, 4)
|
||||
.padding(.vertical, 2)
|
||||
.background(fuel.color.opacity(0.18), in: Capsule())
|
||||
Button {
|
||||
openMaps(latitude: favourite.latitude, longitude: favourite.longitude)
|
||||
} label: {
|
||||
HStack(spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
HStack(spacing: 4) {
|
||||
Text(favourite.name)
|
||||
.font(.caption)
|
||||
.fontWeight(favourite.isCheapest ? .semibold : .regular)
|
||||
.lineLimit(1)
|
||||
if favourite.isCheapest {
|
||||
Text("TOP")
|
||||
.font(.system(size: 9, weight: .bold))
|
||||
.padding(.horizontal, 4)
|
||||
.padding(.vertical, 2)
|
||||
.background(fuel.color.opacity(0.18), in: Capsule())
|
||||
}
|
||||
}
|
||||
if let distanceText = favourite.distanceText {
|
||||
Text(distanceText)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
if let distanceText = favourite.distanceText {
|
||||
Text(distanceText)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer()
|
||||
Text(favourite.priceText)
|
||||
.font(.callout.monospacedDigit())
|
||||
.fontWeight(.semibold)
|
||||
}
|
||||
Spacer()
|
||||
Text(favourite.priceText)
|
||||
.font(.callout.monospacedDigit())
|
||||
.fontWeight(.semibold)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 8)
|
||||
.contentShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
|
||||
}
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 8)
|
||||
.buttonStyle(.plain)
|
||||
.background(Color.white.opacity(0.06), in: RoundedRectangle(cornerRadius: 12, style: .continuous))
|
||||
}
|
||||
|
||||
@@ -499,6 +555,7 @@ struct ContentView: View {
|
||||
|
||||
private func runCheckNow() {
|
||||
refreshState = .checking
|
||||
let previousLastRefresh = WatchFuelCache.loadLastRefresh()
|
||||
let requestDate = Date()
|
||||
WatchFuelCache.requestRefresh(requestDate)
|
||||
WatchSyncManager.shared.requestRefresh(at: requestDate)
|
||||
@@ -508,8 +565,16 @@ struct ContentView: View {
|
||||
if WatchFuelCache.wasRefreshHandled(since: requestDate) {
|
||||
await MainActor.run {
|
||||
reloadFromCache()
|
||||
let label = WatchFuelCache.loadLastRefresh().map(relativeRefreshText(for:)) ?? "just now"
|
||||
refreshState = .requested(lastUpdated: label)
|
||||
let currentLastRefresh = WatchFuelCache.loadLastRefresh()
|
||||
if let currentLastRefresh,
|
||||
currentLastRefresh >= requestDate,
|
||||
currentLastRefresh > (previousLastRefresh ?? .distantPast) {
|
||||
refreshState = .requested(lastUpdated: relativeRefreshText(for: currentLastRefresh))
|
||||
} else if let currentLastRefresh {
|
||||
refreshState = .checkedNoNewData(lastUpdated: relativeRefreshText(for: currentLastRefresh))
|
||||
} else {
|
||||
refreshState = .noData
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -526,6 +591,17 @@ struct ContentView: View {
|
||||
formatter.unitsStyle = .short
|
||||
return formatter.localizedString(for: date, relativeTo: Date())
|
||||
}
|
||||
|
||||
private func openMaps(latitude: Double, longitude: Double) {
|
||||
let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
|
||||
let destination = MKMapItem(placemark: MKPlacemark(coordinate: coordinate))
|
||||
_ = MKMapItem.openMaps(
|
||||
with: [MKMapItem.forCurrentLocation(), destination],
|
||||
launchOptions: [
|
||||
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
|
||||
@@ -59,9 +59,6 @@ final class WatchSyncManager: NSObject, WCSessionDelegate {
|
||||
if let favourites = payload["fuelboard.favourites"] as? Data {
|
||||
defaults.set(favourites, forKey: "fuelboard.favourites")
|
||||
}
|
||||
if let stations = payload["fuelboard.stations"] as? Data {
|
||||
defaults.set(stations, forKey: "fuelboard.stations")
|
||||
}
|
||||
if let fuel = payload["fuelboard.selectedFuel"] as? String {
|
||||
defaults.set(fuel, forKey: "fuelboard.selectedFuel")
|
||||
}
|
||||
|
||||
@@ -147,9 +147,9 @@ private struct FuelBoardLiveActivityView: View {
|
||||
}
|
||||
|
||||
/// Minimal strip for small space (CarPlay small / Watch smart stack):
|
||||
/// fuel type + bold price on one line, station · distance below.
|
||||
/// Deliberately no app name and no "Tap for directions" — CarPlay is
|
||||
/// display-only, and the user's asks here are just fuel + price + distance.
|
||||
/// fuel type + distance + bold price on one line, station name below.
|
||||
/// Deliberately no app name and no full address — the watch-sized slot is
|
||||
/// too tight, so the second line is reserved for the station name only.
|
||||
private var compactBody: some View {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
HStack(spacing: 5) {
|
||||
@@ -157,16 +157,21 @@ private struct FuelBoardLiveActivityView: View {
|
||||
.font(.caption.bold())
|
||||
.lineLimit(1)
|
||||
Spacer(minLength: 4)
|
||||
Text(context.state.distanceText)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
Spacer(minLength: 4)
|
||||
FuelStore.priceTextAttributed(context.state.pricePence,
|
||||
style: context.state.priceDisplayStyle,
|
||||
size: 15, weight: .bold)
|
||||
.lineLimit(1)
|
||||
}
|
||||
Text("\(context.state.stationName) · \(context.state.distanceText)")
|
||||
.font(.system(size: 9))
|
||||
Text(context.state.stationName)
|
||||
.font(.system(size: 10, weight: .medium))
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.7)
|
||||
.minimumScaleFactor(0.75)
|
||||
.truncationMode(.tail)
|
||||
}
|
||||
.padding(8)
|
||||
|
||||
Reference in New Issue
Block a user