From a157af2955a15ca99861d393ab53830c24fbd47a Mon Sep 17 00:00:00 2001 From: Zsolt Kocsi Date: Fri, 8 Sep 2023 12:15:02 +0100 Subject: [PATCH] Remove derivedStateOf --- .../interactions/core/DraggableChildren.kt | 18 +++++++----------- .../navigation/composable/AppyxComponent.kt | 18 +++++++----------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/DraggableChildren.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/DraggableChildren.kt index a680f2872..f35cb435f 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/DraggableChildren.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/DraggableChildren.kt @@ -10,7 +10,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.key import androidx.compose.runtime.mutableStateOf @@ -190,16 +189,13 @@ fun elementOffset( val positionOutside = motionPropertyRenderValue() val layoutDirection = LocalLayoutDirection.current - val positionInsideOffset by derivedStateOf { - positionInside?.let { - it.alignment.align(elementSize, containerSize, layoutDirection) - } ?: IntOffset.Zero - } - val positionOutsideOffset by derivedStateOf { - positionOutside?.let { - it.alignment.align(elementSize, containerSize, layoutDirection) - } ?: IntOffset.Zero - } + val positionInsideOffset = positionInside?.let { + it.alignment.align(elementSize, containerSize, layoutDirection) + } ?: IntOffset.Zero + + val positionOutsideOffset = positionOutside?.let { + it.alignment.align(elementSize, containerSize, layoutDirection) + } ?: IntOffset.Zero return positionInsideOffset - positionOutsideOffset } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxComponent.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxComponent.kt index 8b26d4251..6125a06a1 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxComponent.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/AppyxComponent.kt @@ -7,7 +7,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState -import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.key import androidx.compose.runtime.mutableStateOf @@ -218,16 +217,13 @@ class ChildrenTransitionScope( val positionOutside = motionPropertyRenderValue() val layoutDirection = LocalLayoutDirection.current - val positionInsideOffset by derivedStateOf { - positionInside?.let { - it.alignment.align(elementSize, containerSize, layoutDirection) - } ?: IntOffset.Zero - } - val positionOutsideOffset by derivedStateOf { - positionOutside?.let { - it.alignment.align(elementSize, containerSize, layoutDirection) - } ?: IntOffset.Zero - } + val positionInsideOffset = positionInside?.let { + it.alignment.align(elementSize, containerSize, layoutDirection) + } ?: IntOffset.Zero + + val positionOutsideOffset = positionOutside?.let { + it.alignment.align(elementSize, containerSize, layoutDirection) + } ?: IntOffset.Zero return positionInsideOffset + positionOutsideOffset }