Hey there... whats the best way to implement a `Fo...
# compose-desktop
m
Hey there... whats the best way to implement a
Form
in compose desktop? (UX and Code based) I have a View (with ViewModel) for the screen which displays all
Employees
and allows the user to delete them. My idea was to put the Form for creating a new employee or updating an existing one in a popup and stay at the same screen. However then, I would have to have all the form data fields in my
EmployeeScreenState
, which could result in a heavy mess couldn't it? On the other hand, I could put the form on a separate screen with a separate viewModel, but then I'd have a pretty empty screen with just some form-fields which looks weird imo. What would be the best practice in this case? Thanks in advance!
r
You can use a navigation library which supports opening dialogs. Then the dialog is a separate screen with a separate screen state and possibly a view model.
m
Do you know such a navigation library (for compose desktop)? Currently I'm using Voyager.
r
I don't know about voyager (if it supports navigation to dialogs) but Decompose and Jetpack Navigation do (as far as I remember). But even if you open the dialog manually, you can still have the dialog get a reference to its viewmodel (or create it and remember it). A navigation library would make this a bit simpler but you can also do a disposable effect and make sure to clean up the viewmodel after the dialog leaves the composition.
👍 1