Colton Idle
01/18/2021, 10:34 PMLazyColumn{
items(movies){
MovieCard(it)
}
}
MovieCard(movie: Movie){
Text(movie.name)
LazyColumn{
items(movie.reviews){
ReviewItem(it)
}
}
}
You get an error like this
java.lang.IllegalStateException: Nesting scrollable in the same direction layouts like ScrollableContainer and LazyColumn is not allowed. If you want to add a header before the list of items please take a look on LazyColumn component which has a DSL api which allows to first add a header via item() function and then the list of items via items().
Problem is solved if the LazyColumn in MovieCard just become a Column and I iterate with a for loop. BUT I want that inner loop to be performant and handle being super long. So I don't want a "dumb" Column. I need something that will recycle those ReviewItems.jim
01/18/2021, 10:41 PMModifier.nestedScroll
Colton Idle
01/18/2021, 10:43 PMjim
01/18/2021, 10:44 PMColton Idle
01/18/2021, 10:47 PMKirill Grouchnikov
01/18/2021, 10:47 PMColton Idle
01/18/2021, 10:48 PMAndrey Kulikov
01/19/2021, 3:23 PMLazyColumn{
movies.forEach { movie ->
item {
Text(movie.name)
}
items(movie.reviews){
ReviewItem(it)
}
}
}
Colton Idle
01/19/2021, 4:04 PMLazyColumn{
items(movies){
MovieCard(it)
}
}
MovieCard(movie: Movie){
Text(movie.name)
LazyColumn{
items(movie.reviews){
ReviewItem(it)
}
}
}
Andrey Kulikov
01/20/2021, 6:14 PMitem { CardHeader() } items { … } item { CardFooter() }
so it visually looks like card, but it is not that easy with elevations. in you can’t split them then your whole card should be a one item with just Column instead of LazyColumn inside and you kinda loosing the laziness. note that in your example where you said that in Android you usually just wrap RecyclerView inside RecyclerView it was working in pretty much the same way: the inner RecyclerView was measured with the infinity constraints which means all the elements were created and added straightaway with loosing the whole recycling mechanism. the same issue is happening in Compose, but we decided to throw an exception when we detect such case so users are aware that they do something inefficientlyColton Idle
01/21/2021, 7:11 AMAndrey Kulikov
01/21/2021, 11:40 AMColton Idle
01/21/2021, 5:17 PMAndrey Kulikov
01/21/2021, 5:47 PMColton Idle
01/21/2021, 5:55 PMAndrey Kulikov
01/21/2021, 5:56 PMColton Idle
01/21/2021, 5:58 PMJohan Reitan
03/05/2021, 1:11 PM