Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
joelkanyi committed Jun 7, 2024
1 parent da2a9c4 commit 088959f
Showing 1 changed file with 4 additions and 148 deletions.
152 changes: 4 additions & 148 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,158 +1,14 @@
<p align="center"><img src="demo/sain.gif" alt="Sign" height="150px"></p>

[![Maven central](https://img.shields.io/maven-central/v/io.github.joelkanyi/sain.svg)](https://search.maven.org/artifact/io.github.joelkanyi/sain) ![Build status](https://github.com/joelkanyi/sain/actions/workflows/build.yml/badge.svg)

# Sain (サイン)
A Compose Multiplatform library for capturing and exporting signatures as ImageBitmap with customizable options. Perfect for electronic signature, legal documents and more.

</br>

### Including it in your project:

#### Add the Maven Central repository if it is not already there:
```gradle
repositories {
mavenCentral()
}
```

#### In multiplatform projects, add a dependency to the commonMain source set dependencies
```kotlin
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("io.github.joelkanyi:sain:2.0.3")
}
}
}
}
```

#### In Android projects, add the dependency to your dependencies block in your app's build.gradle file:
```kotlin
dependencies {
implementation("io.github.joelkanyi:sain:2.0.3")
}
```

#### For those using Gradle Version Catalog, you can add the dependency as follows:
```libs.version.toml
[versions]
sain = "2.0.3"

[libraries]
sain = { module = "io.github.joelkanyi:sain", version.ref = "sain" }
```

#### Add then include the dependency in your project as follows:
```kotlin
dependencies {
implementation(libs.sain)
}
```
</br>

#### Usage
Add the `Sain` composable into your project and customize it according to your needs:
```kotlin
var imageBitmap: ImageBitmap? by remember {
mutableStateOf(null)
}

val state = remember {
SignatureState()
}

Sain(
state = state,
modifier = Modifier
.fillMaxWidth()
.height(250.dp)
.border(
BorderStroke(
width = .5.dp,
color = MaterialTheme.colorScheme.onSurface
),
shape = RoundedCornerShape(8.dp)
),
onComplete = { signatureBitmap ->
if (signatureBitmap != null) {
imageBitmap = signatureBitmap
} else {
println("Signature is empty")
}
},
) { action ->
Row(
modifier = Modifier
.padding(top = 16.dp)
.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
Button(
modifier = Modifier.weight(1f),
onClick = {
imageBitmap = null
action(SignatureAction.CLEAR)
}) {
Text("Clear")
}
Button(
modifier = Modifier.weight(1f),
onClick = {
action(SignatureAction.COMPLETE)
}) {
Text("Complete")
}
}
}
```

</br>

#### Actions
The `Sain` composable takes in an `actions` parameter which is a lambda that takes in a `SignatureAction` enum. The `SignatureAction` enum has two values:
- `CLEAR` - Clears the signature
- `COMPLETE` - Completes the signature and returns the signature as an `ImageBitmap` in the `onComplete` lambda

</br>

#### Customization
- `signatureColor` - The color of the signature
- `signatureThickness` - The thickness of the signature
- `modifier` - The modifier for the `Sain` composable which allows you to customize the size, shape, background, border etc of the signature view

</br>

#### Known Issues
The library works well in one orientation. If you rotate the device, the signature will be lost. This is a known issue and will be fixed in the next release.

> Note: The library is now hosted on Maven Central. If you were using the previous version hosted on Jitpack, please update your dependencies to the latest version.
</br>

### Demo
##### Android
<img src="demo/android_demo.gif" width="250"/>
</br>

##### iOS
<img src="demo/ios_demo.gif" width="250"/>
</br>

##### Desktop
<img src="demo/desktop_demo.gif"/>
</br>

##### Web Wasm
<img src="demo/demo_web_wasm.gif"/>
</br>

##### Web JS
<img src="demo/web_js_demo.gif"/>
</br>
See the [project's website](https://joelkanyi.github.io/sain/) for documentation.

#### License
```xml
```
Copyright 2023 Joel Kanyi
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down

0 comments on commit 088959f

Please sign in to comment.