Trends: anchor empty/loading/error states to the top of the chart slot

The no-data states previously floated or centred vertically (Spacer
sandwich), so the sheet rendered them halfway down the page while the
chart-with-data anchors to the top. All chartArea states now share one
top-aligned container that fills the space below the pickers — the
empty state sits exactly where the chart will render, and the layout no
longer jumps between states. 83 tests, Release build green.
This commit is contained in:
FuelBoard Contributor
2026-08-15 12:30:25 +01:00
parent d1fbac3f05
commit 54aca14fd4
+10 -4
View File
@@ -147,12 +147,16 @@ struct TrendsView: View {
@ViewBuilder @ViewBuilder
private var chartArea: some View { private var chartArea: some View {
// Every state anchors to the TOP of the chart slot the same spot the
// chart occupies when data exists. The empty/loading/error states must
// not float or centre in the sheet, or the layout jumps between states.
Group {
if isLoading { if isLoading {
Spacer() VStack(spacing: 12) {
ProgressView("Fetching price history…") ProgressView("Fetching price history…")
Spacer() }
.padding(.top, 24)
} else if loadFailed { } else if loadFailed {
Spacer()
VStack(spacing: 10) { VStack(spacing: 10) {
Image(systemName: "wifi.exclamationmark") Image(systemName: "wifi.exclamationmark")
.font(.system(size: 32)) .font(.system(size: 32))
@@ -162,7 +166,7 @@ struct TrendsView: View {
Button("Retry") { Task { await load() } } Button("Retry") { Task { await load() } }
.buttonStyle(.bordered) .buttonStyle(.bordered)
} }
Spacer() .padding(.top, 24)
} else if !hasAnyData { } else if !hasAnyData {
emptyState emptyState
} else if !hasEnoughData { } else if !hasEnoughData {
@@ -174,6 +178,8 @@ struct TrendsView: View {
} }
} }
} }
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
}
private var emptyState: some View { private var emptyState: some View {
VStack(spacing: 10) { VStack(spacing: 10) {