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:
@@ -147,12 +147,16 @@ struct TrendsView: View {
|
||||
|
||||
@ViewBuilder
|
||||
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 {
|
||||
Spacer()
|
||||
VStack(spacing: 12) {
|
||||
ProgressView("Fetching price history…")
|
||||
Spacer()
|
||||
}
|
||||
.padding(.top, 24)
|
||||
} else if loadFailed {
|
||||
Spacer()
|
||||
VStack(spacing: 10) {
|
||||
Image(systemName: "wifi.exclamationmark")
|
||||
.font(.system(size: 32))
|
||||
@@ -162,7 +166,7 @@ struct TrendsView: View {
|
||||
Button("Retry") { Task { await load() } }
|
||||
.buttonStyle(.bordered)
|
||||
}
|
||||
Spacer()
|
||||
.padding(.top, 24)
|
||||
} else if !hasAnyData {
|
||||
emptyState
|
||||
} else if !hasEnoughData {
|
||||
@@ -174,6 +178,8 @@ struct TrendsView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
||||
}
|
||||
|
||||
private var emptyState: some View {
|
||||
VStack(spacing: 10) {
|
||||
|
||||
Reference in New Issue
Block a user