Travis Griggs
02/23/2023, 5:10 PMColton Idle
02/23/2023, 5:14 PMTravis Griggs
02/23/2023, 5:41 PMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Pager4Theme {
MainScreen()
}
}
}
}
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun MainScreen() {
val navController = rememberAnimatedNavController()
Scaffold(bottomBar = {
PageTabBar(navController = navController, modifier = Modifier.height(100.dp))
}) { innerPadding ->
PagesNavHost(
navController = navController, modifier = Modifier.padding(innerPadding)
)
}
}
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun PagesNavHost(
modifier: Modifier = Modifier,
navController: NavHostController,
startDestination: String = "page_plans"
) {
AnimatedNavHost(modifier = modifier,
navController = navController,
startDestination = startDestination) {
composable("page_plans") { PlansPage() }
composable("page_maps") { MapsPage() }
composable("page_status") { StatusPage() }
composable("page_settings") { SettingsPage() }
}
}
Ian Lake
02/23/2023, 5:41 PMcomposable
would make nothing appearTravis Griggs
02/23/2023, 5:41 PMimport com.google.accompanist.navigation.animation.AnimatedNavHost
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
Ian Lake
02/23/2023, 5:42 PM• Replacewithimport androidx.navigation.compose.composable
import com.google.accompanist.navigation.animation.composable
Travis Griggs
02/23/2023, 5:43 PMIan Lake
02/23/2023, 5:49 PMNavHost
or AnimatedNavHost
and have them just work without either of them being aware of how bottom sheets are implemented. That also means that AnimatedNavHost
, which only looks for com.google.accompanist.navigation.animation.composable
destinations just assumes someone else is handling a androidx.navigation.compose.composable
destination, just like a bottomSheet
destination. This would certainly be a good candidate for a lint check (since, in fact, it would never work as you've found 🙂 ), but Accompanist currently doesn't ship any lint checks embedded in their libraries. You could certainly file an issue for that though