From 9a478a6520e841654866a5e4c32c3db3308a5404 Mon Sep 17 00:00:00 2001 From: DatLag Date: Mon, 6 May 2024 21:20:26 +0200 Subject: [PATCH] fix some visual bugs --- .../kotlin/dev/datlag/aniflow/App.kt | 15 ++++++--------- .../datlag/aniflow/common/ExtendComponent.kt | 12 ------------ .../ui/navigation/screen/home/HomeScreen.kt | 4 ++-- .../screen/medium/MediumScreenComponent.kt | 7 ++----- .../dev/datlag/aniflow/ui/theme/SchemeTheme.kt | 18 ------------------ 5 files changed, 10 insertions(+), 46 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/App.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/App.kt index da67b2e..942bcb6 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/App.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/App.kt @@ -20,7 +20,6 @@ import dev.datlag.aniflow.other.StateSaver import dev.datlag.aniflow.settings.Settings import dev.datlag.aniflow.settings.model.AppSettings import dev.datlag.aniflow.ui.theme.Colors -import dev.datlag.aniflow.ui.theme.CommonSchemeTheme import dev.datlag.aniflow.ui.theme.DynamicMaterialTheme import dev.datlag.tooling.compose.toTypography import dev.datlag.tooling.decompose.lifecycle.collectAsStateWithLifecycle @@ -62,14 +61,12 @@ internal fun App( seedColor = tempColor?.toComposeColor() ?: seedColor, animate = !allLoading ) { - CommonSchemeTheme(animate = !allLoading) { - Surface( - modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background, - contentColor = MaterialTheme.colorScheme.onBackground - ) { - content() - } + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background, + contentColor = MaterialTheme.colorScheme.onBackground + ) { + content() } } } diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendComponent.kt index 03cc05a..0cb01d9 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/common/ExtendComponent.kt @@ -41,18 +41,6 @@ fun Component.onRenderWithScheme(key: Any?, content: @Composable (SchemeTheme.Up } } -@Composable -fun Component.onRenderApplyCommonScheme(key: Any?, content: @Composable (SchemeTheme.Updater?) -> Unit) { - onRenderWithScheme(key, content) - - SchemeTheme.setCommon(key) - DisposableEffect(key) { - onDispose { - SchemeTheme.setCommon(null) - } - } -} - @Composable fun StateFlow.mapCollect(transform: (value: T) -> R): State { return remember(this) { diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreen.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreen.kt index d5402a7..d1ce91e 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreen.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/home/HomeScreen.kt @@ -64,7 +64,7 @@ fun HomeScreen(component: HomeComponent) { }, bottomBar = { HidingNavigationBar( - visible = listState.isScrollingUp() + visible = listState.isScrollingUp() && listState.canScrollForward ) } ) { @@ -85,7 +85,7 @@ fun HomeScreen(component: HomeComponent) { state = listState, modifier = Modifier.fillMaxSize().haze(state = LocalHaze.current), verticalArrangement = Arrangement.spacedBy(32.dp), - contentPadding = LocalPadding(top = 16.dp) + contentPadding = LocalPadding(vertical = 16.dp) ) { if (!isManga) { item { diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumScreenComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumScreenComponent.kt index 9e888c3..0ee9887 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumScreenComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumScreenComponent.kt @@ -16,10 +16,7 @@ import dev.datlag.aniflow.anilist.model.Medium import dev.datlag.aniflow.anilist.type.MediaFormat import dev.datlag.aniflow.anilist.type.MediaStatus import dev.datlag.aniflow.anilist.type.MediaType -import dev.datlag.aniflow.common.nullableFirebaseInstance -import dev.datlag.aniflow.common.onRenderApplyCommonScheme -import dev.datlag.aniflow.common.popular -import dev.datlag.aniflow.common.rated +import dev.datlag.aniflow.common.* import dev.datlag.aniflow.model.* import dev.datlag.aniflow.other.BurningSeriesResolver import dev.datlag.aniflow.other.Constants @@ -193,7 +190,7 @@ class MediumScreenComponent( CompositionLocalProvider( LocalHaze provides state ) { - onRenderApplyCommonScheme(initialMedium.id) { + onRenderWithScheme(initialMedium.id) { MediumScreen(this) } } diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/theme/SchemeTheme.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/theme/SchemeTheme.kt index 8d137a1..8620e55 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/theme/SchemeTheme.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/theme/SchemeTheme.kt @@ -30,7 +30,6 @@ import kotlin.coroutines.CoroutineContext data object SchemeTheme { internal val executor = Executor() - internal val commonSchemeKey = MutableStateFlow(null) private val kache = InMemoryKache>( maxSize = 25L * 1024 * 1024 ) { @@ -49,10 +48,6 @@ data object SchemeTheme { kache.getOrPut(key) { fallback } }.getOrNull() - fun setCommon(key: Any?) { - commonSchemeKey.update { key } - } - @Composable fun create(key: Any?): Updater? { if (key == null) { @@ -199,19 +194,6 @@ fun SchemeTheme( } } -@Composable -fun CommonSchemeTheme(animate: Boolean = false, content: @Composable (SchemeTheme.Updater?) -> Unit) { - val key by SchemeTheme.commonSchemeKey.collectAsStateWithLifecycle() - - SchemeTheme( - key = key, - animate = animate, - defaultColor = null, - defaultOnColor = null, - content = content - ) -} - private fun Color.contrastAgainst(background: Color): Float { val fg = if (alpha < 1f) compositeOver(background) else this