1
+ package com.farsitel.bazaar.bazaarupdaterSample.ui.theme
2
+
3
+ import android.app.Activity
4
+ import android.os.Build
5
+ import androidx.compose.foundation.isSystemInDarkTheme
6
+ import androidx.compose.material3.MaterialTheme
7
+ import androidx.compose.material3.darkColorScheme
8
+ import androidx.compose.material3.dynamicDarkColorScheme
9
+ import androidx.compose.material3.dynamicLightColorScheme
10
+ import androidx.compose.material3.lightColorScheme
11
+ import androidx.compose.runtime.Composable
12
+ import androidx.compose.ui.platform.LocalContext
13
+
14
+ private val DarkColorScheme = darkColorScheme(
15
+ primary = Purple80 ,
16
+ secondary = PurpleGrey80 ,
17
+ tertiary = Pink80
18
+ )
19
+
20
+ private val LightColorScheme = lightColorScheme(
21
+ primary = Purple40 ,
22
+ secondary = PurpleGrey40 ,
23
+ tertiary = Pink40
24
+
25
+ /* Other default colors to override
26
+ background = Color(0xFFFFFBFE),
27
+ surface = Color(0xFFFFFBFE),
28
+ onPrimary = Color.White,
29
+ onSecondary = Color.White,
30
+ onTertiary = Color.White,
31
+ onBackground = Color(0xFF1C1B1F),
32
+ onSurface = Color(0xFF1C1B1F),
33
+ */
34
+ )
35
+
36
+ @Composable
37
+ fun BazaarupdaterSampleTheme (
38
+ darkTheme : Boolean = isSystemInDarkTheme(),
39
+ // Dynamic color is available on Android 12+
40
+ dynamicColor : Boolean = true,
41
+ content : @Composable () -> Unit
42
+ ) {
43
+ val colorScheme = when {
44
+ dynamicColor && Build .VERSION .SDK_INT >= Build .VERSION_CODES .S -> {
45
+ val context = LocalContext .current
46
+ if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
47
+ }
48
+
49
+ darkTheme -> DarkColorScheme
50
+ else -> LightColorScheme
51
+ }
52
+
53
+ MaterialTheme (
54
+ colorScheme = colorScheme,
55
+ typography = Typography ,
56
+ content = content
57
+ )
58
+ }
0 commit comments