@@ -2,6 +2,8 @@ package com.xayah.core.ui.theme
22
33// import android.app.Activity
44import android.os.Build
5+ import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
6+ import androidx.compose.material3.MaterialExpressiveTheme
57import androidx.appcompat.app.AppCompatDelegate
68import androidx.compose.foundation.isSystemInDarkTheme
79import androidx.compose.material3.MaterialTheme
@@ -87,8 +89,8 @@ fun DataBackupTheme(
8789 // val window = (view.context as Activity).window
8890 // window.statusBarColor = colorScheme.primary.toArgb()
8991 // WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
90- // }
91- // }
92+ // }
93+ // }
9294
9395 // Transparent system bars
9496 // val systemUiController = rememberSystemUiController()
@@ -98,11 +100,11 @@ fun DataBackupTheme(
98100 // darkIcons = !darkTheme
99101 // )
100102 // systemUiController.setNavigationBarColor(
101- // color = Color.Transparent,
102- // darkIcons = !darkTheme,
103- // navigationBarContrastEnforced = false
104- // )
105- // }
103+ // color = Color.Transparent,
104+ // darkIcons = !darkTheme,
105+ // navigationBarContrastEnforced = false
106+ // )
107+ // }
106108
107109 MaterialTheme (
108110 colorScheme = colorScheme,
@@ -122,6 +124,55 @@ fun DataBackupTheme(
122124 )
123125}
124126
127+ /* *
128+ * Material 3 Expressive theme wrapper for the Dashboard page.
129+ * Uses MaterialExpressiveTheme which provides expressive shapes, motion, and typography.
130+ */
131+ @OptIn(ExperimentalMaterial3ExpressiveApi ::class )
132+ @Composable
133+ fun DataBackupExpressiveTheme (
134+ content : @Composable () -> Unit ,
135+ ) {
136+ val context = LocalContext .current
137+ val darkTheme = darkTheme()
138+
139+ // Dynamic color is available on Android 12+
140+ val dynamicColor by observeMonetEnabled()
141+ val colorScheme = when {
142+ dynamicColor && Build .VERSION .SDK_INT >= Build .VERSION_CODES .S -> {
143+ if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
144+ }
145+
146+ darkTheme -> darkColorScheme()
147+ else -> lightColorScheme()
148+ }
149+ val themedColorScheme = when {
150+ dynamicColor && Build .VERSION .SDK_INT >= Build .VERSION_CODES .S -> {
151+ if (darkTheme) dynamicDarkThemedColorScheme(context) else dynamicLightThemedColorScheme(context)
152+ }
153+
154+ darkTheme -> darkThemedColorScheme()
155+ else -> lightThemedColorScheme()
156+ }
157+
158+ MaterialExpressiveTheme (
159+ colorScheme = colorScheme,
160+ typography = Typography ,
161+ content = {
162+ CompositionLocalProvider (
163+ LocalThemedColorScheme provides themedColorScheme,
164+ ) {
165+ // LocalThemedColorScheme should be applied first.
166+ val slotScope = rememberSlotScope()
167+ CompositionLocalProvider (
168+ LocalSlotScope provides slotScope,
169+ content = content
170+ )
171+ }
172+ }
173+ )
174+ }
175+
125176@Composable
126177fun observeCurrentTheme (): State <ThemeType > {
127178 return LocalContext .current.readThemeType().collectImmediatelyAsState()
@@ -138,4 +189,4 @@ private fun <T> Flow<T>.collectImmediatelyAsState(): State<T> = produceState(
138189 key1 = this ,
139190) {
140191 drop(1 ).collect { value = it }
141- }
192+ }
0 commit comments