Fiori Signature Capture¶
A Composable for capturing digital signatures. It displays guidance cues, such as an x-mark and an underline, to assist the user in drawing their signature. Once captured, the signature can be converted to different bitmap formats using BitmapMode. When the signature is submitted, the bitmap is returned in a SignatureInfo object, along with metadata such as date/time, SVG representation, and the reason for signing.

Usage¶
Here's a basic example of how to use the FioriSignatureCapture Composable:
var showDialog by rememberSaveable { mutableStateOf(false) }
FioriSignatureCapture(
onDismissRequest = { showDialog = false },
onSubmit = { signatureInfo ->
// Do something with output
showDialog = false
}
)
For customizations, use the additional parameters provided.
Customization and Parameters¶
The component provides various parameters for customizations:
onDismissRequest: A lambda called when the dialog is dismissed.modifier: A common parameter for applying modifications on UI elements.topAppBarTitle: Text to be displayed in the dialog'sTopAppBar.properties: Provides properties for the dialog, such as dismiss actions.signatureBitmap: Repopulates the signature, typically after a configuration change.bitmapMode: Control the output format of the signature.dateTimeFormatter: Formats the date and time shown in the watermark of the output bitmap.sectionHeader: An optional section header.watermarkText: is the text that appears on the output bitmap as a watermark.onSubmit: A lambda called when the user submits their signature.showLineGuidance: Toggles the visual line guidance for the user, indicating that a signature can be drawn on top of the line.showXMark: Toggles the display of an x-mark, indicating that a signature can be drawn after the "x".colors: Defines the color palette forSignatureCapture.styles: Sets the visual styles (such as padding) forSignatureCapture.textStyles: Determines the text styles forSignatureCapture.saveButtonText: Sets the text of the save button.clearButtonText: Sets the text of the clear button.
Stateless Signature Capture¶
The example above illustrated how to implement a simple signature capture in a stateful Composable. A stateful Composable internally handles its own state, reducing boilerplate, at the cost of flexibility. Thus, the SDK also provides a stateless Composable if control of state is needed.
Signature Capture State¶
Before diving into how to use the stateless SignatureCapture, it is important to understand the states.
ReadyToCapture: The component is ready to start capturing the user's signature, before any drawing action.Capturing: This state is active when the user is in the process of drawing the signature.Submitted: Triggered when the user clicks submit after drawing. At this stage, aSignatureInfoobject is returned via theonSubmitcallback.
@`Composable`
fun SignatureScreen() {
SignatureCapture(
state = SignatureCaptureState.ReadyToCapture,
onClear = {
// Called when the user clears the signature
},
onSigned = {
// Called when the user starts signing
},
onSubmit = { signatureInfo ->
// Handle the submitted signature information
}
)
}
In the example above:
- We start with a state
SignatureCaptureState.ReadyToCapture, indicating that the user hasn't started drawing a signature yet. - The
onClearcallback is invoked when the user clears their signature. - The
onSignedcallback is invoked upon the initial signing. - Finally, the
onSubmitcallback provides you with theSignatureInfoobject when the user submits their signature.
Controlling State¶
Since SignatureCapture is a stateless Composable, it is the responsibility of the application to update state upon callbacks. For those who prefer a stateful version, consider using FioriSignatureCapture.
@`Composable`
fun SignatureScreen() {
// State of SignatureCapture
var signatureState by remember { mutableStateOf(SignatureCaptureState.ReadyToCapture) }
SignatureCapture(
state = signatureState,
onClear = {
signatureState = SignatureCaptureState.ReadyToCapture
},
onSigned = {
signatureState = SignatureCaptureState.Capturing
},
onSubmit = { signatureInfo ->
// Handle the submitted signature information
}
)
// Add a submit button (this can be contained in the optional "footer" parameter
// for SignatureCapture, but for simplicity (and to show flexibility) a submit button
// changes the state of SignatureCapture when clicked:
Button(
onClick = {
signatureState = SignatureCaptureState.Submitted
}
) {
Text("Submit")
}
}
In the example above:
- The
onClearcallback now resets the state toSignatureCaptureState.Capturing. - The
onSignedcallback now updates the state toSignatureCaptureState. Capturing. - The button's
onClickcallback now updates the state toSignatureCaptureState.Submitted.