dialogStateOf
creates a DialogState object for usage outside of Compose (e.g. ViewModel)
Parameters
the initial data of this state (should nearly always be null which means that the dialog is not visible initially)
define if the positive button should be enabled initially or not
define if the negative button should be enabled initially or not
define if the dialog can be initially dismissed or not
define if the dialog can be initially swiped away or not
callback that will be called whenever the dialog is shown or dismissed with the current data (null if dismissed)
NOTE:
no automatic state saving (no rememberSaveable)
interaction state will be reset whenever the dialog is shown again
EXAMPLE USAGE in a ViewModel (if state should survice process death):
class MyViewModel: ViewModel() {
private val KEY = "dialog_data"
val dialog = dialogStateOf(
data = savedStateHandle.get<String?>(KEY),
onStateChanged = { savedStateHandle[KEY] = it }
)
}creates a DialogState object for usage outside of Compose (e.g. ViewModel)
Parameters
the initial visibility state
define if the positive button should be enabled initially or not
define if the negative button should be enabled initially or not
define if the dialog can be initially dismissed or not
define if the dialog can be initially swiped away or not
callback that will be called whenever the dialog is shown or dismissed with the current data (true if shown, false if dismissed)
NOTE:
no automatic state saving (like rememberDialogState) - you have to handle this by yourself if needed
interaction state will be reset whenever the dialog is shown again
EXAMPLE USAGE in a ViewModel (if state should survice process death):
class MyViewModel: ViewModel() {
private val KEY = "dialog_data"
val dialog = dialogStateOf(
data = savedStateHandle.get<Boolean?>(KEY),
onStateChanged = { savedStateHandle[KEY] = it }
)
}