best case bars switching working

This commit is contained in:
Diogo
2024-09-04 12:28:56 +01:00
parent a29ec774e8
commit 2e27107646
3 changed files with 21 additions and 15 deletions
@@ -282,7 +282,7 @@ class SimplexApp: Application(), LifecycleEventObserver {
isLight: Boolean,
drawerShadingColor: Animatable<Color, AnimationVector4D>,
toolbarOnTop: Boolean,
changeNavBarColor: (originalColor: Color) -> Color,
navBarColor: Color,
) {
val window = mainActivity.get()?.window ?: return
@@ -292,16 +292,16 @@ class SimplexApp: Application(), LifecycleEventObserver {
val colors = CurrentColors.value.colors
val baseBackgroundColor = if (toolbarOnTop) colors.background.mixWith(colors.onBackground, 0.97f) else colors.background
window.statusBarColor = baseBackgroundColor.mixWith(drawerShadingColor.value.copy(1f), 1 - drawerShadingColor.value.alpha).toArgb()
val navBar = changeNavBarColor(Color(window.navigationBarColor)).toArgb()
val navBar = navBarColor.toArgb()
if (window.navigationBarColor != navBar) {
window.navigationBarColor = navBar
}
if (windowInsetController?.isAppearanceLightNavigationBars != isLight) {
windowInsetController?.isAppearanceLightNavigationBars = isLight
}
}
}
override fun androidSetStatusAndNavBarColors(isLight: Boolean, backgroundColor: Color, hasTop: Boolean, hasBottom: Boolean) {
val window = mainActivity.get()?.window ?: return
@@ -21,7 +21,7 @@ interface PlatformInterface {
fun androidIsBackgroundCallAllowed(): Boolean = true
fun androidSetNightModeIfSupported() {}
fun androidSetStatusAndNavBarColors(isLight: Boolean, backgroundColor: Color, hasTop: Boolean, hasBottom: Boolean) {}
fun androidSetDrawerStatusAndNavBarColor(isLight: Boolean, drawerShadingColor: Animatable<Color, AnimationVector4D>, toolbarOnTop: Boolean, changeNavBarColor: (originalColor: Color) -> Color) {}
fun androidSetDrawerStatusAndNavBarColor(isLight: Boolean, drawerShadingColor: Animatable<Color, AnimationVector4D>, toolbarOnTop: Boolean, navBarColor: Color) {}
fun androidStartCallActivity(acceptCall: Boolean, remoteHostId: Long? = null, chatId: ChatId? = null) {}
fun androidPictureInPictureAllowed(): Boolean = true
fun androidCallEnded() {}
@@ -35,6 +35,7 @@ import chat.simplex.common.views.helpers.*
import chat.simplex.common.platform.*
import chat.simplex.common.views.CreateProfile
import chat.simplex.common.views.newchat.*
import chat.simplex.common.views.onboarding.OnboardingStage
import chat.simplex.common.views.remote.*
import chat.simplex.common.views.usersettings.*
import chat.simplex.common.views.usersettings.AppearanceScope.ColorModeSwitcher
@@ -389,18 +390,23 @@ 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() || newChat.isHiding()) {
if (newChat.isVisible()) {
platform.androidSetDrawerStatusAndNavBarColor(
isLight = CurrentColors.value.colors.isLight,
drawerShadingColor = animatedColor,
isLight = 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)
},
navBarColor = colors.surface
)
} else if (newChat.isHiding()) {
platform.androidSetDrawerStatusAndNavBarColor(
isLight = colors.isLight,
drawerShadingColor = animatedColor,
toolbarOnTop = !appPrefs.oneHandUI.get(),
navBarColor = (if (appPrefs.oneHandUI.get() && appPrefs.onboardingStage.get() == OnboardingStage.OnboardingComplete) {
colors.background.mixWith(CurrentColors.value.colors.onBackground, 0.97f)
} else {
colors.background
})
)
}
}