commonMain.com.arkivanov.decompose.extensions.compose.stack.animation.SimpleStackAnimation.kt Maven / Gradle / Ivy
package com.arkivanov.decompose.extensions.compose.stack.animation
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import com.arkivanov.decompose.Child
import com.arkivanov.decompose.ExperimentalDecomposeApi
internal class SimpleStackAnimation(
disableInputDuringAnimation: Boolean,
private val selector: (Child.Created) -> StackAnimator?,
) : AbstractStackAnimation(disableInputDuringAnimation = disableInputDuringAnimation) {
@OptIn(ExperimentalDecomposeApi::class)
@Composable
override fun Child(
item: AnimationItem,
onFinished: () -> Unit,
content: @Composable (child: Child.Created) -> Unit,
) {
val animator = remember(item.child.key) { selector(item.child) ?: EmptyStackAnimator }
animator(
direction = item.direction,
isInitial = item.isInitial,
onFinished = onFinished,
) { modifier ->
Box(modifier = modifier) {
content(item.child)
}
}
}
}