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

commonMain.cafe.adriel.voyager.transitions.CrossfadeTransition.kt Maven / Gradle / Ivy

The newest version!
package cafe.adriel.voyager.transitions

import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.animation.core.tween
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.Navigator

@Composable
public fun CrossfadeTransition(
    navigator: Navigator,
    animationSpec: FiniteAnimationSpec = tween(),
    label: String = "Crossfade",
    modifier: Modifier = Modifier,
    content: @Composable (Screen) -> Unit = { it.Content() }
) {
    Crossfade(
        targetState = navigator.lastItem,
        animationSpec = animationSpec,
        modifier = modifier,
        label = label
    ) { screen ->
        navigator.saveableState("transition", screen) {
            content(screen)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy