strange AnimatedVisibility issue in 1.7.15-beta
v1.7.15-beta seems to have caused regression for me.
App i'm working on need to hide TopAppBar when navigating to some specific destinations, before bumping to version 1.7.15-beta everything was working fine but after 1.7.15-beta expandVertically animation doesn't seem to work anymore in following code.
I doubled checked by downgrading to 1.6.14-beta and it starts to work again, v1.7.15-beta seems to break this somehow :)
AnimatedVisibility(
visible = visibilityState,
enter = expandVertically(animationSpec = tween(durationMillis = 100)),
exit = shrinkVertically(animationSpec = tween(durationMillis = 200)),
modifier = Modifier.onSizeChanged {
Log.d("AnimatedVisibility - onSizeChanged $it")
}
) {
TopAppBar(......)
}
on v1.6.14-beta when topAppBar is shown: AnimatedVisibility - onSizeChanged 1080 x 259
on v1.7.15-beta when topAppBar is shown : AnimatedVisibility - onSizeChanged 1080 x 0
other: compose.ui : 1.3.0-alpha02 compose.compiler: 1.3.0-rc01 kotlin 1.7.10
This doesn’t seem like a regression on compose destinations. It seems originates from some dependency 🤔
I’ll keep it open until I find something more about it.
No News, although I would appreciate it if someone could test this scenario with official compose navigation (I really think same issue would happen there)
@miduch can you please retry this with 1.7.21-beta? I've updated navigation and accompanist versions.
@raamcosta just tried and i'm afraid it still happens with 1.7.21-beta
As a workaround i've been using EnterTransition.None/ExitTransition.None
AnimatedVisibility(
visible = visibilityState,
enter = EnterTransition.None, // expandVertically(animationSpec = tween(durationMillis = 100)),
exit = ExitTransition.None, // shrinkVertically(animationSpec = tween(durationMillis = 200, delayMillis = 250)),
) {
TopAppBar(
More info
with following, TopAppBar reappears but tabs which i had on this screen wouldn't come back
AnimatedVisibility(
visible = visibilityState,
) {
TopAppBar(
Another attempt i did is with fadeIn/fadeOut only, with this it seems to work but looks uglier than EnterTransition.None/ExitTransition.None
AnimatedVisibility(
visible = visibilityState,
enter = fadeIn(),
exit = fadeOut(),
) {
TopAppBar(
in summary something changed after v1.6.14-beta which causes size related animations issues.
I investigate, and it seems that it's a bug introduce in Android Compose 1.3.
It appears when using AnimatedVisibility in the topBar or bottomBar of a Scaffold. I reproduce the strange behavior in a simple project, without any third dependencies.
var show by remember { mutableStateOf(true) }
Scaffold(
topBar = {
//! Strange behavior here
AnimatedVisibility(visible = show) {
TopAppBar(title = { Text("Title") })
}
},
bottomBar = {
//! Strange behavior here
AnimatedVisibility(visible = show) {
BottomAppBar {
Text("Bottom")
}
}
},
) { paddingValues ->
// content
}
You can find the project reproducing the bug here, with videos that demonstrate the animation glitch. https://github.com/EBfVince/AnimatedVisibilityBug
I reported the bug to Google here : https://issuetracker.google.com/u/1/issues/247605039
In the meantime, you can stick with Android Compose 1.2. It works as expected.
Great! Thank you @EBfVince 🙏
tried this with compose-destinations 1.7.22-beta and compose 1.3.0-rc01, works fine now. Closing issue