Fix banners-related issues (#9143)

This is most likely Compose issue so these changes will
be reevaluated when new Compose ver is out.
This commit is contained in:
Ivan Iskandar
2023-02-26 02:44:35 +07:00
committed by GitHub
parent 79662a5866
commit 63048d2f0b
4 changed files with 29 additions and 26 deletions

View File

@@ -69,7 +69,8 @@ fun AppStateBanners(
val mainInsets = WindowInsets.statusBars
val mainInsetsTop = mainInsets.getTop(density)
SubcomposeLayout(modifier = modifier) { constraints ->
val indexingPlaceable = subcompose(0) {
val indexingId = if (indexing) 0 else -1
val indexingPlaceable = subcompose(indexingId) {
AnimatedVisibility(
visible = indexing,
enter = expandVertically(),
@@ -82,7 +83,8 @@ fun AppStateBanners(
}.fastMap { it.measure(constraints) }
val indexingHeight = indexingPlaceable.fastMaxBy { it.height }?.height ?: 0
val downloadedOnlyPlaceable = subcompose(1) {
val downloadedId = if (indexing) 1 else 0
val downloadedOnlyPlaceable = subcompose(downloadedId) {
AnimatedVisibility(
visible = downloadedOnlyMode,
enter = expandVertically(),
@@ -96,7 +98,12 @@ fun AppStateBanners(
}.fastMap { it.measure(constraints) }
val downloadedOnlyHeight = downloadedOnlyPlaceable.fastMaxBy { it.height }?.height ?: 0
val incognitoPlaceable = subcompose(2) {
val incognitoId = when {
indexing && downloadedOnlyMode -> 3
indexing || downloadedOnlyMode -> 2
else -> 1
}
val incognitoPlaceable = subcompose(incognitoId) {
AnimatedVisibility(
visible = incognitoMode,
enter = expandVertically(),