diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/section/TimetableList.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/section/TimetableList.kt index aa07b5052..a58ab2374 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/section/TimetableList.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/section/TimetableList.kt @@ -2,20 +2,27 @@ package io.github.droidkaigi.confsched.sessions.section import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.calculateEndPadding +import androidx.compose.foundation.layout.calculateStartPadding import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.items import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import io.github.droidkaigi.confsched.designsystem.theme.LocalRoomTheme import io.github.droidkaigi.confsched.model.Timetable import io.github.droidkaigi.confsched.model.TimetableItem +import io.github.droidkaigi.confsched.sessions.component.TimetableTime import io.github.droidkaigi.confsched.ui.component.TimetableItemCard import io.github.droidkaigi.confsched.ui.component.TimetableItemTag import io.github.droidkaigi.confsched.ui.icon @@ -24,7 +31,7 @@ import kotlinx.collections.immutable.PersistentMap const val TimetableListTestTag = "TimetableList" data class TimetableListUiState( - val timetableItemMap: PersistentMap>, + val timetableItemMap: PersistentMap, List>, val timetable: Timetable, ) @@ -37,34 +44,59 @@ fun TimetableList( contentPadding: PaddingValues, modifier: Modifier = Modifier, ) { + val layoutDirection = LocalLayoutDirection.current LazyColumn( modifier = modifier.testTag(TimetableListTestTag), state = scrollState, - verticalArrangement = Arrangement.spacedBy(10.dp), - contentPadding = contentPadding, + verticalArrangement = Arrangement.spacedBy(16.dp), + contentPadding = PaddingValues( + top = contentPadding.calculateTopPadding(), + bottom = contentPadding.calculateBottomPadding(), + start = 16.dp + contentPadding.calculateStartPadding(layoutDirection), + end = 16.dp + contentPadding.calculateEndPadding(layoutDirection), + ), ) { - items(uiState.timetable.timetableItems, key = { it.id.value }) { timetableItem -> - val isBookmarked = uiState.timetable.bookmarks.contains(timetableItem.id) - TimetableItemCard( - isBookmarked = isBookmarked, - timetableItem = timetableItem, - onBookmarkClick = onBookmarkClick, - tags = { - TimetableItemTag( - tagText = timetableItem.room.name.currentLangTitle, - icon = timetableItem.room.icon, - tagColor = LocalRoomTheme.current.primaryColor, - modifier = Modifier.background(LocalRoomTheme.current.containerColor), - ) - Spacer(modifier = Modifier.padding(3.dp)) - timetableItem.language.labels.forEach { label -> - TimetableItemTag(tagText = label, tagColor = MaterialTheme.colorScheme.onSurfaceVariant) - Spacer(modifier = Modifier.padding(3.dp)) + items( + // TODO: Check whether the number of recompositions increases. + items = uiState.timetableItemMap.toList(), + key = { it.first }, + ) { (time, timetableItems) -> + Row { + TimetableTime( + startTime = time.first, + endTime = time.second, + ) + Spacer(modifier = Modifier.width(12.dp)) + Column(verticalArrangement = Arrangement.spacedBy(10.dp)) { + timetableItems.onEach { timetableItem -> + val isBookmarked = + uiState.timetable.bookmarks.contains(timetableItem.id) + TimetableItemCard( + isBookmarked = isBookmarked, + timetableItem = timetableItem, + onBookmarkClick = onBookmarkClick, + tags = { + TimetableItemTag( + tagText = timetableItem.room.name.currentLangTitle, + icon = timetableItem.room.icon, + tagColor = LocalRoomTheme.current.primaryColor, + modifier = Modifier.background(LocalRoomTheme.current.containerColor), + ) + Spacer(modifier = Modifier.padding(3.dp)) + timetableItem.language.labels.forEach { label -> + TimetableItemTag( + tagText = label, + tagColor = MaterialTheme.colorScheme.onSurfaceVariant + ) + Spacer(modifier = Modifier.padding(3.dp)) + } + Spacer(modifier = Modifier.weight(1f)) + }, + onTimetableItemClick = onTimetableItemClick, + ) } - Spacer(modifier = Modifier.weight(1f)) - }, - onTimetableItemClick = onTimetableItemClick, - ) + } + } } } }