Код: Выделить всё
@Serializable
object HomeScreen
@Serializable
object AboutScreen
@Composable
fun NavigationAnimation(){
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = HomeScreen,
){
composable(
enterTransition = {
zoomInTransition()
},
exitTransition = {
zoomOutTransition()
}
){
HomeScreen(
onClickGoAboutScreen = {
navController.navigate(AboutScreen)
}
)
}
composable(
enterTransition = {
zoomInTransition()
},
exitTransition = {
zoomOutTransition()
}
){
AboutScreen(
onClickGoHomeScreen = {
navController.navigate(HomeScreen)
}
)
}
}
}
Код: Выделить всё
// * Optimized only for the forward view (I made it slow for better visibility)
fun zoomInTransition(): EnterTransition {
return scaleIn(
initialScale = 0.85f, // ? When reverse/backward navigation the value will be 1.15f
animationSpec = tween(
durationMillis = 2000, // * Actual duration 250
easing = FastOutSlowInEasing
)
)+ fadeIn(
animationSpec = tween(
durationMillis = 2000, // * Actual duration 250
easing = FastOutSlowInEasing
)
)
}
fun zoomOutTransition(): ExitTransition {
return scaleOut(
targetScale = 1.15f, // ? When reverse/backward navigation the value will be 0.85f
animationSpec = tween(
durationMillis = 2000, // * Actual duration 250
easing = FastOutSlowInEasing
)
) + fadeOut(
animationSpec = tween(
durationMillis = 2000, // * Actual duration 250
easing = FastOutSlowInEasing
)
)
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... mpose-when