From 644342ae63f4d6a1d566ce6c9641d5f56f98b865 Mon Sep 17 00:00:00 2001 From: FuelBoard Contributor Date: Tue, 11 Aug 2026 21:54:56 +0100 Subject: [PATCH] Nav bar: always show gas-pump icon next to title (inline mode); remove scroll-offset row hack --- FuelBoard/StationsView.swift | 40 ++++++------------------------------ 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/FuelBoard/StationsView.swift b/FuelBoard/StationsView.swift index d8de826..75333b7 100644 --- a/FuelBoard/StationsView.swift +++ b/FuelBoard/StationsView.swift @@ -22,23 +22,10 @@ struct StationsView: View { /// which station is "best". @State private var pageSize = 10 @State private var visibleCount = 10 - /// True once the list has scrolled — drives the compact gas-pump+title bar - /// in the nav bar (large title is shown at rest, bar only after scrolling). - @State private var isScrolled = false var body: some View { NavigationStack { List { - GeometryReader { proxy in - Color.clear.preference( - key: ScrollOffsetKey.self, - value: proxy.frame(in: .named("stationsScroll")).minY - ) - } - .frame(height: 0) - .listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) - .listRowSeparator(.hidden) - Section { if let location { if sortMode == .closest { @@ -193,23 +180,17 @@ struct StationsView: View { // New fetch or filter switch → back to the first page. visibleCount = pageSize } - .coordinateSpace(name: "stationsScroll") - .onPreferenceChange(ScrollOffsetKey.self) { minY in - isScrolled = minY < 0 - } .toolbar { ToolbarItem(placement: .principal) { - if isScrolled { - HStack(spacing: 6) { - Image(systemName: "fuelpump.fill") - .foregroundStyle(selectedFuel.tintColor) - Text("FuelBoard") - .font(.headline) - } - .transition(.opacity) + HStack(spacing: 6) { + Image(systemName: "fuelpump.fill") + .foregroundStyle(selectedFuel.tintColor) + Text("FuelBoard") + .font(.headline) } } } + .navigationBarTitleDisplayMode(.inline) .navigationTitle("FuelBoard") } } @@ -217,15 +198,6 @@ struct StationsView: View { // MARK: - Fuel-type iconography (app target only — FuelStore.swift is Foundation-only) -/// Scroll offset preference — the zero-height row at the top of the List -/// reports its position so we know when the large title has collapsed. -private struct ScrollOffsetKey: PreferenceKey { - static var defaultValue: CGFloat = 0 - static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { - value = nextValue() - } -} - extension FuelType { /// Short segment label ("Unleaded" / "Premium" / "Diesel") for the picker. var shortName: String {