From c0f94ae8afaacd218f05e72d1d30c9d15f1eb09e Mon Sep 17 00:00:00 2001 From: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> Date: Fri, 10 Mar 2023 10:10:49 +0700 Subject: [PATCH] Revert "Fix banners-related issues" (#9186) Revert "Fix banners-related issues (#9143)" This reverts commit 63048d2f0b57477aecb4fd91f1f8c20a66ec9e18. --- .../kanade/presentation/components/Banners.kt | 13 ++------- .../eu/kanade/presentation/util/Navigator.kt | 4 +-- .../eu/kanade/tachiyomi/ui/home/HomeScreen.kt | 28 +++++++++++-------- .../kanade/tachiyomi/ui/main/MainActivity.kt | 10 ++++--- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/components/Banners.kt b/app/src/main/java/eu/kanade/presentation/components/Banners.kt index 5f288d7e27..14525e137b 100644 --- a/app/src/main/java/eu/kanade/presentation/components/Banners.kt +++ b/app/src/main/java/eu/kanade/presentation/components/Banners.kt @@ -69,8 +69,7 @@ fun AppStateBanners( val mainInsets = WindowInsets.statusBars val mainInsetsTop = mainInsets.getTop(density) SubcomposeLayout(modifier = modifier) { constraints -> - val indexingId = if (indexing) 0 else -1 - val indexingPlaceable = subcompose(indexingId) { + val indexingPlaceable = subcompose(0) { AnimatedVisibility( visible = indexing, enter = expandVertically(), @@ -83,8 +82,7 @@ fun AppStateBanners( }.fastMap { it.measure(constraints) } val indexingHeight = indexingPlaceable.fastMaxBy { it.height }?.height ?: 0 - val downloadedId = if (indexing) 1 else 0 - val downloadedOnlyPlaceable = subcompose(downloadedId) { + val downloadedOnlyPlaceable = subcompose(1) { AnimatedVisibility( visible = downloadedOnlyMode, enter = expandVertically(), @@ -98,12 +96,7 @@ fun AppStateBanners( }.fastMap { it.measure(constraints) } val downloadedOnlyHeight = downloadedOnlyPlaceable.fastMaxBy { it.height }?.height ?: 0 - val incognitoId = when { - indexing && downloadedOnlyMode -> 3 - indexing || downloadedOnlyMode -> 2 - else -> 1 - } - val incognitoPlaceable = subcompose(incognitoId) { + val incognitoPlaceable = subcompose(2) { AnimatedVisibility( visible = incognitoMode, enter = expandVertically(), diff --git a/app/src/main/java/eu/kanade/presentation/util/Navigator.kt b/app/src/main/java/eu/kanade/presentation/util/Navigator.kt index eab459b14f..fe89516d64 100644 --- a/app/src/main/java/eu/kanade/presentation/util/Navigator.kt +++ b/app/src/main/java/eu/kanade/presentation/util/Navigator.kt @@ -3,7 +3,6 @@ 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 @@ -34,7 +33,7 @@ interface AssistContentScreen { } @Composable -fun DefaultNavigatorScreenTransition(navigator: Navigator, modifier: Modifier = Modifier) { +fun DefaultNavigatorScreenTransition(navigator: Navigator) { val slideDistance = rememberSlideDistance() ScreenTransition( navigator = navigator, @@ -44,6 +43,5 @@ fun DefaultNavigatorScreenTransition(navigator: Navigator, modifier: Modifier = slideDistance = slideDistance, ) }, - modifier = modifier, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt index 981b3a8bad..e75375b5d1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/home/HomeScreen.kt @@ -6,6 +6,7 @@ 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 @@ -112,21 +113,24 @@ object HomeScreen : Screen() { }, contentWindowInsets = WindowInsets(0), ) { contentPadding -> - AnimatedContent( + Box( modifier = Modifier .padding(contentPadding) .consumeWindowInsets(contentPadding), - targetState = tabNavigator.current, - transitionSpec = { - materialFadeThroughIn(initialScale = 1f, durationMillis = TabFadeDuration) with - materialFadeThroughOut(durationMillis = TabFadeDuration) - }, - content = { - tabNavigator.saveableState(key = "currentTab", it) { - it.Content() - } - }, - ) + ) { + AnimatedContent( + targetState = tabNavigator.current, + transitionSpec = { + materialFadeThroughIn(initialScale = 1f, durationMillis = TabFadeDuration) with + materialFadeThroughOut(durationMillis = TabFadeDuration) + }, + content = { + tabNavigator.saveableState(key = "currentTab", it) { + it.Content() + } + }, + ) + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 6deefde84a..089e50b823 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -13,6 +13,7 @@ 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 @@ -221,14 +222,15 @@ class MainActivity : BaseActivity() { }, contentWindowInsets = scaffoldInsets, ) { contentPadding -> - // Shows current screen // Consume insets already used by app state banners - DefaultNavigatorScreenTransition( - navigator = navigator, + Box( modifier = Modifier .padding(contentPadding) .consumeWindowInsets(contentPadding), - ) + ) { + // Shows current screen + DefaultNavigatorScreenTransition(navigator = navigator) + } } // Pop source-related screens when incognito mode is turned off