From 8362a55b5040741f9ddd647afe4ea8476d2f174a Mon Sep 17 00:00:00 2001 From: Revxrsal Date: Sat, 23 Dec 2023 17:47:50 +0300 Subject: [PATCH 1/2] Add crossfade transition --- .../transitions/CrossfadeTransition.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 voyager-transitions/src/commonMain/kotlin/cafe/adriel/voyager/transitions/CrossfadeTransition.kt diff --git a/voyager-transitions/src/commonMain/kotlin/cafe/adriel/voyager/transitions/CrossfadeTransition.kt b/voyager-transitions/src/commonMain/kotlin/cafe/adriel/voyager/transitions/CrossfadeTransition.kt new file mode 100644 index 00000000..e3b66f84 --- /dev/null +++ b/voyager-transitions/src/commonMain/kotlin/cafe/adriel/voyager/transitions/CrossfadeTransition.kt @@ -0,0 +1,29 @@ +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 +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) + } + } +} From 47ad1a9720f6cd473a9ed7edd8966b83c7dde289 Mon Sep 17 00:00:00 2001 From: Revxrsal Date: Tue, 26 Dec 2023 23:12:49 +0300 Subject: [PATCH 2/2] Make CrossfadeTransition public --- .../cafe/adriel/voyager/transitions/CrossfadeTransition.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voyager-transitions/src/commonMain/kotlin/cafe/adriel/voyager/transitions/CrossfadeTransition.kt b/voyager-transitions/src/commonMain/kotlin/cafe/adriel/voyager/transitions/CrossfadeTransition.kt index e3b66f84..72b08008 100644 --- a/voyager-transitions/src/commonMain/kotlin/cafe/adriel/voyager/transitions/CrossfadeTransition.kt +++ b/voyager-transitions/src/commonMain/kotlin/cafe/adriel/voyager/transitions/CrossfadeTransition.kt @@ -9,7 +9,7 @@ import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.navigator.Navigator @Composable -fun CrossfadeTransition( +public fun CrossfadeTransition( navigator: Navigator, animationSpec: FiniteAnimationSpec = tween(), label: String = "Crossfade",