@@ -15,24 +15,33 @@ public struct Table<Row>: View {
15
15
_ children: EmptyViewContent . Children ,
16
16
backend: Backend
17
17
) -> Backend . Widget {
18
- return backend. createTable ( rows: rows. count, columns: columns. count)
18
+ return backend. createTable ( rows: rows. count + 1 , columns: columns. count)
19
19
}
20
20
21
21
public func update< Backend: AppBackend > (
22
22
_ widget: Backend . Widget ,
23
23
children: EmptyViewContent . Children ,
24
24
backend: Backend
25
25
) {
26
- backend. setRowCount ( ofTable: widget, to: rows. count)
26
+ backend. setRowCount ( ofTable: widget, to: rows. count + 1 )
27
27
backend. setColumnCount ( ofTable: widget, to: columns. count)
28
- for i in 0 ..< rows. count {
29
- let row = rows [ i]
30
- for j in 0 ..< columns. count {
28
+ for (i, column) in columns. enumerated ( ) {
29
+ backend. setCell (
30
+ at: CellPosition ( 0 , i) ,
31
+ inTable: widget,
32
+ to: backend. createTextView (
33
+ content: column. title,
34
+ shouldWrap: false
35
+ )
36
+ )
37
+ }
38
+ for (i, row) in rows. enumerated ( ) {
39
+ for (j, column) in columns. enumerated ( ) {
31
40
backend. setCell (
32
- at: CellPosition ( i, j) ,
41
+ at: CellPosition ( i + 1 , j) ,
33
42
inTable: widget,
34
43
to: backend. createTextView (
35
- content: columns [ j ] . value ( row) ,
44
+ content: column . value ( row) ,
36
45
shouldWrap: false
37
46
)
38
47
)
0 commit comments