With Material3 when I dismiss a row in my list the...
# compose-android
j
With Material3 when I dismiss a row in my list the dismissed row doesn't disappear. I am not certain what is causing this.
The viewmodel really in this case just tells it how many items to put into the list. It serves no other purpose for this example. It starts with ExpenseListView, which is basically just a lazy column to show the data, and then the goal is just to swipe and have it disappear and have the line also disappear. I am using compose version 1.4.3 and material3 1.1.1
@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun SwipeToDismissListItems() {
val dismissState = rememberDismissState()
SwipeToDismiss(
state = dismissState,
background = *{*
val color by animateColorAsState(
when (dismissState.targetValue) {
DismissValue._Default_ -> MaterialTheme.colorScheme.tertiaryContainer
DismissValue._DismissedToEnd_ -> Color.Green
DismissValue._DismissedToStart_ -> Color.Red
}, label = "Dismiss 3"
)
Box(
Modifier
._fillMaxSize_()
._background_(color))
*}*,
dismissContent = *{*
Card *{*
ListItem(
headlineContent = *{*
Text("Cupcake")
*}*,
supportingContent = *{* Text("Swipe me left or right!") *}*
)
}
}
)
}
@Composable
fun ExpenseListView(viewModel: MainViewModel) {
val lazyListState = rememberLazyListState()
val expenseListState = viewModel.expenseListFlow.collectAsState()
LazyColumn(
modifier = Modifier._fillMaxHeight_(),
state = lazyListState,
userScrollEnabled = true
) *{*
_items_(items = expenseListState.value, itemContent = *{* item *->*
SwipeToDismissListItems()
*}*)
}
}
v
You probably need to remove the dismissed item from your LazyColumn after dismissing it? You don't seem to be doing that
☝️ 1
☝🏾 1
j
You are correct, my backing list is removing it, but the lazy column isn't responding. I think my experiment with material3 is a failure. There are too many issues to work through, as it worked fine with material. Time to go back.
🫤 1
e
Ignoring the defeatist attitude for a moment I realize this is probably just the last straw that broke the camels back but lazyList is not Material 3. I dont see any issue with Material 3 in this case. Compose is declarative, so whatever you see is driven from your data, if your view model is indeed removing the item, have you also checked that the screen is recomposed on such a change? Maybe post your VM code also…