import SwiftUI struct SheetTable: View { @Bindable var model: SheetModel var body: some View { VStack { HStack { Button("Back to grid") { model.showTable = false } Button("Previous page") { model.tablePage -= 1 Task { await model.loadTable() } }.disabled(model.table?.HasPrev != true || model.hasUnconfirmedChanges || model.busy) Text("Page \(model.tablePage)") Button("Next page") { model.tablePage += 1 Task { await model.loadTable() } }.disabled(model.table?.HasNext != true || model.hasUnconfirmedChanges || model.busy) } ScrollView([.horizontal, .vertical]) { LazyVStack(spacing: 0) { ForEach(model.table?.Rows ?? [], id: \.Number) { row in HStack(spacing: 0) { Text(String(row.Number)).frame(width: 48) ForEach(row.Cells, id: \.C) { cell in SheetCell(model: model, point: Coordinate(r: cell.R, c: cell.C), editing: .constant(nil), select: { model.select(Coordinate(r: cell.R, c: cell.C)) }, endEditing: {}) } } } } } }.task { await model.loadTable() } } }