@@ -23,6 +23,7 @@ import androidx.compose.foundation.layout.wrapContentWidth
23
23
import androidx.compose.foundation.lazy.LazyColumn
24
24
import androidx.compose.foundation.lazy.LazyRow
25
25
import androidx.compose.foundation.pager.HorizontalPager
26
+ import androidx.compose.foundation.pager.PagerState
26
27
import androidx.compose.foundation.pager.rememberPagerState
27
28
import androidx.compose.foundation.shape.CircleShape
28
29
import androidx.compose.material.icons.Icons
@@ -122,7 +123,9 @@ fun MemoryManagerComposable() {
122
123
.alpha(contentAlpha)
123
124
) {
124
125
CarouselLayout (
125
- items = listOf (storageInfo , ramInfo) , peekPreviewWidth = 24 .dp
126
+ items = listOf (storageInfo, ramInfo),
127
+ peekPreviewWidth = 24 .dp,
128
+ pagerState = pagerState
126
129
) { item ->
127
130
when (item) {
128
131
is StorageInfo -> StorageInfoCard (item)
@@ -177,10 +180,11 @@ fun MemoryManagerComposable() {
177
180
@OptIn(ExperimentalFoundationApi ::class )
178
181
@Composable
179
182
fun <T > CarouselLayout (
180
- items : List <T > , peekPreviewWidth : Dp , itemContent : @Composable (item : T ) -> Unit
183
+ items : List <T >,
184
+ peekPreviewWidth : Dp ,
185
+ pagerState : PagerState ,
186
+ itemContent : @Composable (item: T ) -> Unit
181
187
) {
182
- val pagerState = rememberPagerState(pageCount = { items.size })
183
-
184
188
HorizontalPager (
185
189
state = pagerState ,
186
190
modifier = Modifier .fillMaxWidth() ,
0 commit comments