Stations: move price-rating Key (legend) into a modal sheet opened by an info button in the nav header; list stays focused on stations. Sheet = medium detent, inline nav title 'Key', Done button; legend rows unchanged. Adds -showKeySheet launch arg (QA hook for sim).
This commit is contained in:
@@ -25,6 +25,10 @@ struct StationsView: View {
|
||||
@State private var pageSize = 10
|
||||
@State private var visibleCount = 10
|
||||
|
||||
/// Price-rating legend (the "Key") lives in a sheet, opened from the
|
||||
/// info button in the header — keeps the list focused on stations.
|
||||
@State private var showKey = false
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List {
|
||||
@@ -127,40 +131,6 @@ struct StationsView: View {
|
||||
}
|
||||
}
|
||||
|
||||
Section("Key") {
|
||||
HStack(spacing: 8) {
|
||||
Circle().fill(.green).frame(width: 12, height: 12)
|
||||
Text("Best value — within 1.5p of the cheapest")
|
||||
.font(.caption)
|
||||
}
|
||||
HStack(spacing: 8) {
|
||||
Circle().fill(.orange).frame(width: 12, height: 12)
|
||||
Text("Okay — within 4p of the cheapest")
|
||||
.font(.caption)
|
||||
}
|
||||
HStack(spacing: 8) {
|
||||
Circle().fill(.red).frame(width: 12, height: 12)
|
||||
Text("Pricey — more than 4p over the cheapest")
|
||||
.font(.caption)
|
||||
}
|
||||
HStack(spacing: 8) {
|
||||
Text("TOP")
|
||||
.font(.caption2.bold())
|
||||
.padding(.horizontal, 5)
|
||||
.padding(.vertical, 1)
|
||||
.background(Capsule().fill(.blue.opacity(0.15)))
|
||||
.foregroundStyle(.blue)
|
||||
Text("Top result for the current sort")
|
||||
.font(.caption)
|
||||
}
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "star.fill")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.yellow)
|
||||
Text("Star a station to add it to Favourites")
|
||||
.font(.caption)
|
||||
}
|
||||
}
|
||||
}
|
||||
.refreshable {
|
||||
// Manual override for the twice-a-day cache policy.
|
||||
@@ -176,6 +146,71 @@ struct StationsView: View {
|
||||
// only renders text, which is exactly what we want here.
|
||||
.navigationTitle("FuelBoard")
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
.onAppear {
|
||||
// QA hook: launch with `-showKeySheet` to verify the legend
|
||||
// sheet without driving a tap (simctl has no tap command).
|
||||
if ProcessInfo.processInfo.arguments.contains("-showKeySheet") {
|
||||
showKey = true
|
||||
}
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .topBarTrailing) {
|
||||
Button {
|
||||
showKey = true
|
||||
} label: {
|
||||
Image(systemName: "info.circle")
|
||||
}
|
||||
.accessibilityLabel("Key")
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showKey) {
|
||||
NavigationStack {
|
||||
List {
|
||||
Section("Key") {
|
||||
HStack(spacing: 8) {
|
||||
Circle().fill(.green).frame(width: 12, height: 12)
|
||||
Text("Best value — within 1.5p of the cheapest")
|
||||
.font(.caption)
|
||||
}
|
||||
HStack(spacing: 8) {
|
||||
Circle().fill(.orange).frame(width: 12, height: 12)
|
||||
Text("Okay — within 4p of the cheapest")
|
||||
.font(.caption)
|
||||
}
|
||||
HStack(spacing: 8) {
|
||||
Circle().fill(.red).frame(width: 12, height: 12)
|
||||
Text("Pricey — more than 4p over the cheapest")
|
||||
.font(.caption)
|
||||
}
|
||||
HStack(spacing: 8) {
|
||||
Text("TOP")
|
||||
.font(.caption2.bold())
|
||||
.padding(.horizontal, 5)
|
||||
.padding(.vertical, 1)
|
||||
.background(Capsule().fill(.blue.opacity(0.15)))
|
||||
.foregroundStyle(.blue)
|
||||
Text("Top result for the current sort")
|
||||
.font(.caption)
|
||||
}
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "star.fill")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.yellow)
|
||||
Text("Star a station to add it to Favourites")
|
||||
.font(.caption)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Key")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button("Done") { showKey = false }
|
||||
}
|
||||
}
|
||||
}
|
||||
.presentationDetents([.medium])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user