If you have an app state holder in the top navigat...
# compose
p
If you have an app state holder in the top navigation of your app, and that state holder haves a dialog message variable that must be used to display a dialog if it is different from null... how to deal with it if you need to display a dialog on the children screens when a button is pressed and some logic is executed? those viewmodels doesn't have access to the main app state holder to set that message only when some logic is executed successfully. Should the app state holder be passed to the children screens viewmodels?
z
Does the dialog actually need to be owned by the child screens or can it be shown from closer to the root of your app?
p
well, the childs have some logic... downloading data from a server, and I wanna display a "x files downloaded" dialog... but I already have an app level dialog state variables that are used to display an app level dialog on my app.kt, where the navigation is managed
if I hoist the message from the child screen to the parent app.kt... I don't know how to do it just when my child screen viewmodel has ended recovering the data from internet...
z
Sound like you are trying to build something like
SnackbarHost
and
SnackbarHostState
.
That said, there’s no technical reason why you can just give each child its own local state for its own dialog. But that might be undesirable for other reasons (eg the potential for overlapping dialogs)