Skip to content

Commit

Permalink
release/1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhirkevich committed Mar 3, 2024
1 parent d37a650 commit 4ec1c47
Show file tree
Hide file tree
Showing 59 changed files with 845 additions and 3,275 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build

on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- uses: gradle/[email protected]
with:
gradle-home-cache-cleanup: true
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Assemble
run: ./gradlew assemble --stacktrace
- name: Publish
if: startsWith(github.ref, 'refs/tags/')
run: ./gradlew publish
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_KEY_PWD: ${{ secrets.GPG_KEY_PWD }}

23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
![badge-macOS](https://img.shields.io/badge/Platform-macOS-purple)
![badge-web](https://img.shields.io/badge/Platform-Web-blue)

QR code design library for Compose Multiplatform
Barcode generation library for Compose Multiplatform

<img width="465" alt="Screenshot 2023-10-10 at 10 34 05" src="https://github.com/alexzhirkevich/qrose/assets/63979218/7469cc1c-d6fd-4dab-997d-f2604dfa49de">

Expand All @@ -16,34 +16,45 @@ Why QRose?
- **Efficient** - declare and render codes synchronously right from the composition in 60+ fps;
- **Scalable** - no raster bitmaps, only scalable vector graphics;
- **Multiplatform** - supports all the targets supported by Compose Multiplatform.
- **Multiformat** - multiple formats supported : QR, UPC, EAN, Code 128, etc.

# Installation

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.alexzhirkevich/qrose/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.alexzhirkevich/qrose)

```gradle
dependencies {
implementation("io.github.alexzhirkevich:qrose:1.0.0-beta3")
// For QR codes
implementation("io.github.alexzhirkevich:qrose:1.0.0")
// For single-dimension barcodes (UPC,EAN, Code128, ...)
implementation("io.github.alexzhirkevich:qrose:1.0.0-oned")
}
```

# Usage

## Basic

You can create code right in composition using `rememberQrCodePainter`.
Or do it outside of Compose scope by instantiating a `QrCodePainter` class.
You can create code right in composition using `rememberQrCodePainter`, `rememberBarcodePainter`.
Or use `QrCodePainter`, `BarcodePainter` to crate it outside compose.

```kotlin
Image(
painter = rememberQrCodePainter("https://example.com"),
contentDescription = "QR code"
contentDescription = "QR code referring to the example.com website"
)

Image(
painter = rememberBarcodePainter("9780201379624", BarcodeType.EAN13),
contentDescription = "EAN barcode for some product"
)
```

## Design

There are some overloads of `rememberQrCodePainter` including DSL constructor:
QR codes have flexible styling options, for example:

```kotlin
val logoPainter : Painter = painterResource("logo.png")
Expand Down
98 changes: 98 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
@file: Suppress("DSL_SCOPE_VIOLATION")

import org.jetbrains.compose.internal.utils.localPropertiesFile
import java.util.Properties
import java.util.Base64

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.application).apply(false)
alias(libs.plugins.compose).apply(false)
alias(libs.plugins.dokka).apply(false)
id("maven-publish")
id("signing")
}

//tasks.register("clean", Delete::class) {
Expand All @@ -19,13 +26,29 @@ val composePlugin = libs.plugins.compose

val ver = libs.versions.qrose.get()

if (System.getenv("OSSRH_PASSWORD") != null){
ext["OSSRH_USERNAME"] = System.getenv("OSSRH_USERNAME")
ext["OSSRH_PASSWORD"] = System.getenv("OSSRH_PASSWORD")
ext["GPG_KEY"] = System.getenv("GPG_KEY")
ext["GPG_KEY_PWD"] = System.getenv("GPG_KEY_PWD")
} else {
val properties = Properties().apply {
load(localPropertiesFile.inputStream())
}
properties.forEach {
ext[it.key.toString()] = it.value.toString()
}
}

subprojects {
if (!name.startsWith("qrose"))
return@subprojects

this.group = "io.github.alexzhirkevich"
this.version = ver

plugins.apply("maven-publish")
plugins.apply("signing")
plugins.apply(kmpPlugin.get().pluginId)
plugins.apply(androidLibPlugin.get().pluginId)
plugins.apply(composePlugin.get().pluginId)
Expand Down Expand Up @@ -95,6 +118,81 @@ subprojects {
targetCompatibility = JavaVersion.toVersion(_jvmTarget)
}
}

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}

val signingTasks = tasks.withType<Sign>()

tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOn(signingTasks)
}

publishing {

repositories.maven {
val releasesRepoUrl =
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl =
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = if (version.toString().endsWith("SNAPSHOT")) {
uri(snapshotsRepoUrl)
} else {
uri(releasesRepoUrl)
}
credentials {
if (rootProject.ext.has("OSSRH_PASSWORD")) {
password = rootProject.ext["OSSRH_PASSWORD"] as String
}
if (rootProject.ext.has("OSSRH_USERNAME")) {
username = rootProject.ext["OSSRH_USERNAME"] as String
}
}
}

val publishProperties = Properties().apply {
load(file("publish.properties").inputStream())
}

publications.withType<MavenPublication> {
artifact(javadocJar)
pom {
name.set(this@subprojects.name)
description.set(publishProperties.getProperty("description"))
url.set("https://github.com/alexzhirkevich/qrose")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("alexzhirkevich")
name.set("Alexander Zhirkevich")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/alexzhirkevich/qrose")
connection.set("scm:git:git://github.com/alexzhirkevich/qrose.git")
developerConnection.set("scm:git:git://github.com/alexzhirkevich/qrose.git")
}
}
}
}

if (rootProject.ext.has("GPG_KEY") && rootProject.ext.has("GPG_KEY_PWD") ) {
signing {
useInMemoryPgpKeys(
Base64.getDecoder().decode(rootProject.ext["GPG_KEY"] as String).decodeToString(),
rootProject.ext["GPG_KEY_PWD"] as String,
)
sign(publishing.publications)
}
}
}
android {
namespace = "io.github.alexzhirkevich.qrose"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.DatePicker
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.rememberDatePickerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -32,18 +27,11 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.unit.dp
import io.github.alexzhirkevich.qrose.DelicateQRoseApi
import io.github.alexzhirkevich.qrose.QrData
import io.github.alexzhirkevich.qrose.email
import io.github.alexzhirkevich.qrose.oned.rememberCodabarPainter
import io.github.alexzhirkevich.qrose.oned.rememberCode128Painter
import io.github.alexzhirkevich.qrose.oned.rememberCode39Painter
import io.github.alexzhirkevich.qrose.oned.rememberCode93Painter
import io.github.alexzhirkevich.qrose.oned.rememberEAN13Painter
import io.github.alexzhirkevich.qrose.oned.rememberEAN8Painter
import io.github.alexzhirkevich.qrose.oned.rememberITFPainter
import io.github.alexzhirkevich.qrose.oned.rememberUPCAPainter
import io.github.alexzhirkevich.qrose.oned.rememberUPCEPainter
import io.github.alexzhirkevich.qrose.options.DelicateQRoseApi
import io.github.alexzhirkevich.qrose.oned.BarcodeType
import io.github.alexzhirkevich.qrose.oned.rememberBarcodePainter
import io.github.alexzhirkevich.qrose.options.QrBallShape
import io.github.alexzhirkevich.qrose.options.QrBrush
import io.github.alexzhirkevich.qrose.options.QrCodeShape
Expand All @@ -65,7 +53,6 @@ import qrose.example.shared.generated.resources.Res
import qrose.example.shared.generated.resources.jc
import qrose.example.shared.generated.resources.jcbg

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun App() {
AllBarcodes()
Expand All @@ -75,15 +62,15 @@ fun App() {
@Composable
fun AllBarcodes() {
FlowRow(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())) {
OnedCode("ITF", rememberITFPainter("123456734512"))
OnedCode("UPC E", rememberUPCEPainter("02345673"))
OnedCode("UPC A", rememberUPCAPainter("123456789012"))
OnedCode("EAN 13", rememberEAN13Painter("9780201379624"))
OnedCode("EAN 8", rememberEAN8Painter("1234567"))
OnedCode("Code 39", rememberCode39Painter("TEST"))
OnedCode("Code 93", rememberCode93Painter("TEST"))
OnedCode("Code 128", rememberCode128Painter("test"))
OnedCode("Codabar", rememberCodabarPainter("A23342453D"))
OnedCode("ITF", rememberBarcodePainter("123456734512", BarcodeType.ITF))
OnedCode("UPC E", rememberBarcodePainter("02345673", BarcodeType.UPCE))
OnedCode("UPC A", rememberBarcodePainter("123456789012", BarcodeType.UPCA))
OnedCode("EAN 13", rememberBarcodePainter("9780201379624", BarcodeType.EAN13))
OnedCode("EAN 8", rememberBarcodePainter("1234567", BarcodeType.EAN8))
OnedCode("Code 39", rememberBarcodePainter("TEST", BarcodeType.Code39))
OnedCode("Code 93", rememberBarcodePainter("TEST", BarcodeType.Code93))
OnedCode("Code 128", rememberBarcodePainter("test", BarcodeType.Code128))
OnedCode("Codabar", rememberBarcodePainter("A23342453D", BarcodeType.Codabar))
OnedCode("QR", rememberQrCodePainter("https://github.com/alexzhirkevich/qrose"))
}
}
Expand Down
Loading

0 comments on commit 4ec1c47

Please sign in to comment.