improvements on status and nav color set

This commit is contained in:
Diogo
2024-09-04 12:12:43 +01:00
parent 9009744c28
commit a29ec774e8
3 changed files with 33 additions and 17 deletions
@@ -21,7 +21,7 @@ interface PlatformInterface {
fun androidIsBackgroundCallAllowed(): Boolean = true
fun androidSetNightModeIfSupported() {}
fun androidSetStatusAndNavBarColors(isLight: Boolean, backgroundColor: Color, hasTop: Boolean, hasBottom: Boolean) {}
fun androidSetStatusBarColor(isLight: Boolean, animatedColor: Animatable<Color, AnimationVector4D>) {}
fun androidSetDrawerStatusAndNavBarColor(isLight: Boolean, drawerShadingColor: Animatable<Color, AnimationVector4D>, toolbarOnTop: Boolean, changeNavBarColor: (originalColor: Color) -> Color) {}
fun androidStartCallActivity(acceptCall: Boolean, remoteHostId: Long? = null, chatId: ChatId? = null) {}
fun androidPictureInPictureAllowed(): Boolean = true
fun androidCallEnded() {}
@@ -379,6 +379,8 @@ fun UserPicker(
)
}
val originalNavColor = mutableStateOf<Color?>(null)
LaunchedEffect(Unit) {
launch {
userPickerState.collect {
@@ -387,15 +389,18 @@ fun UserPicker(
val toColor = if (colors.isLight) colors.onSurface.copy(alpha = ScrimOpacity) else Color.Black.copy(0.64f)
animatedColor.animateTo(if (newChat.isVisible()) toColor else Color.Transparent, newChatSheetAnimSpec()) {
if (newChat.isVisible()) {
platform.androidSetStatusAndNavBarColors(colors.isLight, colors.surface, !appPrefs.oneHandUI.get(), false)
} else {
platform.androidSetStatusAndNavBarColors(colors.isLight, colors.background, !appPrefs.oneHandUI.get(), appPrefs.oneHandUI.get())
}
if (newChat.isVisible() || newChat.isHiding()) {
platform.androidSetStatusBarColor(
CurrentColors.value.colors.isLight,
animatedColor
platform.androidSetDrawerStatusAndNavBarColor(
isLight = CurrentColors.value.colors.isLight,
drawerShadingColor = animatedColor,
toolbarOnTop = !appPrefs.oneHandUI.get(),
changeNavBarColor = { c ->
val onc = originalNavColor.value
if (onc == null) {
originalNavColor.value = c
}
if (newChat.isVisible()) colors.surface else onc ?: colors.background.mixWith(colors.onBackground, 0.97f)
},
)
}
}