Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a1ef0bd59 | ||
|
|
551a40ddf0 |
+23
-10
@@ -981,6 +981,21 @@ struct StationRow: View {
|
||||
return String(format: "%+.1fp", delta)
|
||||
}
|
||||
|
||||
private func handleTap() {
|
||||
switch tapAction {
|
||||
case .openMap:
|
||||
if let url = station.mapsDirectionsURL {
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
case .showDetails:
|
||||
showDetails()
|
||||
}
|
||||
}
|
||||
|
||||
private func showDetails() {
|
||||
onShowDetails(station)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 12) {
|
||||
// LEFT — round brand logo (or generic fuel pump fallback)
|
||||
@@ -1017,6 +1032,12 @@ struct StationRow: View {
|
||||
.background(Capsule().fill(.blue.opacity(0.15)))
|
||||
.foregroundStyle(.blue)
|
||||
}
|
||||
ForEach(StationNotice.notices(for: station)) { notice in
|
||||
Image(systemName: notice.symbolName)
|
||||
.font(.caption2.weight(.semibold))
|
||||
.foregroundStyle(.secondary)
|
||||
.accessibilityLabel(notice.title)
|
||||
}
|
||||
}
|
||||
Text("\(station.address), \(station.postcode)")
|
||||
.font(.caption)
|
||||
@@ -1059,16 +1080,8 @@ struct StationRow: View {
|
||||
.buttonStyle(.borderless)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
switch tapAction {
|
||||
case .openMap:
|
||||
if let url = station.mapsDirectionsURL {
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
case .showDetails:
|
||||
onShowDetails(station)
|
||||
}
|
||||
}
|
||||
.onTapGesture(perform: handleTap)
|
||||
.onLongPressGesture(perform: showDetails)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,14 @@ struct StationDetailView: View {
|
||||
LabeledContent("Distance", value: distanceUnit.format(km))
|
||||
.monospacedDigit()
|
||||
}
|
||||
ForEach(StationNotice.notices(for: station)) { notice in
|
||||
Label(notice.title, systemImage: notice.symbolName)
|
||||
.font(.subheadline.weight(.semibold))
|
||||
.foregroundStyle(.orange)
|
||||
.padding(.horizontal, 10)
|
||||
.padding(.vertical, 6)
|
||||
.background(Capsule().fill(Color.orange.opacity(0.14)))
|
||||
}
|
||||
}
|
||||
Section {
|
||||
Button {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import Foundation
|
||||
|
||||
/// Presentation-only notices derived from existing station metadata.
|
||||
///
|
||||
/// These do not alter `FuelStation`, persistence, filtering, sorting, or
|
||||
/// navigation. They are intentionally small and reusable so additional
|
||||
/// informational station notices can be added later from the UI layer.
|
||||
enum StationNotice: Identifiable, Equatable {
|
||||
case membershipRequired
|
||||
|
||||
var id: String {
|
||||
switch self {
|
||||
case .membershipRequired: return "membershipRequired"
|
||||
}
|
||||
}
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .membershipRequired: return "Membership required"
|
||||
}
|
||||
}
|
||||
|
||||
var symbolName: String {
|
||||
switch self {
|
||||
case .membershipRequired: return "creditcard.fill"
|
||||
}
|
||||
}
|
||||
|
||||
static func notices(for station: FuelStation) -> [StationNotice] {
|
||||
isCostco(station) ? [.membershipRequired] : []
|
||||
}
|
||||
|
||||
static func isCostco(_ station: FuelStation) -> Bool {
|
||||
containsCostcoToken(station.brand) || containsCostcoToken(station.name)
|
||||
}
|
||||
|
||||
private static func containsCostcoToken(_ value: String) -> Bool {
|
||||
let tokens = value.uppercased().split { !$0.isLetter && !$0.isNumber }
|
||||
return tokens.contains("COSTCO")
|
||||
}
|
||||
}
|
||||
@@ -148,6 +148,7 @@
|
||||
"Done" = "Done";
|
||||
"Directions" = "Directions";
|
||||
"Report issue" = "Report issue";
|
||||
"Membership required" = "Membership required";
|
||||
"Report an error?" = "Report an error?";
|
||||
"Cancel" = "Cancel";
|
||||
"Report" = "Report";
|
||||
|
||||
Reference in New Issue
Block a user