Skip to content

Commit

Permalink
Remove pastelize
Browse files Browse the repository at this point in the history
  • Loading branch information
imashnake0 committed Dec 28, 2024
1 parent 8f958e2 commit c6f3eb4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 104 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import com.imashnake.animite.core.Constants.PASTELIZE_RATIO
import com.imashnake.animite.dev.ext.pastelize
import com.materialkolor.PaletteStyle
import com.materialkolor.rememberDynamicColorScheme

/**
Expand All @@ -22,9 +21,11 @@ fun rememberColorSchemeFor(
color: Int?,
fallbackColorScheme: ColorScheme = MaterialTheme.colorScheme,
isDark: Boolean = isSystemInDarkTheme()
): ColorScheme {
return color?.let {
rememberDynamicColorScheme(Color(it), isDark = isDark, isAmoled = false)
.pastelize(PASTELIZE_RATIO)
} ?: fallbackColorScheme
}
) = color?.let {
rememberDynamicColorScheme(
seedColor = Color(it),
isDark = isDark,
isAmoled = false,
style = PaletteStyle.Vibrant,
)
} ?: fallbackColorScheme
68 changes: 0 additions & 68 deletions app/src/main/kotlin/com/imashnake/animite/features/theme/Color.kt

This file was deleted.

31 changes: 18 additions & 13 deletions app/src/main/kotlin/com/imashnake/animite/features/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,52 @@ import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import com.imashnake.animite.core.Constants.PASTELIZE_RATIO
import com.imashnake.animite.core.ui.LocalPaddings
import com.imashnake.animite.core.ui.Paddings
import com.imashnake.animite.core.ui.rememberDefaultPaddings
import com.imashnake.animite.dev.ext.pastelize
import com.materialkolor.PaletteStyle
import com.materialkolor.rememberDynamicColorScheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AnimiteTheme(
paddings: Paddings = rememberDefaultPaddings(),
content: @Composable () -> Unit
content: @Composable () -> Unit,
) {
val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
val darkTheme = isSystemInDarkTheme()
val useDarkTheme = isSystemInDarkTheme()
val animiteColorScheme = when {
dynamicColor && darkTheme -> dynamicDarkColorScheme(LocalContext.current)
dynamicColor && !darkTheme -> dynamicLightColorScheme(LocalContext.current)
.pastelize(PASTELIZE_RATIO)
darkTheme -> KimiNoDarkColorScheme
else -> KimiNoLightColorScheme
.pastelize(PASTELIZE_RATIO)
dynamicColor && useDarkTheme -> dynamicDarkColorScheme(LocalContext.current)
dynamicColor && !useDarkTheme -> dynamicLightColorScheme(LocalContext.current)
else -> rememberDynamicColorScheme(
seedColor = Color(0xFF2D7AB0),
secondary = Color(0xFF687797),
isDark = useDarkTheme,
isAmoled = false,
style = PaletteStyle.Vibrant,
)
}

val animiteRippleTheme = RippleConfiguration(
color = MaterialTheme.colorScheme.primary,
rippleAlpha = RippleAlpha(
draggedAlpha = 0.16f,
focusedAlpha = 0.12f,
hoveredAlpha = 0.08f,
pressedAlpha = 0.12f
pressedAlpha = 0.12f,
)
)

MaterialTheme(
colorScheme = animiteColorScheme,
typography = AnimiteTypography
typography = AnimiteTypography,
) {
CompositionLocalProvider(
LocalRippleConfiguration provides animiteRippleTheme,
LocalPaddings provides paddings,
content = content
content = content,
)
}
}
2 changes: 0 additions & 2 deletions core/src/main/kotlin/com/imashnake/animite/core/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ object Constants {
const val ANILIST_BASE_URL = "https://graphql.anilist.co/"
const val CROSSFADE_DURATION = 500
const val MEDIA_TYPE = "mediaType"

const val PASTELIZE_RATIO = 0.05f
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -104,12 +103,9 @@ fun MediaSmall(
label: String? = null,
) {
Card(
modifier = modifier.width(cardWidth),
onClick = onClick,
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.3f)
),
shape = RoundedCornerShape(dimensionResource(R.dimen.media_card_corner_radius))
shape = RoundedCornerShape(dimensionResource(R.dimen.media_card_corner_radius)),
modifier = modifier.width(cardWidth),
) {
AsyncImage(
model = crossfadeModel(image),
Expand Down

0 comments on commit c6f3eb4

Please sign in to comment.