https://kotlinlang.org logo
#compose
Title
# compose
g

gsala

11/07/2020, 11:22 AM
Using the new navigation for Compose, can I use
Parcelable
arguments or is it only uri-based arguments that can be parse to primitive types?
g

Gabriel

11/07/2020, 11:32 AM
as I understand it it's meant to be used as uri like arguments
g

gsala

11/07/2020, 11:43 AM
sigh.... Thanks 👍
i

Ian Lake

11/08/2020, 1:27 AM
Yes, that's correct
j

Jordi Saumell

11/09/2020, 7:26 PM
I was trying without success to pass a parcelable and found this. But then, if we need to do a simple two-screens list-detail we will need to find a way to scope an object that holds the list and lives for both screens (but not more to save memory). For simple cases this is quite cumbersome compared to just passing a parcelable
g

Gabriel

11/09/2020, 7:29 PM
I have a list of them in the viewmodel and just get the item from that list when moving to the details screen
Copy code
composable(Screen.ImageItem.route + "?imageId={imageId}") { backStackEntry ->
	val imageId = backStackEntry.arguments?.getString("imageId")
	val imageItems by viewModel.imageItems.collectAsState()
	ImageItemScreen(imageItems.first { it.id == imageId })
}
i

Ian Lake

11/09/2020, 8:19 PM
The better thread about this, with more information on how routes should be treated re: Parcelables is https://kotlinlang.slack.com/archives/CJLTWPH7S/p1604053414451400
4 Views