@@ -15,24 +15,33 @@ public struct Table<Row>: View {
1515 _ children: EmptyViewContent . Children ,
1616 backend: Backend
1717 ) -> Backend . Widget {
18- return backend. createTable ( rows: rows. count, columns: columns. count)
18+ return backend. createTable ( rows: rows. count + 1 , columns: columns. count)
1919 }
2020
2121 public func update< Backend: AppBackend > (
2222 _ widget: Backend . Widget ,
2323 children: EmptyViewContent . Children ,
2424 backend: Backend
2525 ) {
26- backend. setRowCount ( ofTable: widget, to: rows. count)
26+ backend. setRowCount ( ofTable: widget, to: rows. count + 1 )
2727 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 ( ) {
3140 backend. setCell (
32- at: CellPosition ( i, j) ,
41+ at: CellPosition ( i + 1 , j) ,
3342 inTable: widget,
3443 to: backend. createTextView (
35- content: columns [ j ] . value ( row) ,
44+ content: column . value ( row) ,
3645 shouldWrap: false
3746 )
3847 )
0 commit comments