Odin
06/20/2023, 9:43 PMchr
06/21/2023, 12:06 AMandroid.content.res.Configuration
, I assume accessing LocalConfiguration
can only be done on a platform that defines Configuration
, which is Android-only.Odin
06/21/2023, 12:12 AMchr
06/21/2023, 12:16 AMisSystemInDarkTheme()
(which delegates to checking via skiko as seen here: https://github.com/search?q=repo%3AJetBrains%2Fskiko+%22actual+val+currentSystemTheme%22&type=code)
If you want to āforceā dark mode, you can just replace any usages of that API with a constant true
and use a MaterialTheme with values for dark mode.chr
06/21/2023, 12:16 AMOdin
06/21/2023, 12:39 AMisSystemInDarkTheme
API šOdin
06/21/2023, 12:41 AMchr
06/21/2023, 6:53 AM@Composable
fun MyTheme(isDarkMode: Boolean = isSystemInDarkTheme()) {
if (isDarkMode) {
MaterialTheme(colors = /* dark colors */)
} else {
MaterialTheme(colors = /* light colors */)
}
}
you can force only a specific part of the app to be in dark mode, if you want:
MyTheme {
// This is in either light mode or dark mode, depending on the platform
Box {
MainContent()
MyTheme(isDarkMode = true) {
// This part will always be in dark mode
PopupContent()
}
}
}