My App looks like this:
Theme -> ModalBottomSheetLayout -> Scaffold(bottomBar, topBar) -> NavHost
. I use the same
TopBar
to prevent flickering. I was now wondering how I can propagate click events down to the correct screen that is currently displayed with
NavHost
. To use the good old todo example:
When the user clicks a note they enter the
EditNoteScreen
. The
SmallAppTopBar
checks if the current route is
edit-note
and if so, adds an action to delete the note. However, the press happens on the TopBar level which is "more upwards" then the
EditNoteScreen
. And only the ViewModel of that screen knows the current note that gets edited.
The toplevel that contains the
Theme -> ... -> Scaffold
does not even have a ViewModel. Until now it has been completely dump.