Bug P4
Status Update
Comments
st...@google.com <st...@google.com> #2
That's correct, we have not yet updated the Wear Compose Navigation library to support the type-safety that's now supported on the compose navhost. It's on the roadmap, but unlikely to make it as part of our 1.5 release.
vi...@meditab.com <vi...@meditab.com> #3
Any guesses, on which date 1.5 version can be released?
ze...@gmail.com <ze...@gmail.com> #4
You should use
import com.google.android.horologist.compose.nav.SwipeDismissableNavHost
import com.google.android.horologist.compose.nav.composable
instead of
import androidx.wear.compose.navigation.SwipeDismissableNavHost
import androidx.wear.compose.navigation.composable
vi...@meditab.com <vi...@meditab.com> #5
Which dependency I have to add for "com.google.android.horologist.compose.nav.SwipeDismissableNavHost"? Also, does it support for wear navigation compose?
Description
Version used:1.5.0-alpha04
Devices/Android versions reproduced on: Samsung Galaxy Watch 6
How to use Navigation library in Wear compose with type safety version. The SwipeDismissableNavHost's startDestination propety doesn't accept Any value like NavHost.
Used Dependency for wear navigation Compose:
androidx.wear.compose:compose-navigation:1.5.0-alpha04
Please find below code and error:
java.lang.IllegalArgumentException: navigation destination home is not a direct child of this NavGraph
Code:
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
setTheme(android.R.style.Theme_Black)
setContent {
WearAppIMSTheme {
Scaffold(timeText = {
TimeText(
timeTextStyle = TimeTextDefaults.timeTextStyle(
color = MaterialTheme.colors.onBackground
)
)
},
content = {
DemoApp(modifier = Modifier)
})
}
}
}
}
@Composable
fun DemoApp(modifier: Modifier) {
Box(
modifier = modifier
.background(MaterialTheme.colors.background)
) {
val navController = rememberSwipeDismissableNavController()
/**
* NavHost Builds a navGraph to handle navigation, set the start destination to Home and
* provide the navController which will control the navigation.
*/
SwipeDismissableNavHost(
navController = navController,
startDestination = ("home") // Getting Error: IllegalArgumentException: navigation destination home is not a direct child of this NavGraph
) {
composable<Routes.Home> {
Home(navigateToDetails = { aptDetails ->
navController.navigate(Routes.AppointmentDetail(aptDetails))
}, navigateToMySchedule = {
navController.navigate(Routes.MySchedule)
}, navigateToWaitingApts = {
navController.navigate(Routes.WaitingForMe)
})
}
composable<Routes.WaitingForMe> {
WaitingForMe(onBackPress = {
navController.popBackStack()
})
}
composable<Routes.AppointmentDetail>(
typeMap = mapOf(typeOf<ApptList>() to NavType.fromCustom<ApptList>())
) {
val apptList = rememberSaveable {
it.toRoute<Routes.AppointmentDetail>().apptDetail
}
AppointmentDetail(apptList, onBackPress = {
navController.popBackStack()
}, modifier)
}
composable<Routes.MySchedule> {
MySchedule(onBackPress = {
navController.popBackStack()
}, modifier = Modifier,
navigateToDetails = {
navController.navigate(Routes.AppointmentDetail(it))
})
}
}
}
}