Animate room list filters when clearing

They animate cleanly back to their original locations now, and correctly
overlap each other when doing so. The only thing that is mildly jarring
is the reappearing chips, but there's no way to animate appearance in
the current version of jetpack compose, so that'll have to be fixed
later.

Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
Joe Groocock 2024-05-21 22:17:18 +00:00
parent 7aa9d856b8
commit b852578ffc
No known key found for this signature in database
GPG key ID: A5571FCDC53ADDE6

View file

@ -34,7 +34,6 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.FilterChip
import androidx.compose.material3.FilterChipDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
@ -106,13 +105,6 @@ fun RoomListFiltersView(
}
}
}
LaunchedEffect(state.filterSelectionStates) {
// Checking for canScrollBackward is necessary for the itemPlacementAnimation to work correctly.
// We don't want the itemPlacementAnimation to be triggered when clearing the filters.
if (!state.hasAnyFilterSelected || lazyListState.canScrollBackward) {
lazyListState.animateScrollToItem(0)
}
}
}
@Composable