sain
2.1.6indexedCaptures and exports signatures as ImageBitmap with customizable options for electronic documents. Includes Base64 encoding utility for easy storage and transfer across platforms.
Captures and exports signatures as ImageBitmap with customizable options for electronic documents. Includes Base64 encoding utility for easy storage and transfer across platforms.
A Compose Multiplatform library for capturing and exporting signatures as ImageBitmap with customizable options. Perfect for electronic signatures, legal documents, and more.
Supported platforms: Android · iOS · Desktop (JVM) · Web (JS) · Web (WasmJS)
See the project's website for full documentation.
ImageBitmap on all platformsrememberSignatureState() for persistenceSignatureActionAdd the Maven Central repository if it is not already there:
repositories {
mavenCentral()
}
Add the dependency to your commonMain source set:
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("io.github.joelkanyi:sain:<latest-version>")
}
}
}
}
Add the dependency to your app's build.gradle.kts:
dependencies {
implementation("io.github.joelkanyi:sain:<latest-version>")
}
Add the following to your libs.versions.toml:
[versions]
sain = "<latest-version>"
[libraries]
sain = { module = "io.github.joelkanyi:sain", version.ref = "sain" }
Then add the dependency in your build.gradle.kts:
dependencies {
implementation(libs.sain)
}
Add the Sain composable to your project:
var imageBitmap by remember { mutableStateOf<ImageBitmap?>() }
Sain(
signatureHeight = dp,
signaturePadColor = Color.White,
signatureBorderStroke = BorderStroke(
width = .dp,
color = MaterialTheme.colorScheme.onSurface,
),
signaturePadShape = RoundedCornerShape(dp),
onComplete = { signatureBitmap ->
(signatureBitmap != ) {
imageBitmap = signatureBitmap
} {
println()
}
},
) { action ->
Row(
modifier = Modifier
.padding(top = dp)
.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(dp),
) {
Button(
modifier = Modifier.weight(),
onClick = {
imageBitmap =
action(SignatureAction.CLEAR)
},
) {
Text()
}
Button(
modifier = Modifier.weight(),
onClick = {
action(SignatureAction.COMPLETE)
},
) {
Text()
}
}
}
| Android | iOS | Desktop |
|---|---|---|
![]() | ![]() | ![]() |
| Web (JS) | Web (WasmJS) |
|---|---|
![]() | ![]() |
Copyright 2023 Joel Kanyi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
Surfaced from shared tags and platforms — no rankings paid for.