Skip to content

Commit

Permalink
update the order of rowIndex and columnIndex to be consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny-chung committed Sep 3, 2023
1 parent beaca80 commit 5cc419d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import androidx.compose.ui.unit.Dp
@Composable
fun Table(
modifier: Modifier = Modifier,
columnCount: Int,
rowCount: Int,
columnCount: Int,
stickyRowCount: Int = 0,
stickyColumnCount: Int = 0,
maxCellWidthDp: Dp = Dp.Infinity,
maxCellHeightDp: Dp = Dp.Infinity,
verticalScrollState: ScrollState = rememberScrollState(),
horizontalScrollState: ScrollState = rememberScrollState(),
cellContent: @Composable (columnIndex: Int, rowIndex: Int) -> Unit
cellContent: @Composable (rowIndex: Int, columnIndex: Int) -> Unit
) {
val columnWidths = remember { mutableStateMapOf<Int, Int>() }
val rowHeights = remember { mutableStateMapOf<Int, Int>() }
Expand All @@ -47,14 +47,12 @@ fun Table(
@Composable
fun StickyCells(modifier: Modifier = Modifier, rowCount: Int, columnCount: Int) {
if (rowCount > 0 && columnCount > 0) {
Box(
modifier = modifier
) {
Box(modifier = modifier) {
Layout(
content = {
(0 until rowCount).forEach { rowIndex ->
(0 until columnCount).forEach { columnIndex ->
cellContent(columnIndex = columnIndex, rowIndex = rowIndex)
cellContent(rowIndex = rowIndex, columnIndex = columnIndex)
}
}
},
Expand Down Expand Up @@ -99,10 +97,9 @@ fun Table(
) {
Layout(
content = {

(0 until rowCount).forEach { rowIndex ->
(0 until columnCount).forEach { columnIndex ->
cellContent(columnIndex = columnIndex, rowIndex = rowIndex)
cellContent(rowIndex = rowIndex, columnIndex = columnIndex)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fun AppView() {
stickyRowCount = 2,
stickyColumnCount = 2,
maxCellWidthDp = 320.dp
) { columnIndex, rowIndex ->
) { rowIndex, columnIndex ->
val header = headers[columnIndex]
if (rowIndex == 0) {
HeaderCell(header)
Expand Down

0 comments on commit 5cc419d

Please sign in to comment.