Only changes shouldShow if the value is different.

This commit is contained in:
Vitor Pamplona
2023-10-02 14:44:29 -04:00
parent 4b36217699
commit d6f4ffafa1
@@ -239,18 +239,26 @@ fun MainScreen(
val newOffset = bottomBarOffsetHeightPx.value + available.y
if (accountViewModel.account.settings.automaticallyHideNavigationBars == BooleanType.ALWAYS) {
bottomBarOffsetHeightPx.value = if (navState.value?.destination?.route !in InvertedLayouts) {
val newBottomBarOffset = if (navState.value?.destination?.route !in InvertedLayouts) {
newOffset.coerceIn(-bottomBarHeightPx, 0f)
} else {
newOffset.coerceIn(0f, bottomBarHeightPx)
}
if (newBottomBarOffset != bottomBarOffsetHeightPx.value) {
bottomBarOffsetHeightPx.value = newBottomBarOffset
}
} else {
if (abs(bottomBarOffsetHeightPx.value) > 0.1) {
bottomBarOffsetHeightPx.value = 0f
}
}
shouldShow.value = abs(bottomBarOffsetHeightPx.value) < bottomBarHeightPx / 2.0f
val newShouldShow = abs(bottomBarOffsetHeightPx.value) < bottomBarHeightPx / 2.0f
if (shouldShow.value != newShouldShow) {
shouldShow.value = newShouldShow
}
return Offset.Zero
}