I have a `ModalBottomSheetLayout` where the conten...
# compose
l
I have a
ModalBottomSheetLayout
where the contents is the main screen with a list of items, and the
sheetContent
are item details (with different settings). As the item details are quite complex, and don't influence the main screen, I would like to have them in a separate ViewModel. How can I pass the
itemId
from the
MainScreenViewModel
to the
ItemDetailsViewModel
. I don't really fancy creating a shared ViewModel just to pass one value (which is anyway only temporary, as the
ItemDetailsViewModel
will store
itemId
as well to get the item data).
m
create an Item with itemId, use it as lazyColumn item id and also, use a lambda with a callback with that same id with the click, and pass it to the details viewmodel
l
Yes, the passing of the callback to the details viewmodel was something I was missing. It is actually quite easy, as both viewmodels are known by the same host (fragment in my case), so I can pass their callbacks to the composable click listeners. Thank you for the hint!