mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Ensure that the manual dark theme is rendering correctly regarding night resource and keyboard.
This commit is contained in:
+14
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
package io.element.android.libraries.designsystem.theme
|
package io.element.android.libraries.designsystem.theme
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@@ -29,6 +31,9 @@ import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
|||||||
/**
|
/**
|
||||||
* Theme to use for all the regular screens of the application.
|
* Theme to use for all the regular screens of the application.
|
||||||
* Will manage the light / dark theme based on the user preference.
|
* Will manage the light / dark theme based on the user preference.
|
||||||
|
* Will also ensure that the system is applying the correct global theme
|
||||||
|
* to the application, especially when the system is light and the application
|
||||||
|
* is forced to use dark theme.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun ElementThemeApp(
|
fun ElementThemeApp(
|
||||||
@@ -39,6 +44,15 @@ fun ElementThemeApp(
|
|||||||
appPreferencesStore.getThemeFlow().mapToTheme()
|
appPreferencesStore.getThemeFlow().mapToTheme()
|
||||||
}
|
}
|
||||||
.collectAsState(initial = Theme.System)
|
.collectAsState(initial = Theme.System)
|
||||||
|
LaunchedEffect(theme) {
|
||||||
|
AppCompatDelegate.setDefaultNightMode(
|
||||||
|
when (theme) {
|
||||||
|
Theme.System -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
|
Theme.Light -> AppCompatDelegate.MODE_NIGHT_NO
|
||||||
|
Theme.Dark -> AppCompatDelegate.MODE_NIGHT_YES
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
ElementTheme(
|
ElementTheme(
|
||||||
darkTheme = theme.isDark(),
|
darkTheme = theme.isDark(),
|
||||||
content = content,
|
content = content,
|
||||||
|
|||||||
Reference in New Issue
Block a user