I'm having some trouble figuring out how to struct...
# compose-android
z
I'm having some trouble figuring out how to structure my UI/Logic such that it easily allows me to implement bottom sheets. In my app, I have a card component that I use across multiple screens. Long click on the card should show a bottom sheet with extra actions. The issue is though that its like 3+ screens, and using a lambda to relay the the long click down to the root screen feels very excessive. There's gotta be an easier way to do this such that it follows proper compose design?
t
There are a couple of alternatives.. You could wrap each of the screens in the bottom sheet (so you end up with 3 instances of the sheet). Essentially just reusing the bottom sheet component. Then you only have to propagate the action up one layer of the hierarchy. Or, you could use the accompanist-navigation-material library, and have your bottom sheet as a navigation destination. Now your calls only have to propagate up until you find a navController, and then you can ask the navController to navigate to the bottom sheet
Otherwise, what you’ve described doesn’t actually sound that bad to me. Compose does feel fairly callback heavy. You can use CompositionLocal to avoid excessive callbacks as well, but that’s probably not how I’d solve this particular problem