Theme: fix themes for composables
This commit is contained in:
@@ -17,24 +17,33 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.colorResource
|
import androidx.compose.ui.res.colorResource
|
||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
|
import com.aurora.store.util.Preferences
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App theme for Aurora Store based on [MaterialTheme]
|
* App theme for Aurora Store based on [MaterialTheme]
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun AuroraTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
|
fun AuroraTheme(content: @Composable () -> Unit) {
|
||||||
val colorScheme = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
val context = LocalContext.current
|
||||||
if (darkTheme) {
|
val themeStyle = Preferences.getInteger(context, Preferences.PREFERENCE_THEME_STYLE)
|
||||||
dynamicDarkColorScheme(LocalContext.current)
|
val isDynamicColorSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||||
} else {
|
|
||||||
dynamicLightColorScheme(LocalContext.current)
|
val lightScheme = if (isDynamicColorSupported) {
|
||||||
}
|
dynamicLightColorScheme(context)
|
||||||
} else {
|
} else {
|
||||||
if (darkTheme) {
|
lightColorScheme(primary = colorResource(id = R.color.colorAccent))
|
||||||
darkColorScheme(primary = colorResource(id = R.color.colorAccent))
|
}
|
||||||
} else {
|
|
||||||
lightColorScheme(primary = colorResource(id = R.color.colorAccent))
|
val darkScheme = if (isDynamicColorSupported) {
|
||||||
}
|
dynamicDarkColorScheme(context)
|
||||||
|
} else {
|
||||||
|
darkColorScheme(primary = colorResource(id = R.color.colorAccent))
|
||||||
|
}
|
||||||
|
|
||||||
|
val colorScheme = when (themeStyle) {
|
||||||
|
1 -> lightScheme
|
||||||
|
2 -> darkScheme
|
||||||
|
else -> if (isSystemInDarkTheme()) darkScheme else lightScheme
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialTheme(colorScheme = colorScheme, typography = Typography(), content = content)
|
MaterialTheme(colorScheme = colorScheme, typography = Typography(), content = content)
|
||||||
|
|||||||
Reference in New Issue
Block a user