Fix system bar color after login on light theme.
Actually for the SunsetPage, we need a light status bar.
This commit is contained in:
parent
a7dd09014d
commit
0d5470758e
3 changed files with 18 additions and 5 deletions
1
changelog.d/1222.bugfix
Normal file
1
changelog.d/1222.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Fix system bar color after login on light theme.
|
||||||
|
|
@ -44,6 +44,7 @@ import io.element.android.libraries.designsystem.text.withColoredPeriod
|
||||||
import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator
|
import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator
|
||||||
import io.element.android.libraries.designsystem.theme.components.Text
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
import io.element.android.libraries.theme.ElementTheme
|
import io.element.android.libraries.theme.ElementTheme
|
||||||
|
import io.element.android.libraries.theme.ForcedDarkElementTheme
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SunsetPage(
|
fun SunsetPage(
|
||||||
|
|
@ -53,9 +54,7 @@ fun SunsetPage(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
overallContent: @Composable () -> Unit,
|
overallContent: @Composable () -> Unit,
|
||||||
) {
|
) {
|
||||||
ElementTheme(
|
ForcedDarkElementTheme(lightStatusBar = true) {
|
||||||
darkTheme = true
|
|
||||||
) {
|
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier.fillMaxSize()
|
modifier = modifier.fillMaxSize()
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ internal val LocalCompoundColors = staticCompositionLocalOf { compoundColorsLigh
|
||||||
@Composable
|
@Composable
|
||||||
fun ElementTheme(
|
fun ElementTheme(
|
||||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
lightStatusBar: Boolean = !darkTheme,
|
||||||
dynamicColor: Boolean = false, /* true to enable MaterialYou */
|
dynamicColor: Boolean = false, /* true to enable MaterialYou */
|
||||||
compoundColors: SemanticColors = if (darkTheme) compoundColorsDark else compoundColorsLight,
|
compoundColors: SemanticColors = if (darkTheme) compoundColorsDark else compoundColorsLight,
|
||||||
materialLightColors: ColorScheme = materialColorSchemeLight,
|
materialLightColors: ColorScheme = materialColorSchemeLight,
|
||||||
|
|
@ -111,8 +112,19 @@ fun ElementTheme(
|
||||||
darkTheme -> materialDarkColors
|
darkTheme -> materialDarkColors
|
||||||
else -> materialLightColors
|
else -> materialLightColors
|
||||||
}
|
}
|
||||||
|
val statusBarColorScheme = if (lightStatusBar) {
|
||||||
|
when {
|
||||||
|
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||||
|
val context = LocalContext.current
|
||||||
|
dynamicLightColorScheme(context)
|
||||||
|
}
|
||||||
|
else -> materialLightColors
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
colorScheme
|
||||||
|
}
|
||||||
SideEffect {
|
SideEffect {
|
||||||
systemUiController.applyTheme(colorScheme = colorScheme, darkTheme = darkTheme)
|
systemUiController.applyTheme(colorScheme = statusBarColorScheme, darkTheme = darkTheme && !lightStatusBar)
|
||||||
}
|
}
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalCompoundColors provides currentCompoundColor,
|
LocalCompoundColors provides currentCompoundColor,
|
||||||
|
|
@ -132,6 +144,7 @@ fun ElementTheme(
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun ForcedDarkElementTheme(
|
fun ForcedDarkElementTheme(
|
||||||
|
lightStatusBar: Boolean = false,
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit,
|
||||||
) {
|
) {
|
||||||
val systemUiController = rememberSystemUiController()
|
val systemUiController = rememberSystemUiController()
|
||||||
|
|
@ -142,7 +155,7 @@ fun ForcedDarkElementTheme(
|
||||||
systemUiController.applyTheme(colorScheme, wasDarkTheme)
|
systemUiController.applyTheme(colorScheme, wasDarkTheme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ElementTheme(darkTheme = true, content = content)
|
ElementTheme(darkTheme = true, lightStatusBar = lightStatusBar, content = content)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SystemUiController.applyTheme(
|
private fun SystemUiController.applyTheme(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue