import SwiftUI /// The "How Best Value works" explanation as its own sheet. /// /// It used to sit inline in the Key sheet as a `Section`; it is one shared view /// now so the Key sheet and the More info sheet can both open it, and the copy is /// unchanged (the same `Localizable.strings` keys are reused — the old section /// header string is the sheet's title). struct HowBestValueSheet: View { @Environment(\.dismiss) private var dismiss var body: some View { NavigationStack { List { Section { VStack(alignment: .leading, spacing: 10) { Text("Best Value compares each station with the closest one. It works out what you could save at the pump, then takes off the fuel used for the extra return journey.") Text("Your fill-up amount and MPG are used to show whether you could save overall.") Text("Results are marked “Approx.” until road distances are available.") .foregroundStyle(.secondary) } .font(.subheadline) .padding(.vertical, 4) } } .navigationTitle("How Best Value works") .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .confirmationAction) { Button("Done") { dismiss() } } } } .presentationDetents([.fraction(0.42)]) .presentationBackground(Color(UIColor.systemGroupedBackground)) } } /// The row that opens `HowBestValueSheet`. A tappable row with a chevron, like /// the other rows in both sheets. `.buttonStyle(.plain)` keeps it from becoming a /// row-wide tap target that could swallow a neighbouring control (see the /// two-buttons-in-one-row rule). struct HowBestValueRow: View { let action: () -> Void var body: some View { Button(action: action) { HStack(spacing: 8) { Text("How Best Value works") Spacer(minLength: 8) Image(systemName: "chevron.forward") .font(.footnote.weight(.semibold)) .foregroundStyle(.tertiary) } } .buttonStyle(.plain) } } #if DEBUG /// QA hook support: `-showBestValueInfo` opens this sheet without a tap, so it can /// be screenshotted (simctl has no tap command) — the same pattern as /// `-showKeySheet` / `-showDetail`. enum BestValueInfoQA { static var isRequested: Bool { ProcessInfo.processInfo.arguments.contains("-showBestValueInfo") } } #endif