diff --git a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/MainScreen.kt b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/MainScreen.kt index 0548506..6ca0b4e 100644 --- a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/MainScreen.kt +++ b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/MainScreen.kt @@ -1,10 +1,12 @@ package mikufan.cx.songfinder.ui.component import androidx.compose.desktop.ui.tooling.preview.Preview +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.material3.Divider import androidx.compose.runtime.Composable import androidx.compose.runtime.State import androidx.compose.runtime.mutableStateOf +import androidx.compose.ui.Modifier import mikufan.cx.songfinder.backend.controller.MainScreenController import mikufan.cx.songfinder.backend.db.entity.PvService import mikufan.cx.songfinder.backend.db.entity.PvType @@ -41,6 +43,7 @@ fun RestOfPart(isAllFinished: Boolean) = if (isAllFinished) { } +@OptIn(ExperimentalFoundationApi::class) @Preview @Composable fun PreviewMainScreen() { @@ -73,7 +76,9 @@ fun PreviewMainScreen() { ) ) ) - ) + ) { + DebugUsedCell(it, Modifier.animateItemPlacement()) + } } } } \ No newline at end of file diff --git a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/mainpage/ResultGridCell.kt b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/mainpage/ResultGridCell.kt index 6f30c07..c181a75 100644 --- a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/mainpage/ResultGridCell.kt +++ b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/mainpage/ResultGridCell.kt @@ -14,6 +14,6 @@ fun LazyGridItemScope.ResultGridCell(result: SongSearchResult) { } @Composable -private fun DebugUsedCell(result: SongSearchResult, modifier: Modifier = Modifier) { +fun DebugUsedCell(result: SongSearchResult, modifier: Modifier = Modifier) { Text(result.toString(), modifier = modifier) } \ No newline at end of file diff --git a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/mainpage/ResultPanel.kt b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/mainpage/ResultPanel.kt index 9b291fe..8100875 100644 --- a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/mainpage/ResultPanel.kt +++ b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/mainpage/ResultPanel.kt @@ -24,7 +24,9 @@ import mikufan.cx.songfinder.ui.theme.spacing fun ResultPanel() { val controller = getSpringBean() val resultList = controller.currentResultState - RealResultPanel(resultList) + RealResultPanel(resultList) { result -> + ResultGridCell(result) + } } /** @@ -34,15 +36,17 @@ fun ResultPanel() { * @param modifier The modifier to be applied to the panel. */ @Composable -fun RealResultPanel(resultList: List, modifier: Modifier = Modifier) { +fun RealResultPanel( + resultList: List, + modifier: Modifier = Modifier, + cellContent: @Composable LazyGridItemScope.(SongSearchResult) -> Unit, +) { if (resultList.isEmpty()) { RowCentralizedWithSpacing(furtherModifier = modifier) { Text("No result found", style = MaterialTheme.typography.titleMedium) } } else { - ResultPanelGrid(resultList, modifier) { result -> - ResultGridCell(result) - } + ResultPanelGrid(resultList, modifier, cellContent) } }