Skip to content

Commit

Permalink
enable dynamic color
Browse files Browse the repository at this point in the history
  • Loading branch information
X1nto committed Dec 23, 2023
1 parent a960d7f commit a4dce4c
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions androidApp/src/main/java/dev/xinto/argos/ui/theme/ArgosTheme.kt
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
package dev.xinto.argos.ui.theme

import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Shapes
import androidx.compose.material3.Typography
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext

@Composable
fun ArgosTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colors = if (darkTheme) {
darkColorScheme(
primary = Color(0xFFBB86FC),
secondary = Color(0xFF03DAC5),
tertiary = Color(0xFF3700B3)
)
} else {
lightColorScheme(
primary = Color(0xFF6200EE),
secondary = Color(0xFF03DAC5),
tertiary = Color(0xFF3700B3)
)
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> darkColorScheme()
else -> lightColorScheme()
}
val typography = Typography()
val shapes = Shapes()

MaterialTheme(
colorScheme = colors,
typography = typography,
shapes = shapes,
colorScheme = colorScheme,
typography = Typography(),
shapes = Shapes(),
content = content
)
}

0 comments on commit a4dce4c

Please sign in to comment.