Performance: uses primitive instead of the wrapped object.

This commit is contained in:
Vitor Pamplona
2023-12-15 14:58:57 -05:00
parent 504980d263
commit 2dc23b601a
@@ -261,7 +261,7 @@ fun MainScreen(
val nestedScrollConnection = remember { val nestedScrollConnection = remember {
object : NestedScrollConnection { object : NestedScrollConnection {
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset { override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
val newOffset = bottomBarOffsetHeightPx.value + available.y val newOffset = bottomBarOffsetHeightPx.floatValue + available.y
if (accountViewModel.settings.automaticallyHideNavigationBars == BooleanType.ALWAYS) { if (accountViewModel.settings.automaticallyHideNavigationBars == BooleanType.ALWAYS) {
val newBottomBarOffset = if (navState.value?.destination?.route !in InvertedLayouts) { val newBottomBarOffset = if (navState.value?.destination?.route !in InvertedLayouts) {
@@ -270,16 +270,16 @@ fun MainScreen(
newOffset.coerceIn(0f, bottomBarHeightPx) newOffset.coerceIn(0f, bottomBarHeightPx)
} }
if (newBottomBarOffset != bottomBarOffsetHeightPx.value) { if (newBottomBarOffset != bottomBarOffsetHeightPx.floatValue) {
bottomBarOffsetHeightPx.value = newBottomBarOffset bottomBarOffsetHeightPx.floatValue = newBottomBarOffset
} }
} else { } else {
if (abs(bottomBarOffsetHeightPx.value) > 0.1) { if (abs(bottomBarOffsetHeightPx.floatValue) > 0.1) {
bottomBarOffsetHeightPx.value = 0f bottomBarOffsetHeightPx.floatValue = 0f
} }
} }
val newShouldShow = abs(bottomBarOffsetHeightPx.value) < bottomBarHeightPx / 2.0f val newShouldShow = abs(bottomBarOffsetHeightPx.floatValue) < bottomBarHeightPx / 2.0f
if (shouldShow.value != newShouldShow) { if (shouldShow.value != newShouldShow) {
shouldShow.value = newShouldShow shouldShow.value = newShouldShow