Skip to content

Commit

Permalink
fix some visual bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed May 6, 2024
1 parent 96d35e8 commit 9a478a6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 46 deletions.
15 changes: 6 additions & 9 deletions composeApp/src/commonMain/kotlin/dev/datlag/aniflow/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T, R> StateFlow<T>.mapCollect(transform: (value: T) -> R): State<R> {
return remember(this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fun HomeScreen(component: HomeComponent) {
},
bottomBar = {
HidingNavigationBar(
visible = listState.isScrollingUp()
visible = listState.isScrollingUp() && listState.canScrollForward
)
}
) {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -193,7 +190,7 @@ class MediumScreenComponent(
CompositionLocalProvider(
LocalHaze provides state
) {
onRenderApplyCommonScheme(initialMedium.id) {
onRenderWithScheme(initialMedium.id) {
MediumScreen(this)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import kotlin.coroutines.CoroutineContext
data object SchemeTheme {

internal val executor = Executor()
internal val commonSchemeKey = MutableStateFlow<Any?>(null)
private val kache = InMemoryKache<Any, DominantColorState<Painter>>(
maxSize = 25L * 1024 * 1024
) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9a478a6

Please sign in to comment.