refactor: improve navigation animations
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
package bzh.ajaury.chombev
|
||||
|
||||
import androidx.compose.animation.ExitTransition
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.compose.animation.togetherWith
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.saveable.rememberSerializable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.navigation3.runtime.NavEntry
|
||||
import androidx.navigation3.runtime.metadata
|
||||
import androidx.navigation3.ui.NavDisplay
|
||||
import androidx.savedstate.compose.serialization.serializers.SnapshotStateListSerializer
|
||||
import bzh.ajaury.chombev.core.coroutines.di.coroutinesModule
|
||||
@@ -70,7 +76,28 @@ fun App() {
|
||||
}
|
||||
}
|
||||
|
||||
is Route.Player -> NavEntry(key) {
|
||||
is Route.Player -> NavEntry(
|
||||
key,
|
||||
metadata = metadata {
|
||||
put(NavDisplay.TransitionKey) {
|
||||
// Slide new content up, keeping the old content in place underneath
|
||||
slideInHorizontally(
|
||||
initialOffsetX = { it },
|
||||
animationSpec = tween(400),
|
||||
) togetherWith ExitTransition.KeepUntilTransitionsFinished
|
||||
}
|
||||
put(NavDisplay.PopTransitionKey) {
|
||||
// Slide in from left when navigating back
|
||||
slideInHorizontally(initialOffsetX = { -it }) togetherWith
|
||||
slideOutHorizontally(targetOffsetX = { it })
|
||||
}
|
||||
put(NavDisplay.PredictivePopTransitionKey) {
|
||||
// Slide in from left when navigating back
|
||||
slideInHorizontally(initialOffsetX = { -it }) togetherWith
|
||||
slideOutHorizontally(targetOffsetX = { it })
|
||||
}
|
||||
},
|
||||
) {
|
||||
PlayerScreen(
|
||||
recordId = key.recordId,
|
||||
onBackClicked = { backStack.removeLastOrNull() },
|
||||
|
||||
Reference in New Issue
Block a user