oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1import SwiftUI
2
3struct SheetTable: View {
4 @Bindable var model: SheetModel
5 var body: some View {
6 VStack {
7 HStack {
8 Button("Back to grid") { model.showTable = false }
9 Button("Previous page") {
10 model.tablePage -= 1
11 Task { await model.loadTable() }
12 }.disabled(model.table?.HasPrev != true || model.hasUnconfirmedChanges || model.busy)
13 Text("Page \(model.tablePage)")
14 Button("Next page") {
15 model.tablePage += 1
16 Task { await model.loadTable() }
17 }.disabled(model.table?.HasNext != true || model.hasUnconfirmedChanges || model.busy)
18 }
19 ScrollView([.horizontal, .vertical]) {
20 LazyVStack(spacing: 0) {
21 ForEach(model.table?.Rows ?? [], id: \.Number) { row in
22 HStack(spacing: 0) {
23 Text(String(row.Number)).frame(width: 48)
24 ForEach(row.Cells, id: \.C) { cell in
25 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: {})
26 }
27 }
28 }
29 }
30 }
31 }.task { await model.loadTable() }
32 }
33}
34