diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..b44d3255
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,21 @@
+root = true
+
+[*]
+charset = utf-8
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{kt,kts}]
+ij_kotlin_imports_layout = *
+ij_kotlin_allow_trailing_comma = true
+ij_kotlin_allow_trailing_comma_on_call_site = true
+ktlint_code_style = intellij_idea
+ktlint_function_naming_ignore_when_annotated_with = Composable
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.{yml,yaml}]
+indent_size = 2
\ No newline at end of file
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 89763e39..a0cf1441 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -2,31 +2,101 @@ name: Build
on:
push:
- branches:
- - main
+ branches: [ "*" ]
+ paths-ignore:
+ - 'mkdocs.yml'
+ - 'docs/**'
pull_request:
- branches:
- - main
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
jobs:
+ lint:
+ name: 🧹 Lint
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Validate Gradle Wrapper
+ uses: gradle/wrapper-validation-action@v3
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ java-version: '17'
+ distribution: 'adopt'
+ cache: gradle
+
+ - name: Make gradle executable
+ run: chmod +x ./gradlew
+
+ - name: Lint app
+ run: ./gradlew spotlessCheck --stacktrace
+
+ test:
+ name: 🧪 Test
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Validate Gradle Wrapper
+ uses: gradle/wrapper-validation-action@v3
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ java-version: '17'
+ distribution: 'adopt'
+ cache: gradle
+
+ - name: Make gradle executable
+ run: chmod +x ./gradlew
+
+ - name: Test app
+ run: ./gradlew test --stacktrace
+
+ api-check:
+ name: 🕵️ API Check
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Validate Gradle Wrapper
+ uses: gradle/wrapper-validation-action@v3
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v4
+ with:
+ java-version: '17'
+ distribution: 'adopt'
+ cache: gradle
+
+ - name: Make gradle executable
+ run: chmod +x ./gradlew
+
+ - name: API Check
+ run: ./gradlew apiCheck --stacktrace
+
build:
+ name: 🏗 Build
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: JDK setup
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: corretto
- name: Cache konan directory
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-konan-${{ hashFiles('*.gradle.kts', 'buildSrc/*') }}
@@ -37,4 +107,4 @@ jobs:
run: |
./gradlew :sample:shared:assemble --no-daemon --stacktrace
env:
- GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3g"
\ No newline at end of file
+ GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3g"
diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml
new file mode 100644
index 00000000..2183cc28
--- /dev/null
+++ b/.github/workflows/publish-docs.yml
@@ -0,0 +1,60 @@
+name: Publish docs
+
+on:
+ push:
+ branches:
+ - main
+ workflow_dispatch:
+
+permissions:
+ contents: write
+ pages: write
+ id-token: write
+
+jobs:
+ deploy_docs:
+ runs-on: macos-latest
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup JDK
+ uses: actions/setup-java@v4
+ with:
+ distribution: 'zulu'
+ java-version: 21
+
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.x'
+
+ - name: Setup Pages
+ uses: actions/configure-pages@v5
+
+ - name: Install dependencies
+ run: |
+ python3 -m pip install --upgrade pip
+ python3 -m pip install mkdocs mkdocs-material mkdocs-video "mkdocs-material[imaging]"
+
+ - name: Set up Gradle
+ uses: gradle/actions/setup-gradle@v3
+
+ - name: Generate Dokka documentation
+ run: ./gradlew dokkaHtmlMultiModule
+
+ - name: Build MkDocs
+ run: mkdocs build
+
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ path: 'site/' # MkDocs builds to site/ by default
+
+ - name: Deploy to GitHub Pages
+ id: deployment # This is required for environment
+ uses: actions/deploy-pages@v4
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index a0f5d2c0..a06e3d77 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -14,17 +14,28 @@ permissions:
jobs:
deploy:
- runs-on: ubuntu-latest
- timeout-minutes: 30
+ strategy:
+ matrix:
+ include:
+ - target: publish
+ os: macos-14
+ runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v3
+ - name: Validate Gradle Wrapper
+ uses: gradle/wrapper-validation-action@v1
+ - uses: actions/cache@v3
+ with:
+ path: |
+ ~/.konan
+ key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
- - name: Setup JDK
- uses: actions/setup-java@v4
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
with:
- distribution: 'zulu'
- java-version: 17
+ java-version: '17'
+ distribution: 'temurin'
- name: Make gradle executable
run: chmod +x ./gradlew
diff --git a/.gitignore b/.gitignore
index 04ca0e6a..28887f32 100644
--- a/.gitignore
+++ b/.gitignore
@@ -98,4 +98,6 @@ Preview.html
screenshots/**/*.png
test_output
-*.env*
\ No newline at end of file
+*.env*
+
+.kotlin
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 00000000..7fa4a87d
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+Sain
\ No newline at end of file
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
new file mode 100644
index 00000000..b52f5496
--- /dev/null
+++ b/.idea/deploymentTargetSelector.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index fe63bb67..148fdd24 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 630de44d..c0351255 100644
--- a/README.md
+++ b/README.md
@@ -1,158 +1,14 @@
-

+[](https://search.maven.org/artifact/io.github.joelkanyi/sain) 
+
+
# Sain (サイン)
A Compose Multiplatform library for capturing and exporting signatures as ImageBitmap with customizable options. Perfect for electronic signature, legal documents and more.
-
-
-### 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)
-}
-```
-
-
-#### 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")
- }
- }
-}
-```
-
-
-
-#### 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
-
-
-
-#### 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
-
-
-
-#### 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.
-
-
-
-### Demo
-##### Android
-
-
-
-##### iOS
-
-
-
-##### Desktop
-
-
-
-##### Web Wasm
-
-
-
-##### Web JS
-
-
+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");
diff --git a/build.gradle.kts b/build.gradle.kts
index d583ceab..e83a95b4 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -37,6 +37,12 @@ subprojects {
)
trimTrailingWhitespace()
endWithNewline()
+
+ ktlint().customRuleSets(
+ listOf(
+ "io.nlopez.compose.rules:ktlint:0.4.4",
+ ),
+ )
}
format("kts") {
target("**/*.kts")
@@ -51,3 +57,7 @@ subprojects {
}
}
}
+
+tasks.withType().configureEach {
+ outputDirectory.set(file("$rootDir/docs/kdoc"))
+}
diff --git a/docs/assets/android_demo.gif b/docs/assets/android_demo.gif
new file mode 100644
index 00000000..dc470913
Binary files /dev/null and b/docs/assets/android_demo.gif differ
diff --git a/docs/assets/demo_web_wasm.gif b/docs/assets/demo_web_wasm.gif
new file mode 100644
index 00000000..6743fa16
Binary files /dev/null and b/docs/assets/demo_web_wasm.gif differ
diff --git a/docs/assets/desktop_demo.gif b/docs/assets/desktop_demo.gif
new file mode 100644
index 00000000..3617c8f2
Binary files /dev/null and b/docs/assets/desktop_demo.gif differ
diff --git a/docs/assets/ios_demo.gif b/docs/assets/ios_demo.gif
new file mode 100644
index 00000000..343b0452
Binary files /dev/null and b/docs/assets/ios_demo.gif differ
diff --git a/docs/assets/sain.gif b/docs/assets/sain.gif
new file mode 100644
index 00000000..518368fa
Binary files /dev/null and b/docs/assets/sain.gif differ
diff --git a/docs/assets/web_js_demo.gif b/docs/assets/web_js_demo.gif
new file mode 100644
index 00000000..7fdecc50
Binary files /dev/null and b/docs/assets/web_js_demo.gif differ
diff --git a/docs/get-started.md b/docs/get-started.md
new file mode 100644
index 00000000..e2484abf
--- /dev/null
+++ b/docs/get-started.md
@@ -0,0 +1,45 @@
+### 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)
+}
+```
+
\ No newline at end of file
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 00000000..cf470a6b
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,147 @@
+# Sain (サイン)
+A Compose Multiplatform library for capturing and exporting signatures as ImageBitmap with customizable options. Perfect for electronic signature, legal documents and more.
+
+
+
+### 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)
+}
+```
+
+
+#### 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")
+ }
+ }
+}
+```
+
+
+
+#### 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
+
+
+
+#### 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
+
+
+
+#### 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.
+
+
+
+
+#### License
+```xml
+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://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
diff --git a/docs/license.md b/docs/license.md
new file mode 100644
index 00000000..a1ef93a0
--- /dev/null
+++ b/docs/license.md
@@ -0,0 +1,15 @@
+```xml
+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://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
\ No newline at end of file
diff --git a/docs/samples.md b/docs/samples.md
new file mode 100644
index 00000000..f6310924
--- /dev/null
+++ b/docs/samples.md
@@ -0,0 +1,19 @@
+##### Android
+
+
+
+##### iOS
+
+
+
+##### Desktop
+
+
+
+##### Web Wasm
+
+
+
+##### Web JS
+
+
diff --git a/docs/usage.md b/docs/usage.md
new file mode 100644
index 00000000..b4bac638
--- /dev/null
+++ b/docs/usage.md
@@ -0,0 +1,73 @@
+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")
+ }
+ }
+}
+```
+
+#### 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
+
+
+
+#### 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
+
+
+
+#### 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.
diff --git a/gradle.properties b/gradle.properties
index 6a65e357..5c440885 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,5 +1,5 @@
# Lib version
-version=2.0.3
+version=2.0.5
#Gradle
org.gradle.jvmargs=-Xmx4048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx4048M"
@@ -28,4 +28,4 @@ org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.wasm.enabled=true
#macOS
-org.jetbrains.compose.experimental.macos.enabled=true
\ No newline at end of file
+org.jetbrains.compose.experimental.macos.enabled=true
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 8ca93a52..dc30c5e9 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,13 +1,14 @@
[versions]
-kotlin = "1.9.23"
-agp = "8.3.2"
-core-ktx = "1.13.0"
-compose = "1.6.2"
-compose-activity = "1.9.0"
+kotlin = "1.9.24"
+agp = "8.5.1"
+core-ktx = "1.13.1"
+compose = "1.6.11"
+compose-activity = "1.9.1"
spotless = "6.25.0"
kotlin-compatibility = "0.14.0"
dokka = "1.9.20"
-gradleMavenPublish = "0.28.0"
+gradleMavenPublish = "0.29.0"
+nmcp = "0.0.8"
[libraries]
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" }
@@ -25,4 +26,4 @@ jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-compatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlin-compatibility" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
gradleMavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "gradleMavenPublish" }
-nmcp = { id = "com.gradleup.nmcp", version = "0.0.4" }
\ No newline at end of file
+nmcp = { id = "com.gradleup.nmcp", version.ref = "nmcp" }
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index b82aa23a..a4413138 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
index 1aa94a42..b740cf13 100755
--- a/gradlew
+++ b/gradlew
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
diff --git a/mkdocs.yml b/mkdocs.yml
new file mode 100644
index 00000000..9d02d43b
--- /dev/null
+++ b/mkdocs.yml
@@ -0,0 +1,71 @@
+site_name: Sain
+site_description: "A Simple Compose Multiplatform Signature Capture Library"
+site_author: "Joel Kanyi"
+site_url: "https://joelkanyi.github.io/sain/"
+repo_name: sain
+repo_url: "https://github.com/joelkanyi/sain"
+edit_uri: "tree/main/docs/"
+docs_dir: docs
+remote_branch: gh-pages
+
+nav:
+ - 'Overview': index.md
+ - 'Getting Started': get-started.md
+ - 'Usage': usage.md
+ - 'API Reference': kdoc/sain/index.html
+ - 'Demo': samples.md
+ - 'License': license.md
+
+theme:
+ name: 'material'
+ language: 'en'
+ features:
+ - navigation.sections
+ - navigation.top
+ - search.suggest
+ - search.highlight
+ - content.tabs.link
+ - content.code.annotation
+ - content.code.copy
+ palette:
+ # Palette toggle for light mode
+ - scheme: default
+ media: "(prefers-color-scheme: light)"
+ toggle:
+ icon: material/brightness-7
+ name: Switch to dark mode
+
+ # Palette toggle for dark mode
+ - scheme: slate
+ media: "(prefers-color-scheme: dark)"
+ toggle:
+ icon: material/brightness-4
+ name: Switch to light mode
+
+plugins:
+ - search
+
+# Extensions
+markdown_extensions:
+ - admonition
+ - attr_list
+ - codehilite:
+ guess_lang: false
+ - footnotes
+ - pymdownx.betterem
+ - pymdownx.superfences
+ - pymdownx.tabbed
+ - pymdownx.details
+ - pymdownx.tilde
+
+extra:
+ social:
+ - icon: fontawesome/brands/github-alt
+ link: https://github.com/joelkanyi
+ - icon: fontawesome/brands/twitter
+ link: https://twitter.com/_joelkanyi
+ - icon: fontawesome/brands/linkedin
+ link: https://www.linkedin.com/in/joel-kanyi-037270174/
+
+copyright: |
+ © 2024 Joel Kanyi
diff --git a/renovate.json b/renovate.json
index 8f1c4e65..2bff9dc0 100644
--- a/renovate.json
+++ b/renovate.json
@@ -12,7 +12,7 @@
],
"prHourlyLimit": 0,
"baseBranches": [
- "develop"
+ "main"
],
"separateMultipleMajor": true,
"dependencyDashboardTitle": "automated dependency updates dashboard",
diff --git a/sain/api/android/sain.api b/sain/api/android/sain.api
index 9ba50e9f..dc49ab87 100644
--- a/sain/api/android/sain.api
+++ b/sain/api/android/sain.api
@@ -1,15 +1,5 @@
-public final class io/github/joelkanyi/sain/ActionsAlignment : java/lang/Enum {
- public static final field BOTTOM Lio/github/joelkanyi/sain/ActionsAlignment;
- public static final field LEFT Lio/github/joelkanyi/sain/ActionsAlignment;
- public static final field RIGHT Lio/github/joelkanyi/sain/ActionsAlignment;
- public static final field TOP Lio/github/joelkanyi/sain/ActionsAlignment;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
- public static fun valueOf (Ljava/lang/String;)Lio/github/joelkanyi/sain/ActionsAlignment;
- public static fun values ()[Lio/github/joelkanyi/sain/ActionsAlignment;
-}
-
public final class io/github/joelkanyi/sain/SainKt {
- public static final fun Sain-uKGX-YA (Landroidx/compose/ui/Modifier;Lio/github/joelkanyi/sain/SignatureState;JFLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V
+ public static final fun Sain-zSi9XkE (Lio/github/joelkanyi/sain/SignatureState;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;JFLkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V
}
public final class io/github/joelkanyi/sain/SignatureAction : java/lang/Enum {
@@ -20,10 +10,6 @@ public final class io/github/joelkanyi/sain/SignatureAction : java/lang/Enum {
public static fun values ()[Lio/github/joelkanyi/sain/SignatureAction;
}
-public final class io/github/joelkanyi/sain/SignatureActionKt {
- public static final fun toAlignment (Lio/github/joelkanyi/sain/ActionsAlignment;)Landroidx/compose/ui/Alignment;
-}
-
public final class io/github/joelkanyi/sain/SignatureLine {
public static final field $stable I
public synthetic fun (JJLkotlin/jvm/internal/DefaultConstructorMarker;)V
diff --git a/sain/api/jvm/sain.api b/sain/api/jvm/sain.api
index 9ba50e9f..dc49ab87 100644
--- a/sain/api/jvm/sain.api
+++ b/sain/api/jvm/sain.api
@@ -1,15 +1,5 @@
-public final class io/github/joelkanyi/sain/ActionsAlignment : java/lang/Enum {
- public static final field BOTTOM Lio/github/joelkanyi/sain/ActionsAlignment;
- public static final field LEFT Lio/github/joelkanyi/sain/ActionsAlignment;
- public static final field RIGHT Lio/github/joelkanyi/sain/ActionsAlignment;
- public static final field TOP Lio/github/joelkanyi/sain/ActionsAlignment;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
- public static fun valueOf (Ljava/lang/String;)Lio/github/joelkanyi/sain/ActionsAlignment;
- public static fun values ()[Lio/github/joelkanyi/sain/ActionsAlignment;
-}
-
public final class io/github/joelkanyi/sain/SainKt {
- public static final fun Sain-uKGX-YA (Landroidx/compose/ui/Modifier;Lio/github/joelkanyi/sain/SignatureState;JFLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V
+ public static final fun Sain-zSi9XkE (Lio/github/joelkanyi/sain/SignatureState;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Modifier;JFLkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V
}
public final class io/github/joelkanyi/sain/SignatureAction : java/lang/Enum {
@@ -20,10 +10,6 @@ public final class io/github/joelkanyi/sain/SignatureAction : java/lang/Enum {
public static fun values ()[Lio/github/joelkanyi/sain/SignatureAction;
}
-public final class io/github/joelkanyi/sain/SignatureActionKt {
- public static final fun toAlignment (Lio/github/joelkanyi/sain/ActionsAlignment;)Landroidx/compose/ui/Alignment;
-}
-
public final class io/github/joelkanyi/sain/SignatureLine {
public static final field $stable I
public synthetic fun (JJLkotlin/jvm/internal/DefaultConstructorMarker;)V
diff --git a/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/ImageBitmapUtils.kt b/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/ImageBitmapUtils.kt
index d93a1ec9..83ac87d8 100644
--- a/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/ImageBitmapUtils.kt
+++ b/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/ImageBitmapUtils.kt
@@ -48,7 +48,7 @@ internal fun toImageBitmap(
density = Density(1f, 1f),
layoutDirection = LayoutDirection.Ltr,
canvas = this,
- size = Size(width.toFloat(), height.toFloat())
+ size = Size(width.toFloat(), height.toFloat()),
) {
signatureSignatureLines.forEach { line ->
drawLine(
@@ -56,7 +56,7 @@ internal fun toImageBitmap(
start = line.start,
end = line.end,
strokeWidth = (signatureSize * 3).toPx(),
- cap = StrokeCap.Round
+ cap = StrokeCap.Round,
)
}
}
diff --git a/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/Sain.kt b/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/Sain.kt
index 989cac48..de27ca4f 100644
--- a/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/Sain.kt
+++ b/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/Sain.kt
@@ -43,13 +43,14 @@ import androidx.compose.ui.unit.dp
* @param actions The composable that provides the actions that can be performed on the signature.
* We only have two actions: [SignatureAction.CLEAR] and [SignatureAction.COMPLETE].
**/
+@Suppress("ktlint:compose:modifier-not-used-at-root")
@Composable
public fun Sain(
- modifier: Modifier = Modifier,
state: SignatureState,
+ onComplete: (signature: ImageBitmap?) -> Unit,
+ modifier: Modifier = Modifier,
signatureColor: Color = Color.Black,
signatureThickness: Dp = 5.dp,
- onComplete: (signature: ImageBitmap?) -> Unit,
actions: @Composable (
action: (SignatureAction) -> Unit,
) -> Unit,
@@ -78,9 +79,9 @@ public fun Sain(
signatureColor = signatureColor,
signatureSize = signatureThickness,
signatureSignatureLines = state.signatureLines,
- )
+ ),
)
- }
+ },
) {
state.signature?.let {
Image(
@@ -103,7 +104,7 @@ public fun Sain(
state.signature
} else {
null
- }
+ },
)
}
}
@@ -126,7 +127,6 @@ public class SignatureState {
private val _signatureLines = mutableStateListOf()
public val signatureLines: List get() = _signatureLines.toList()
-
private val _signature = mutableStateOf(null)
public val signature: ImageBitmap? get() = _signature.value
diff --git a/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/SignatureAction.kt b/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/SignatureAction.kt
index 51c92f33..413ee2cb 100644
--- a/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/SignatureAction.kt
+++ b/sain/src/commonMain/kotlin/io/github/joelkanyi/sain/SignatureAction.kt
@@ -15,11 +15,6 @@
*/
package io.github.joelkanyi.sain
-import androidx.compose.ui.Alignment
-import io.github.joelkanyi.sain.ActionsAlignment.BOTTOM
-import io.github.joelkanyi.sain.ActionsAlignment.LEFT
-import io.github.joelkanyi.sain.ActionsAlignment.RIGHT
-import io.github.joelkanyi.sain.ActionsAlignment.TOP
import io.github.joelkanyi.sain.SignatureAction.CLEAR
import io.github.joelkanyi.sain.SignatureAction.COMPLETE
@@ -32,27 +27,3 @@ public enum class SignatureAction {
CLEAR,
COMPLETE,
}
-
-/**
- * Actions Alignment
- * [TOP] aligns the actions to the top.
- * [BOTTOM] aligns the actions to the bottom.
- * [LEFT] aligns the actions to the left.
- * [RIGHT] aligns the actions to the right.
- */
-public enum class ActionsAlignment {
- TOP,
- BOTTOM,
- LEFT,
- RIGHT,
-}
-
-/**
- * Converts the ActionsAlignment to Alignment.
- */
-public fun ActionsAlignment.toAlignment(): Alignment = when (this) {
- ActionsAlignment.TOP -> Alignment.TopStart
- ActionsAlignment.BOTTOM -> Alignment.BottomStart
- ActionsAlignment.LEFT -> Alignment.TopStart
- ActionsAlignment.RIGHT -> Alignment.TopEnd
-}
diff --git a/sample/android/build.gradle.kts b/sample/android/build.gradle.kts
index 4f7a779b..3808c6ef 100644
--- a/sample/android/build.gradle.kts
+++ b/sample/android/build.gradle.kts
@@ -57,7 +57,7 @@ android {
}
composeOptions {
- kotlinCompilerExtensionVersion = "1.5.11"
+ kotlinCompilerExtensionVersion = "1.5.14"
}
packaging {
resources {
diff --git a/sample/android/src/main/java/com/joelkanyi/sain/ui/theme/Theme.kt b/sample/android/src/main/java/com/joelkanyi/sain/ui/theme/Theme.kt
index a18154b9..83c10372 100644
--- a/sample/android/src/main/java/com/joelkanyi/sain/ui/theme/Theme.kt
+++ b/sample/android/src/main/java/com/joelkanyi/sain/ui/theme/Theme.kt
@@ -28,13 +28,13 @@ import androidx.compose.ui.platform.LocalContext
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
- tertiary = Pink80
+ tertiary = Pink80,
)
private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
- tertiary = Pink40
+ tertiary = Pink40,
/* Other default colors to override
background = Color(0xFFFFFBFE),
@@ -44,7 +44,7 @@ private val LightColorScheme = lightColorScheme(
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
- */
+ */
)
@Composable
@@ -52,7 +52,7 @@ fun ComposeSignatureTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
- content: @Composable () -> Unit
+ content: @Composable () -> Unit,
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
@@ -66,6 +66,6 @@ fun ComposeSignatureTheme(
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
- content = content
+ content = content,
)
}
diff --git a/sample/android/src/main/java/com/joelkanyi/sain/ui/theme/Type.kt b/sample/android/src/main/java/com/joelkanyi/sain/ui/theme/Type.kt
index 7d961fd2..f23bfe94 100644
--- a/sample/android/src/main/java/com/joelkanyi/sain/ui/theme/Type.kt
+++ b/sample/android/src/main/java/com/joelkanyi/sain/ui/theme/Type.kt
@@ -28,8 +28,8 @@ val Typography = Typography(
fontWeight = FontWeight.Normal,
fontSize = 16.sp,
lineHeight = 24.sp,
- letterSpacing = 0.5.sp
- )
+ letterSpacing = 0.5.sp,
+ ),
/* Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
@@ -45,5 +45,5 @@ val Typography = Typography(
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
- */
+ */
)
diff --git a/sample/shared/src/commonMain/kotlin/com.composesignature.sample/Sample.kt b/sample/shared/src/commonMain/kotlin/com.composesignature.sample/Sample.kt
index fe66475e..6d643460 100644
--- a/sample/shared/src/commonMain/kotlin/com.composesignature.sample/Sample.kt
+++ b/sample/shared/src/commonMain/kotlin/com.composesignature.sample/Sample.kt
@@ -48,9 +48,11 @@ import io.github.joelkanyi.sain.SignatureAction
import io.github.joelkanyi.sain.SignatureState
@Composable
-fun Sample() {
+fun Sample(
+ modifier: Modifier = Modifier,
+) {
Surface(
- modifier = Modifier.fillMaxSize(),
+ modifier = modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
var imageBitmap by remember {
@@ -67,7 +69,7 @@ fun Sample() {
.padding(16.dp)
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
- verticalArrangement = Arrangement.spacedBy(16.dp)
+ verticalArrangement = Arrangement.spacedBy(16.dp),
) {
Text(
modifier = Modifier.fillMaxWidth(),
@@ -83,9 +85,9 @@ fun Sample() {
.border(
BorderStroke(
width = .5.dp,
- color = MaterialTheme.colorScheme.onSurface
+ color = MaterialTheme.colorScheme.onSurface,
),
- shape = RoundedCornerShape(8.dp)
+ shape = RoundedCornerShape(8.dp),
),
onComplete = { signatureBitmap ->
if (signatureBitmap != null) {
@@ -99,21 +101,23 @@ fun Sample() {
modifier = Modifier
.padding(top = 16.dp)
.fillMaxWidth(),
- horizontalArrangement = Arrangement.spacedBy(16.dp)
+ 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")
}
}