Refactor preferences to avoid a global state when it's not necessary
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package it.vfsfitvnm.vimusic.ui.styling
|
||||
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
|
||||
data class Appearance(
|
||||
val colorPalette: ColorPalette,
|
||||
val typography: Typography,
|
||||
val thumbnailShape: Shape
|
||||
)
|
||||
|
||||
val LocalAppearance = staticCompositionLocalOf<Appearance> { TODO() }
|
||||
@@ -82,5 +82,3 @@ val LightColorPalette = ColorPalette(
|
||||
// iconOnPrimaryContainer = Color(0xff2e30b8),
|
||||
isDark = false
|
||||
)
|
||||
|
||||
val LocalColorPalette = staticCompositionLocalOf { LightColorPalette }
|
||||
|
||||
@@ -23,53 +23,3 @@ data class Typography(
|
||||
val m: TextStyle,
|
||||
val l: TextStyle,
|
||||
)
|
||||
|
||||
val LocalTypography = staticCompositionLocalOf<Typography> { TODO() }
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@OptIn(ExperimentalTextApi::class)
|
||||
@Composable
|
||||
fun rememberTypography(color: Color): Typography {
|
||||
return remember(color) {
|
||||
TextStyle(
|
||||
fontFamily = FontFamily(
|
||||
Font(
|
||||
resId = R.font.poppins_w300,
|
||||
weight = FontWeight.Light
|
||||
),
|
||||
Font(
|
||||
resId = R.font.poppins_w400,
|
||||
weight = FontWeight.Normal
|
||||
),
|
||||
Font(
|
||||
resId = R.font.poppins_w400_italic,
|
||||
weight = FontWeight.Normal,
|
||||
style = FontStyle.Italic
|
||||
),
|
||||
Font(
|
||||
resId = R.font.poppins_w500,
|
||||
weight = FontWeight.Medium
|
||||
),
|
||||
Font(
|
||||
resId = R.font.poppins_w600,
|
||||
weight = FontWeight.SemiBold
|
||||
),
|
||||
Font(
|
||||
resId = R.font.poppins_w700,
|
||||
weight = FontWeight.Bold
|
||||
),
|
||||
),
|
||||
fontWeight = FontWeight.Normal,
|
||||
color = color,
|
||||
platformStyle = PlatformTextStyle(includeFontPadding = false)
|
||||
).run {
|
||||
Typography(
|
||||
xxs = copy(fontSize = 12.sp),
|
||||
xs = copy(fontSize = 14.sp),
|
||||
s = copy(fontSize = 16.sp),
|
||||
m = copy(fontSize = 18.sp),
|
||||
l = copy(fontSize = 20.sp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user