Hello all, wondering if someone can help with a la...
# getting-started
b
Hello all, wondering if someone can help with a lazylist animation problem. I would like to animate (fade out) items in a list if they are deleted. Currently the list is queried from a database table. The query returns all items where visible = true. I am not seeing the item fade out, and wondering if the problem is that the attribute I am using doesn’t work as the entire list is changing, when I update the database to set an items visibility to false. Code in reply.
Copy code
@Composable
fun Items(
   viewModel: ItemsViewModel = hiltViewModel()
) {
   val myItems by viewModel.items.observeAsState(emptyList())

   Surface(Modifier.fillMaxSize()) {
      LazyColumn {
         items(
            count = myItems.count()
         ) { index ->
            val item = myItems[index]
            AnimatedVisibility(
               visible = item.visible,
               exit = fadeOut(
                  animationSpec = TweenSpec(20000, 0, FastOutLinearInEasing)
               )
            ) {
               ItemContent(...)
            }
         }
      }
   }
}
Currently when an item is removed from the list the database is updated to set the items visibility to false. So the viewModel.items list is changed to no longer contain the item. Is this why I am not seeing the item fade animation?
e