All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.arkivanov.decompose.extensions.compose.stack.animation.SimpleStackAnimation.kt Maven / Gradle / Ivy

There is a newer version: 3.2.2
Show newest version
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

internal class SimpleStackAnimation(
    disableInputDuringAnimation: Boolean,
    private val selector: (Child.Created) -> StackAnimator?,
) : AbstractStackAnimation(disableInputDuringAnimation = disableInputDuringAnimation) {

    @Composable
    override fun Child(
        item: AnimationItem,
        onFinished: () -> Unit,
        content: @Composable (child: Child.Created) -> Unit,
    ) {
        val animator = remember(item.child.configuration) { selector(item.child) ?: EmptyStackAnimator }

        animator(
            direction = item.direction,
            isInitial = item.isInitial,
            onFinished = onFinished,
        ) { modifier ->
            Box(modifier = modifier) {
                content(item.child)
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy