I am using Accompanist animation library:
implementation "com.google.accompanist:accompanist-navigation-animation:0.24.0-alpha"
And I have the following AnimatedNavHost:
val navController = rememberAnimatedNavController()
AnimatedNavHost(
navController = navController,
startDestination = "auth",
enterTransition = { EnterTransition.None },
exitTransition = { ExitTransition.None }
) {
composable(
route = "auth"
) {
AuthScreen(
navController = navController
)
}
composable(
route = "profile"
) {
ProfileScreen(
navController = navController
)
}
}
My AuthScreen is as simple as:
Box(
modifier = Modifier.fillMaxSize().padding(bottom = 48.dp),
contentAlignment = Alignment.BottomCenter
) {
Button(
onClick = {
signIn()
}
) {
Text(
text = SIGN_IN,
fontSize = 18.sp
)
}
When I launch the app nothing is displayed on the screen? No crash. Can anyone help? Thanks
P.S. I'm also using:
implementation "androidx.hilt:hilt-navigation-compose:1.0.0-rc01"
I'm using the following imports:
import com.google.accompanist.navigation.animation.AnimatedNavHost
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
As per the Accompanist Navigation Animation migration guide:
To migrate from using the Navigation Compose APIs do the following:
- Replace
rememberNavController()
withrememberAnimatedNavController()
- Replace
NavHost
withAnimatedNavHost
- Replace
import androidx.navigation.compose.navigation
with importcom.google.accompanist.navigation.animation.navigation
- Replace
import androidx.navigation.compose.composable
with importcom.google.accompanist.navigation.animation.composable
I suspect you haven't actually done the last one - you need to use the Accompanist version of the composable
NavGraphBuilder extension if you want your destination to be picked up by AnimatedNavHost
.