Skip to content

Commit 9e3b905

Browse files
committed
feat: Update Nav transitions
Signed-off-by: Hu Shenghao <dede.hu@qq.com>
1 parent 69a6809 commit 9e3b905

File tree

1 file changed

+11
-29
lines changed

1 file changed

+11
-29
lines changed

app/src/main/java/com/dede/android_eggs/views/main/EasterEggsNavHost.kt

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package com.dede.android_eggs.views.main
22

3-
import androidx.compose.animation.AnimatedContentTransitionScope.SlideDirection
4-
import androidx.compose.animation.core.EaseIn
5-
import androidx.compose.animation.core.EaseOut
6-
import androidx.compose.animation.core.LinearEasing
73
import androidx.compose.animation.core.tween
84
import androidx.compose.animation.fadeIn
95
import androidx.compose.animation.fadeOut
6+
import androidx.compose.animation.slideInHorizontally
7+
import androidx.compose.animation.slideOutHorizontally
108
import androidx.compose.runtime.Composable
119
import androidx.compose.runtime.CompositionLocalProvider
1210
import androidx.compose.ui.Modifier
@@ -33,7 +31,7 @@ import com.dede.android_eggs.views.timeline.TimelineListDialog
3331
import com.dede.basic.Utils
3432

3533

36-
private const val TRANSITION_DURATION = 320
34+
private const val TRANSITION_DURATION = 400
3735

3836
@Composable
3937
fun EasterEggsNavHost(
@@ -51,36 +49,20 @@ fun EasterEggsNavHost(
5149
startDestination = EasterEggsScreen.route,
5250
modifier = modifier,
5351
enterTransition = {
54-
fadeIn(
55-
animationSpec = tween(TRANSITION_DURATION, easing = LinearEasing)
56-
) + slideIntoContainer(
57-
animationSpec = tween(TRANSITION_DURATION, easing = EaseIn),
58-
towards = SlideDirection.Start
59-
)
52+
fadeIn(animationSpec = tween(TRANSITION_DURATION)) +
53+
slideInHorizontally(animationSpec = tween(TRANSITION_DURATION)) { it }
6054
},
6155
exitTransition = {
62-
fadeOut(
63-
animationSpec = tween(TRANSITION_DURATION, easing = LinearEasing)
64-
) + slideOutOfContainer(
65-
animationSpec = tween(TRANSITION_DURATION, easing = EaseIn),
66-
towards = SlideDirection.Start
67-
)
56+
fadeOut(animationSpec = tween(TRANSITION_DURATION)) +
57+
slideOutHorizontally(animationSpec = tween(TRANSITION_DURATION))
6858
},
6959
popEnterTransition = {
70-
fadeIn(
71-
animationSpec = tween(TRANSITION_DURATION, easing = LinearEasing)
72-
) + slideIntoContainer(
73-
animationSpec = tween(TRANSITION_DURATION, easing = EaseOut),
74-
towards = SlideDirection.End,
75-
)
60+
fadeIn(animationSpec = tween(TRANSITION_DURATION), initialAlpha = 0.3f) +
61+
slideInHorizontally(animationSpec = tween(TRANSITION_DURATION))
7662
},
7763
popExitTransition = {
78-
fadeOut(
79-
animationSpec = tween(TRANSITION_DURATION, easing = LinearEasing)
80-
) + slideOutOfContainer(
81-
animationSpec = tween(TRANSITION_DURATION, easing = EaseOut),
82-
towards = SlideDirection.End
83-
)
64+
fadeOut(animationSpec = tween(TRANSITION_DURATION)) +
65+
slideOutHorizontally(animationSpec = tween(TRANSITION_DURATION)) { it }
8466
},
8567
) {
8668
composable(route = EasterEggsScreen.route) {

0 commit comments

Comments
 (0)