135 lines
4.8 KiB
Kotlin
135 lines
4.8 KiB
Kotlin
package com.anthonyla.livewallpaper.themes
|
|
|
|
import android.os.Build
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.Typography
|
|
import androidx.compose.material3.lightColorScheme
|
|
import androidx.compose.material3.darkColorScheme
|
|
import androidx.compose.material3.dynamicDarkColorScheme
|
|
import androidx.compose.material3.dynamicLightColorScheme
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import androidx.compose.ui.text.TextStyle
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
|
private val LightColors = lightColorScheme(
|
|
primary = md_theme_light_primary,
|
|
onPrimary = md_theme_light_onPrimary,
|
|
primaryContainer = md_theme_light_primaryContainer,
|
|
onPrimaryContainer = md_theme_light_onPrimaryContainer,
|
|
secondary = md_theme_light_secondary,
|
|
onSecondary = md_theme_light_onSecondary,
|
|
secondaryContainer = md_theme_light_secondaryContainer,
|
|
onSecondaryContainer = md_theme_light_onSecondaryContainer,
|
|
tertiary = md_theme_light_tertiary,
|
|
onTertiary = md_theme_light_onTertiary,
|
|
tertiaryContainer = md_theme_light_tertiaryContainer,
|
|
onTertiaryContainer = md_theme_light_onTertiaryContainer,
|
|
error = md_theme_light_error,
|
|
errorContainer = md_theme_light_errorContainer,
|
|
onError = md_theme_light_onError,
|
|
onErrorContainer = md_theme_light_onErrorContainer,
|
|
background = md_theme_light_background,
|
|
onBackground = md_theme_light_onBackground,
|
|
surface = md_theme_light_surface,
|
|
onSurface = md_theme_light_onSurface,
|
|
surfaceVariant = md_theme_light_surfaceVariant,
|
|
onSurfaceVariant = md_theme_light_onSurfaceVariant,
|
|
outline = md_theme_light_outline,
|
|
inverseOnSurface = md_theme_light_inverseOnSurface,
|
|
inverseSurface = md_theme_light_inverseSurface,
|
|
inversePrimary = md_theme_light_inversePrimary,
|
|
surfaceTint = md_theme_light_surfaceTint,
|
|
outlineVariant = md_theme_light_outlineVariant,
|
|
scrim = md_theme_light_scrim,
|
|
)
|
|
|
|
|
|
private val DarkColors = darkColorScheme(
|
|
primary = md_theme_dark_primary,
|
|
onPrimary = md_theme_dark_onPrimary,
|
|
primaryContainer = md_theme_dark_primaryContainer,
|
|
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
|
|
secondary = md_theme_dark_secondary,
|
|
onSecondary = md_theme_dark_onSecondary,
|
|
secondaryContainer = md_theme_dark_secondaryContainer,
|
|
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
|
|
tertiary = md_theme_dark_tertiary,
|
|
onTertiary = md_theme_dark_onTertiary,
|
|
tertiaryContainer = md_theme_dark_tertiaryContainer,
|
|
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
|
|
error = md_theme_dark_error,
|
|
errorContainer = md_theme_dark_errorContainer,
|
|
onError = md_theme_dark_onError,
|
|
onErrorContainer = md_theme_dark_onErrorContainer,
|
|
background = md_theme_dark_background,
|
|
onBackground = md_theme_dark_onBackground,
|
|
surface = md_theme_dark_surface,
|
|
onSurface = md_theme_dark_onSurface,
|
|
surfaceVariant = md_theme_dark_surfaceVariant,
|
|
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
|
|
outline = md_theme_dark_outline,
|
|
inverseOnSurface = md_theme_dark_inverseOnSurface,
|
|
inverseSurface = md_theme_dark_inverseSurface,
|
|
inversePrimary = md_theme_dark_inversePrimary,
|
|
surfaceTint = md_theme_dark_surfaceTint,
|
|
outlineVariant = md_theme_dark_outlineVariant,
|
|
scrim = md_theme_dark_scrim,
|
|
)
|
|
|
|
val typography = Typography(
|
|
headlineSmall = TextStyle(
|
|
fontWeight = FontWeight.SemiBold,
|
|
fontSize = 24.sp,
|
|
lineHeight = 32.sp,
|
|
letterSpacing = 0.sp
|
|
),
|
|
titleLarge = TextStyle(
|
|
fontWeight = FontWeight.Normal,
|
|
fontSize = 18.sp,
|
|
lineHeight = 28.sp,
|
|
letterSpacing = 0.sp
|
|
),
|
|
bodyLarge = TextStyle(
|
|
fontWeight = FontWeight.Normal,
|
|
fontSize = 16.sp,
|
|
lineHeight = 24.sp,
|
|
letterSpacing = 0.15.sp
|
|
),
|
|
bodyMedium = TextStyle(
|
|
fontWeight = FontWeight.Medium,
|
|
fontSize = 14.sp,
|
|
lineHeight = 20.sp,
|
|
letterSpacing = 0.25.sp
|
|
),
|
|
labelMedium = TextStyle(
|
|
fontWeight = FontWeight.SemiBold,
|
|
fontSize = 12.sp,
|
|
lineHeight = 16.sp,
|
|
letterSpacing = 0.5.sp
|
|
)
|
|
)
|
|
|
|
|
|
@Composable
|
|
fun LiveWallpaperTheme(
|
|
useDarkTheme: Boolean,
|
|
useDynamicTheme: Boolean,
|
|
content: @Composable () -> Unit
|
|
) { // Check if dynamic theming is enabled in settings
|
|
val context = LocalContext.current
|
|
val colors = when {((Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)) && useDynamicTheme -> {
|
|
if (useDarkTheme) dynamicDarkColorScheme(context)
|
|
else dynamicLightColorScheme(context)
|
|
}
|
|
useDarkTheme -> DarkColors
|
|
else -> LightColors
|
|
}
|
|
MaterialTheme(
|
|
colorScheme = colors,
|
|
typography = typography,
|
|
content = content
|
|
)
|
|
} |