commonMain.StackChildren.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of componental-compose-jvm Show documentation
Show all versions of componental-compose-jvm Show documentation
Kotlin Multiplatform library for componentization of Compose UI.
The newest version!
package de.halfbit.componental.compose
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.runtime.Composable
import de.halfbit.componental.router.stack.Stack
@Composable
public inline fun StackChildren(
stack: Stack,
crossinline content: @Composable (active: C) -> Unit,
) {
AnimatedContent(
targetState = stack.active,
label = "StackChildren",
contentKey = { it.route },
transitionSpec = {
fadeIn(
animationSpec = tween(220, delayMillis = 70),
initialAlpha = 0f,
) togetherWith fadeOut(
animationSpec = tween(220),
targetAlpha = 1f,
)
},
) { active ->
content(active.child)
}
}