Fix banners-related issues ()

This is most likely Compose issue so these changes will
be reevaluated when new Compose ver is out.

(cherry picked from commit 63048d2f0b57477aecb4fd91f1f8c20a66ec9e18)
This commit is contained in:
Ivan Iskandar 2023-02-26 02:44:35 +07:00 committed by Jobobby04
parent b842d48512
commit 87788a49d7
4 changed files with 29 additions and 26 deletions
app/src/main/java/eu/kanade
presentation
tachiyomi/ui

@ -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(),

@ -3,6 +3,7 @@ package eu.kanade.presentation.util
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.core.screen.ScreenKey
import cafe.adriel.voyager.core.screen.uniqueScreenKey
@ -38,7 +39,7 @@ interface AssistContentScreen {
}
@Composable
fun DefaultNavigatorScreenTransition(navigator: Navigator) {
fun DefaultNavigatorScreenTransition(navigator: Navigator, modifier: Modifier = Modifier) {
val slideDistance = rememberSlideDistance()
ScreenTransition(
navigator = navigator,
@ -48,5 +49,6 @@ fun DefaultNavigatorScreenTransition(navigator: Navigator) {
slideDistance = slideDistance,
)
},
modifier = modifier,
)
}

@ -6,7 +6,6 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.expandVertically
import androidx.compose.animation.shrinkVertically
import androidx.compose.animation.with
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.consumeWindowInsets
@ -131,12 +130,10 @@ object HomeScreen : Screen() {
},
contentWindowInsets = WindowInsets(0),
) { contentPadding ->
Box(
AnimatedContent(
modifier = Modifier
.padding(contentPadding)
.consumeWindowInsets(contentPadding),
) {
AnimatedContent(
targetState = tabNavigator.current,
transitionSpec = {
materialFadeThroughIn(initialScale = 1f, durationMillis = TabFadeDuration) with
@ -150,7 +147,6 @@ object HomeScreen : Screen() {
)
}
}
}
val goToLibraryTab = { tabNavigator.current = LibraryTab }
BackHandler(

@ -14,7 +14,6 @@ import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.consumeWindowInsets
@ -271,15 +270,14 @@ class MainActivity : BaseActivity() {
},
contentWindowInsets = scaffoldInsets,
) { contentPadding ->
// Shows current screen
// Consume insets already used by app state banners
Box(
DefaultNavigatorScreenTransition(
navigator = navigator,
modifier = Modifier
.padding(contentPadding)
.consumeWindowInsets(contentPadding),
) {
// Shows current screen
DefaultNavigatorScreenTransition(navigator = navigator)
}
)
}
// Pop source-related screens when incognito mode is turned off