Only changes shouldShow if the value is different.
This commit is contained in:
@@ -239,18 +239,26 @@ fun MainScreen(
|
|||||||
val newOffset = bottomBarOffsetHeightPx.value + available.y
|
val newOffset = bottomBarOffsetHeightPx.value + available.y
|
||||||
|
|
||||||
if (accountViewModel.account.settings.automaticallyHideNavigationBars == BooleanType.ALWAYS) {
|
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)
|
newOffset.coerceIn(-bottomBarHeightPx, 0f)
|
||||||
} else {
|
} else {
|
||||||
newOffset.coerceIn(0f, bottomBarHeightPx)
|
newOffset.coerceIn(0f, bottomBarHeightPx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newBottomBarOffset != bottomBarOffsetHeightPx.value) {
|
||||||
|
bottomBarOffsetHeightPx.value = newBottomBarOffset
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (abs(bottomBarOffsetHeightPx.value) > 0.1) {
|
if (abs(bottomBarOffsetHeightPx.value) > 0.1) {
|
||||||
bottomBarOffsetHeightPx.value = 0f
|
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
|
return Offset.Zero
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user