使用 AnimatedNavHost 时屏幕上不显示任何内容

Nothing is displayed on the screen when using AnimatedNavHost

我正在使用伴奏动画库:

implementation "com.google.accompanist:accompanist-navigation-animation:0.24.0-alpha"

我有以下 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
        )
    }
}

我的 AuthScreen 非常简单:

Box(
    modifier = Modifier.fillMaxSize().padding(bottom = 48.dp),
    contentAlignment = Alignment.BottomCenter
) {
    Button(
        onClick = {
            signIn()
        }
    ) {
        Text(
            text = SIGN_IN,
            fontSize = 18.sp
        )
    }

当我启动应用程序时,屏幕上没有任何显示?没有崩溃。谁能帮忙?谢谢

P.S。我也在使用:

implementation "androidx.hilt:hilt-navigation-compose:1.0.0-rc01"

我正在使用以下导入:

import com.google.accompanist.navigation.animation.AnimatedNavHost
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition

根据 Accompanist Navigation Animation migration guide:

To migrate from using the Navigation Compose APIs do the following:

  • Replace rememberNavController() with rememberAnimatedNavController()
  • Replace NavHost with AnimatedNavHost
  • Replace import androidx.navigation.compose.navigation with import com.google.accompanist.navigation.animation.navigation
  • Replace import androidx.navigation.compose.composable with import com.google.accompanist.navigation.animation.composable

我怀疑你实际上还没有完成最后一个 - 如果你想让你的目的地被 AnimatedNavHost 拾取,你需要使用 composable NavGraphBuilder 扩展的 Accompanist 版本。 =22=]