Reputation: 101
In all android compose examples I seen they show a snackbar message with undo when u delete from a list... and stay in same screen. Can someone link me to an example where they select a record and GO to a detail screen and THEN click delete record in that detail screen? Usually after delete action you return to list screen? so when do you show the snackbar msg to give the user a chance to undo?
I been searching for a SIMPLE example, but can't find one. Anyone can direct me to an example?
Ideally I would like to be able to set a message on delete in the detail screen that would be displayed on to the return screen(list).
The other option I been thinking about is to return a value on navigation. So instead of navController.popBackStack()
, I would have to return/pass a route with maybe the deleted ID record
Upvotes: 3
Views: 1097
Reputation: 11
https://github.com/Abokyy/snackbardemo-app - check this repo, it works. You need to create State of your whole app (main: collect same coroutineScope, other way your snackbar will disappear too fast after navigating to need screen) and share it to your NavHost() @Composable class, where you can provide showSnackBar() to all screens you need!
Upvotes: 1