From 2dc23b601afc9b41426b9c417764fa0a6e2522df Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 15 Dec 2023 14:58:57 -0500 Subject: [PATCH] Performance: uses primitive instead of the wrapped object. --- .../amethyst/ui/screen/loggedIn/MainScreen.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt index 3a81c943d..5f74d38bb 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/MainScreen.kt @@ -261,7 +261,7 @@ fun MainScreen( val nestedScrollConnection = remember { object : NestedScrollConnection { 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) { val newBottomBarOffset = if (navState.value?.destination?.route !in InvertedLayouts) { @@ -270,16 +270,16 @@ fun MainScreen( newOffset.coerceIn(0f, bottomBarHeightPx) } - if (newBottomBarOffset != bottomBarOffsetHeightPx.value) { - bottomBarOffsetHeightPx.value = newBottomBarOffset + if (newBottomBarOffset != bottomBarOffsetHeightPx.floatValue) { + bottomBarOffsetHeightPx.floatValue = newBottomBarOffset } } else { - if (abs(bottomBarOffsetHeightPx.value) > 0.1) { - bottomBarOffsetHeightPx.value = 0f + if (abs(bottomBarOffsetHeightPx.floatValue) > 0.1) { + bottomBarOffsetHeightPx.floatValue = 0f } } - val newShouldShow = abs(bottomBarOffsetHeightPx.value) < bottomBarHeightPx / 2.0f + val newShouldShow = abs(bottomBarOffsetHeightPx.floatValue) < bottomBarHeightPx / 2.0f if (shouldShow.value != newShouldShow) { shouldShow.value = newShouldShow