Zoltan Demant
11/06/2021, 10:21 AMZoltan Demant
11/06/2021, 10:24 AMfun removeFromWindow() {
manager.removeView(this)
}
e.g. Removing the view from the window should happen after the animation finishes. Similar but reverse story when adding the view.
My code thus far has a mutableState<Boolean> which indicates whether the view should be attached, but there are no start/end listeners so I dont know where to go from there.Csaba Kozák
11/06/2021, 10:51 AManimatable.animateTo(…)
then it will suspend until the animation is done. In the next line, you can set the state to remove the view.Zoltan Demant
11/06/2021, 11:00 AMvar wasVisible by remember {
mutableStateOf(false)
}
LaunchedEffect(visible) {
if (!wasVisible) {
// addToWindow
}
val animatable = Animatable(
initialValue = if (wasVisible) 1f else 0f
)
animatable.animateTo(
targetValue = if (visible) 1f else 0f
)
if (!visible) {
// removeFromWindow
}
wasVisible = visible
}
Csaba Kozák
11/06/2021, 11:08 AMZoltan Demant
11/06/2021, 11:20 AM