-
-
Save Ahmed-Sellami/ca0a06862290f8414a4002808badb168 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalAnimationApi | |
@Composable | |
fun Home() { | |
val slideStates = remember { | |
mutableStateMapOf<ShoesArticle, SlideState>() | |
.apply { | |
shoesArticles.map { shoesArticle -> | |
shoesArticle to SlideState.NONE | |
}.toMap().also { | |
putAll(it) | |
} | |
} | |
} | |
Scaffold(/* ... */) { innerPadding -> | |
ShoesList( | |
modifier = Modifier.padding(innerPadding), | |
shoesArticles = shoesArticles, | |
slideStates = slideStates | |
) | |
} | |
} | |
@ExperimentalAnimationApi | |
@Composable | |
fun ShoesList( | |
modifier: Modifier, | |
shoesArticles: MutableList<ShoesArticle>, | |
slideStates: Map<ShoesArticle, SlideState> | |
) { | |
val lazyListState = rememberLazyListState() | |
LazyColumn( | |
state = lazyListState, | |
modifier = modifier.padding(top = dimensionResource(id = R.dimen.list_top_padding)) | |
) { | |
items(shoesArticles.size) { index -> | |
val shoesArticle = shoesArticles.getOrNull(index) | |
if (shoesArticle != null) { | |
key(shoesArticle) { | |
val slideState = slideStates[shoesArticle] ?: SlideState.NONE | |
ShoesCard( | |
shoesArticle = shoesArticle, | |
slideState = slideState | |
) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment