Skip to content

Commit

Permalink
Remove derivedStateOf
Browse files Browse the repository at this point in the history
  • Loading branch information
zsoltk committed Sep 8, 2023
1 parent 2146038 commit a157af2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -190,16 +189,13 @@ fun elementOffset(
val positionOutside = motionPropertyRenderValue<PositionOutside.Value, PositionOutside>()
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -218,16 +217,13 @@ class ChildrenTransitionScope<InteractionTarget : Any, NavState : Any>(
val positionOutside = motionPropertyRenderValue<PositionOutside.Value, PositionOutside>()
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
}
Expand Down

0 comments on commit a157af2

Please sign in to comment.