PromptModel
Base model object for prompts.
Prompt is a UI dialog (typically a modal bottom sheet dialog) that asynchronous code can pop up merely by calling a specialized function like requestPassphrase (more generally PromptDialogModel.displayPrompt on a dialog model obtained through getDialogModel). Such function will pop up the dialog, and then suspend until user enters the input, performs the required action or dismisses the dialog. User input is then returned to the caller (or PromptDismissedException is thrown if the dialog is dismissed).
PromptModel must exist in the current CoroutineContext for prompt functions to work.
An instance of PromptModel can be added to the context using withContext.
There is a predefined coroutine scope promptModelScope that is bound to the context that contains this model (it can be used similar to
ViewModel.viewModelScopeon Android).In Composable environment PromptModel can be used with
rememberCoroutineScopelike this:val myScope = rememberCoroutineScope { promptModel }Content copied to clipboard
PromptModel is actually a holder object for individual dialog models PromptDialogModel. More dialog types can be registered by creating and registering PromptDialogModel classes in the platform PromptModel. Each dialog must be bound to its UI independently (see org.multipaz.compose.prompt.PromptDialogs in multipaz-compose for an example), in different UI scenarios a different set of dialogs may be supported.
This class is abstract, as each platform should generally implement its own variant, in particular by providing an appropriate promptModelScope.
Inheritors
Types
Functions
Extracts PromptDialogModel of the required type from this PromptModel.
This method is called when there is no UI that is bound to a particular PromptDialogModel.
Prompts user for authentication through a passphrase.