From 04ced5b0c6674eb64c2d1768d5637070ea0c8baa Mon Sep 17 00:00:00 2001 From: nani <87673002+nanihadesuka@users.noreply.github.com> Date: Sun, 11 Aug 2024 17:02:02 +0200 Subject: [PATCH] remember lists / app demo --- .../my/nanihadesuka/lazycolumnscrollbar/MainActivity.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/my/nanihadesuka/lazycolumnscrollbar/MainActivity.kt b/app/src/main/java/my/nanihadesuka/lazycolumnscrollbar/MainActivity.kt index 145dcdc..765e332 100644 --- a/app/src/main/java/my/nanihadesuka/lazycolumnscrollbar/MainActivity.kt +++ b/app/src/main/java/my/nanihadesuka/lazycolumnscrollbar/MainActivity.kt @@ -36,6 +36,7 @@ import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -105,7 +106,7 @@ fun MainView() { @OptIn(ExperimentalFoundationApi::class) @Composable fun LazyColumnView() { - val listData = (0..100).toList() + val listData = remember { (0..100).toList() } val listState = rememberLazyListState() Box( @@ -160,7 +161,7 @@ fun LazyColumnView() { @OptIn(ExperimentalFoundationApi::class) @Composable fun LazyRowView() { - val listData = (0..100).toList() + val listData = remember { (0..100).toList() } val listState = rememberLazyListState() Box( @@ -314,7 +315,7 @@ fun LazyHorizontalGridView() { @Composable fun ColumnView() { - val listData = (0..18).toList() + val listData = remember { (0..18).toList() } val listState = rememberScrollState() val indicatorContent = @Composable { normalizedOffset: Float, isThumbSelected: Boolean -> Indicator( @@ -357,7 +358,7 @@ fun ColumnView() { @Composable fun RowView() { - val listData = (0..100).toList() + val listData = remember { (0..100).toList() } val listState = rememberScrollState() val indicatorContent = @Composable { normalizedOffset: Float, isThumbSelected: Boolean -> Indicator(