From cacb0d8cee4ea86e83cfb79c96da9fd180b00782 Mon Sep 17 00:00:00 2001 From: hpp2334 Date: Mon, 2 Dec 2024 20:58:26 +0800 Subject: [PATCH] perf: PlaylistPage use LazyColumn to wrap music item --- .../widgets/playlists/PlaylistPage.kt | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/android/app/src/main/java/com/kutedev/easemusicplayer/widgets/playlists/PlaylistPage.kt b/android/app/src/main/java/com/kutedev/easemusicplayer/widgets/playlists/PlaylistPage.kt index 8efba03..de1eb80 100644 --- a/android/app/src/main/java/com/kutedev/easemusicplayer/widgets/playlists/PlaylistPage.kt +++ b/android/app/src/main/java/com/kutedev/easemusicplayer/widgets/playlists/PlaylistPage.kt @@ -28,6 +28,8 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll @@ -400,13 +402,16 @@ private fun PlaylistItemsBlock( mutableStateOf(null) } - Column( + LazyColumn( modifier = Modifier .fillMaxSize() - .verticalScroll(rememberScrollState()) + .padding(0.dp) ) { - Box(modifier = Modifier.height(48.dp)) - for (item in items) { + item { + Box(modifier = Modifier.height(48.dp)) + } + items(items) { + val item = it; val playing = item.id == currentMusicState.id key(item.id) { @@ -424,10 +429,12 @@ private fun PlaylistItemsBlock( ) } } - BottomBarSpacer( - hasCurrentMusic = currentMusicState.id != null, - scaffoldPadding = scaffoldPadding, - ) + item { + BottomBarSpacer( + hasCurrentMusic = currentMusicState.id != null, + scaffoldPadding = scaffoldPadding, + ) + } } }