nglauber
06/28/2021, 3:45 PMisSystemInDarkTheme()
is always returning true even when I switch to light mode? 🤔nglauber
06/28/2021, 3:46 PMsetContent {
MyAppTheme {
ProvideWindowInsets {
Surface(color = AppTheme.colors.background) {
AppNavHost(
initialRoute = initRoute.route,
sharedViewModel = sharedViewModel,
onFinishRequest = { finish() },
hasAccounts = hasAccount
)
}
}
}
}
nglauber
06/28/2021, 3:47 PMTheme.MaterialComponents.DayNight.DarkActionBar
iamthevoid
06/28/2021, 3:48 PMnglauber
06/28/2021, 3:48 PMAndrew Neal
06/28/2021, 3:50 PMMyAppTheme
? There's nothing particularly of note in the snippet you posted.iamthevoid
06/28/2021, 3:50 PMisSystemInDarkTheme()
should returns true
when dark theme enabled android-system-wide and false
if doesn’t. Maybe it is device specific bug?nglauber
06/28/2021, 3:51 PM@Composable
fun MyAppTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
Log.d("NGVL", "darkTheme: $darkTheme ----- ${isSystemInDarkTheme()}")
@Andrew Neal this log is printing… true 😕nglauber
06/28/2021, 3:51 PMiamthevoid
06/28/2021, 3:56 PMdarkTheme: true ----- true
or
darkTheme: true ----- false
?
I am not sure that darkTheme
param changing same waynglauber
06/28/2021, 3:56 PMAndrew Neal
06/28/2021, 3:56 PMisSystemInDarkThem
is just checking the Configuration
flags.
@Composable
@ReadOnlyComposable
internal actual fun _*isSystemInDarkTheme*(): Boolean {
val uiMode = LocalConfiguration.current.uiMode
return (uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
}
nglauber
06/28/2021, 3:57 PMnglauber
06/28/2021, 3:57 PMnglauber
06/28/2021, 3:58 PMnglauber
06/28/2021, 3:58 PMAndrew Neal
06/28/2021, 4:05 PMisSystemInDarkTheme
like you are goes, that looks good.iamthevoid
06/28/2021, 4:19 PMlouiscad
06/28/2021, 4:25 PMnglauber
06/28/2021, 4:35 PM1.4.0-alpha01
Lucien Guimaraes
06/28/2021, 5:05 PMandroid:configChanges="uiMode"
? Without it, the theme won't be updated at runtime when you switch darkMode from the statusbar panelnglauber
06/28/2021, 5:07 PMAdam Powell
06/28/2021, 5:11 PMLucien Guimaraes
06/28/2021, 5:13 PMnglauber
06/28/2021, 5:19 PMnglauber
06/28/2021, 5:47 PMsetContent {
Log.d("NGVL", "isSystemInDarkTheme = ${isSystemInDarkTheme()}")
When I toggle dark/light mode, it is printed, but just the original value is displayed. I mean, if I open the app in dark mode, it’s always show true, otherwise always show false. 😞nglauber
06/28/2021, 6:15 PMattachBaseContext
to configure the application language.
So the context returned by createConfigurationContext
is not working…
val locale = Locale(language)
Locale.setDefault(locale)
val configuration = Configuration(context.resources.configuration)
configuration.setLocale(locale)
return context.createConfigurationContext(configuration)
Suggestions?nglauber
06/28/2021, 6:18 PMtad
06/28/2021, 6:24 PMLocaleList.getDefault
would return the correct valuenglauber
06/28/2021, 6:26 PMonAttachBaseContext
on both app and activity. When I left just in the activity, it’s working… I’ll test language change to check if it’s set.tad
06/28/2021, 6:26 PMcashapp/copper
to update a MutableState whenever the locale changes, but that's probably unnecessary if Compose can pull it from the Configuration