Skip to content

Commit

Permalink
onCellClick: add column, row index
Browse files Browse the repository at this point in the history
  • Loading branch information
cometj03 committed Dec 6, 2022
1 parent a04f501 commit 0bec530
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import kotlin.math.min
@Composable
fun ComposeTimeTable(
timeTableData: TimeTableData,
onCellClick: (dayName: String, ScheduleEntity) -> Unit,
onCellClick: (column: Int, row: Int, ScheduleEntity) -> Unit,
modifier: Modifier = Modifier,
) = ComposeTimeTable(
dayNames = timeTableData.dayNameList,
Expand All @@ -33,7 +33,7 @@ fun ComposeTimeTable(
fun ComposeTimeTable(
dayNames: List<String>,
timeTableData: TimeTableData,
onCellClick: (dayName: String, ScheduleEntity) -> Unit,
onCellClick: (column: Int, row: Int, ScheduleEntity) -> Unit,
modifier: Modifier = Modifier,
) {
val startHour = min(timeTableData.earliestStartHour, tableStartHour)
Expand Down Expand Up @@ -70,7 +70,7 @@ fun ComposeTimeTable(

TimeTableCell(
cellData = scheduleEntity,
onCellClick = { entity -> onCellClick(dayNames[column], entity) },
onCellClick = { entity -> onCellClick(column, index, entity) },
modifier = Modifier
.padding(minBorderWidth)
.timeTableCell(
Expand Down Expand Up @@ -129,7 +129,7 @@ fun TimeTablePreview() {
Column {
ComposeTimeTable(
timeTableData = timeTableData,
onCellClick = { _, _ -> Unit },
onCellClick = { _, _, _ -> },
modifier = Modifier
.verticalScroll(scrollState)
.wrapContentSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,4 @@ class TimeTableParentData(
val offset: Float
) : ParentDataModifier {
override fun Density.modifyParentData(parentData: Any?) = this@TimeTableParentData
}

@Preview(showBackground = true, showSystemUi = true)
@Composable
fun ScheduleTimeCellPreview() {
val entities = timeTableData.scheduleDayDataList[0].scheduleEntities

Row(
Modifier.fillMaxWidth()
) {
repeat(3) {
TimeTableCell(cellData = entities[it], onCellClick = {})
}
}
}

0 comments on commit 0bec530

Please sign in to comment.