ground-android
ground-android copied to clipboard
[Code health] Composure Dialogs should use state variables passed in from their ViewModels, not local MutableStates
From @anandwana001:
Rather than passing MutableState and bringing the variable modification responsibility to compose function, we can leverage the ViewModel with some event structure, where the variable modification can be moved to viewModel and compose responsibility is just to deliver that event to viewModel.
https://github.com/google/ground-android/pull/2637#discussion_r1714946630
This is evident when you switch contexts, sometimes the dialog renders twice as a result! Instead, we should build a state variable that is updated at the ViewModel level which we pass through here. In that PR, I was following an existing pattern, which means we should try to fix this across all the *Dialog classes.