Skip to content

Commit c2bdf44

Browse files
authored
Add unveilIn and veilOut animations to default iOS transition specs (#2655)
Fixes https://youtrack.jetbrains.com/issue/CMP-9003 ## Release Notes ### Features - Navigation - Add `unveilIn` and `veilOut` animations to default iOS transition specs in Navigation3
1 parent dce86a9 commit c2bdf44

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

navigation3/navigation3-ui/src/iosMain/kotlin/androidx/navigation3/ui/NavDisplay.ios.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,24 @@ package androidx.navigation3.ui
1818

1919
import androidx.compose.animation.AnimatedContentTransitionScope
2020
import androidx.compose.animation.ContentTransform
21+
import androidx.compose.animation.ExperimentalAnimationApi
2122
import androidx.compose.animation.core.CubicBezierEasing
2223
import androidx.compose.animation.core.LinearEasing
2324
import androidx.compose.animation.core.spring
2425
import androidx.compose.animation.core.tween
2526
import androidx.compose.animation.fadeIn
2627
import androidx.compose.animation.fadeOut
2728
import androidx.compose.animation.scaleOut
29+
import androidx.compose.animation.unveilIn
30+
import androidx.compose.animation.veilOut
2831
import androidx.navigation3.scene.Scene
2932
import androidx.navigationevent.NavigationEvent.Companion.EDGE_LEFT
3033
import androidx.navigationevent.NavigationEvent.SwipeEdge
3134

3235
private const val DEFAULT_TRANSITION_DURATION_MILLISECOND = 500
3336
private val IosTransitionEasing = CubicBezierEasing(0.2833f, 0.99f, 0.31833f, 0.99f)
3437

38+
@OptIn(ExperimentalAnimationApi::class)
3539
public actual fun <T : Any> defaultTransitionSpec():
3640
AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform = {
3741
ContentTransform(
@@ -43,17 +47,22 @@ public actual fun <T : Any> defaultTransitionSpec():
4347
towards = AnimatedContentTransitionScope.SlideDirection.Left,
4448
targetOffset = { it / 4 },
4549
animationSpec = tween(DEFAULT_TRANSITION_DURATION_MILLISECOND, easing = IosTransitionEasing),
50+
) + veilOut(
51+
animationSpec = tween(DEFAULT_TRANSITION_DURATION_MILLISECOND, easing = IosTransitionEasing),
4652
),
4753
)
4854
}
4955

56+
@OptIn(ExperimentalAnimationApi::class)
5057
public actual fun <T : Any> defaultPopTransitionSpec():
5158
AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform = {
5259
ContentTransform(
5360
slideIntoContainer(
5461
towards = AnimatedContentTransitionScope.SlideDirection.Right,
5562
initialOffset = { it / 4 },
5663
animationSpec = tween(DEFAULT_TRANSITION_DURATION_MILLISECOND, easing = IosTransitionEasing),
64+
) + unveilIn(
65+
animationSpec = tween(DEFAULT_TRANSITION_DURATION_MILLISECOND, easing = IosTransitionEasing)
5766
),
5867
slideOutOfContainer(
5968
towards = AnimatedContentTransitionScope.SlideDirection.Right,
@@ -62,6 +71,7 @@ public actual fun <T : Any> defaultPopTransitionSpec():
6271
)
6372
}
6473

74+
@OptIn(ExperimentalAnimationApi::class)
6575
public actual fun <T : Any> defaultPredictivePopTransitionSpec():
6676
AnimatedContentTransitionScope<Scene<T>>.(@SwipeEdge Int) -> ContentTransform = { edge ->
6777
val towards = if (edge == EDGE_LEFT) {
@@ -74,6 +84,8 @@ public actual fun <T : Any> defaultPredictivePopTransitionSpec():
7484
towards = towards,
7585
initialOffset = { it / 4 },
7686
animationSpec = tween(DEFAULT_TRANSITION_DURATION_MILLISECOND, easing = LinearEasing),
87+
) + unveilIn(
88+
animationSpec = tween(DEFAULT_TRANSITION_DURATION_MILLISECOND, easing = LinearEasing),
7789
),
7890
slideOutOfContainer(
7991
towards = towards,

0 commit comments

Comments
 (0)