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:
parent
79662a5866
commit
63048d2f0b
@ -69,7 +69,8 @@ fun AppStateBanners(
|
|||||||
val mainInsets = WindowInsets.statusBars
|
val mainInsets = WindowInsets.statusBars
|
||||||
val mainInsetsTop = mainInsets.getTop(density)
|
val mainInsetsTop = mainInsets.getTop(density)
|
||||||
SubcomposeLayout(modifier = modifier) { constraints ->
|
SubcomposeLayout(modifier = modifier) { constraints ->
|
||||||
val indexingPlaceable = subcompose(0) {
|
val indexingId = if (indexing) 0 else -1
|
||||||
|
val indexingPlaceable = subcompose(indexingId) {
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = indexing,
|
visible = indexing,
|
||||||
enter = expandVertically(),
|
enter = expandVertically(),
|
||||||
@ -82,7 +83,8 @@ fun AppStateBanners(
|
|||||||
}.fastMap { it.measure(constraints) }
|
}.fastMap { it.measure(constraints) }
|
||||||
val indexingHeight = indexingPlaceable.fastMaxBy { it.height }?.height ?: 0
|
val indexingHeight = indexingPlaceable.fastMaxBy { it.height }?.height ?: 0
|
||||||
|
|
||||||
val downloadedOnlyPlaceable = subcompose(1) {
|
val downloadedId = if (indexing) 1 else 0
|
||||||
|
val downloadedOnlyPlaceable = subcompose(downloadedId) {
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = downloadedOnlyMode,
|
visible = downloadedOnlyMode,
|
||||||
enter = expandVertically(),
|
enter = expandVertically(),
|
||||||
@ -96,7 +98,12 @@ fun AppStateBanners(
|
|||||||
}.fastMap { it.measure(constraints) }
|
}.fastMap { it.measure(constraints) }
|
||||||
val downloadedOnlyHeight = downloadedOnlyPlaceable.fastMaxBy { it.height }?.height ?: 0
|
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(
|
AnimatedVisibility(
|
||||||
visible = incognitoMode,
|
visible = incognitoMode,
|
||||||
enter = expandVertically(),
|
enter = expandVertically(),
|
||||||
|
@ -3,6 +3,7 @@ package eu.kanade.presentation.util
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.ProvidableCompositionLocal
|
import androidx.compose.runtime.ProvidableCompositionLocal
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
import cafe.adriel.voyager.core.screen.Screen
|
import cafe.adriel.voyager.core.screen.Screen
|
||||||
import cafe.adriel.voyager.core.screen.ScreenKey
|
import cafe.adriel.voyager.core.screen.ScreenKey
|
||||||
import cafe.adriel.voyager.core.screen.uniqueScreenKey
|
import cafe.adriel.voyager.core.screen.uniqueScreenKey
|
||||||
@ -33,7 +34,7 @@ interface AssistContentScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DefaultNavigatorScreenTransition(navigator: Navigator) {
|
fun DefaultNavigatorScreenTransition(navigator: Navigator, modifier: Modifier = Modifier) {
|
||||||
val slideDistance = rememberSlideDistance()
|
val slideDistance = rememberSlideDistance()
|
||||||
ScreenTransition(
|
ScreenTransition(
|
||||||
navigator = navigator,
|
navigator = navigator,
|
||||||
@ -43,5 +44,6 @@ fun DefaultNavigatorScreenTransition(navigator: Navigator) {
|
|||||||
slideDistance = slideDistance,
|
slideDistance = slideDistance,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import androidx.compose.animation.AnimatedVisibility
|
|||||||
import androidx.compose.animation.expandVertically
|
import androidx.compose.animation.expandVertically
|
||||||
import androidx.compose.animation.shrinkVertically
|
import androidx.compose.animation.shrinkVertically
|
||||||
import androidx.compose.animation.with
|
import androidx.compose.animation.with
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.RowScope
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||||
@ -113,24 +112,21 @@ object HomeScreen : Screen() {
|
|||||||
},
|
},
|
||||||
contentWindowInsets = WindowInsets(0),
|
contentWindowInsets = WindowInsets(0),
|
||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
Box(
|
AnimatedContent(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(contentPadding)
|
.padding(contentPadding)
|
||||||
.consumeWindowInsets(contentPadding),
|
.consumeWindowInsets(contentPadding),
|
||||||
) {
|
targetState = tabNavigator.current,
|
||||||
AnimatedContent(
|
transitionSpec = {
|
||||||
targetState = tabNavigator.current,
|
materialFadeThroughIn(initialScale = 1f, durationMillis = TabFadeDuration) with
|
||||||
transitionSpec = {
|
materialFadeThroughOut(durationMillis = TabFadeDuration)
|
||||||
materialFadeThroughIn(initialScale = 1f, durationMillis = TabFadeDuration) with
|
},
|
||||||
materialFadeThroughOut(durationMillis = TabFadeDuration)
|
content = {
|
||||||
},
|
tabNavigator.saveableState(key = "currentTab", it) {
|
||||||
content = {
|
it.Content()
|
||||||
tabNavigator.saveableState(key = "currentTab", it) {
|
}
|
||||||
it.Content()
|
},
|
||||||
}
|
)
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import android.widget.Toast
|
|||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.WindowInsetsSides
|
import androidx.compose.foundation.layout.WindowInsetsSides
|
||||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||||
@ -222,15 +221,14 @@ class MainActivity : BaseActivity() {
|
|||||||
},
|
},
|
||||||
contentWindowInsets = scaffoldInsets,
|
contentWindowInsets = scaffoldInsets,
|
||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
|
// Shows current screen
|
||||||
// Consume insets already used by app state banners
|
// Consume insets already used by app state banners
|
||||||
Box(
|
DefaultNavigatorScreenTransition(
|
||||||
|
navigator = navigator,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(contentPadding)
|
.padding(contentPadding)
|
||||||
.consumeWindowInsets(contentPadding),
|
.consumeWindowInsets(contentPadding),
|
||||||
) {
|
)
|
||||||
// Shows current screen
|
|
||||||
DefaultNavigatorScreenTransition(navigator = navigator)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pop source-related screens when incognito mode is turned off
|
// Pop source-related screens when incognito mode is turned off
|
||||||
|
Loading…
Reference in New Issue
Block a user