Skip to content

Commit

Permalink
compose 1.6.0, wasmJs, new barcode types
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhirkevich Alexander Y authored and Zhirkevich Alexander Y committed Feb 28, 2024
1 parent 0b4e72c commit 63cca29
Show file tree
Hide file tree
Showing 26 changed files with 1,866 additions and 3,112 deletions.
95 changes: 93 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,102 @@
@file: Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.kotlin.multiplatform).apply(false)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.application).apply(false)
alias(libs.plugins.android.library).apply(false)
alias(libs.plugins.compose).apply(false)
alias(libs.plugins.dokka).apply(false)
}

//tasks.register("clean", Delete::class) {
// delete(rootProject.buildDir)
//}

val _jvmTarget = findProperty("jvmTarget") as String

val kmpPlugin = libs.plugins.kotlin.multiplatform
val androidLibPlugin = libs.plugins.android.library
val composePlugin = libs.plugins.compose

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

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

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

plugins.apply(kmpPlugin.get().pluginId)
plugins.apply(androidLibPlugin.get().pluginId)
plugins.apply(composePlugin.get().pluginId)

kotlin {
applyDefaultHierarchyTemplate()

androidTarget {
publishLibraryVariants("release")
compilations.all {
kotlinOptions {
jvmTarget = _jvmTarget
}
}
}
iosArm64()
iosX64()
iosSimulatorArm64()
js(IR) {
browser()
}
wasmJs(){
browser()
}
jvm("desktop") {
compilations.all {
kotlinOptions {
jvmTarget = _jvmTarget
}
}
}

macosArm64()
macosX64()

sourceSets {

val desktopMain by getting

val darwinMain by creating {
dependsOn(commonMain.get())
macosMain.get().dependsOn(this)
iosMain.get().dependsOn(this)
}

val wasmJsMain by getting

val skikoMain by creating {
dependsOn(commonMain.get())
jsMain.get().dependsOn(this)
wasmJsMain.dependsOn(this)
desktopMain.dependsOn(this)
darwinMain.dependsOn(this)
}
}
}

android {
namespace = "io.github.alexzhirkevich.${name.replace('-','.')}"
compileSdk = 34
defaultConfig {
minSdk = 21
}

compileOptions {
sourceCompatibility = JavaVersion.toVersion(_jvmTarget)
targetCompatibility = JavaVersion.toVersion(_jvmTarget)
}
}
}
android {
namespace = "io.github.alexzhirkevich.qrose"
compileSdk = findProperty("android.compileSdk").toString().toInt()
}
7 changes: 2 additions & 5 deletions example/desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ plugins {

kotlin {
jvm {
withJava()
// compilations.all {
// kotlinOptions.jvmTarget = "11"
// }

}
sourceSets {
val jvmMain by getting {
kotlin.srcDirs("src/main/kotlin")
dependencies {
implementation(project(":example:shared"))

implementation(compose.desktop.macos_arm64)
implementation(compose.desktop.currentOs)
api(compose.runtime)
api(compose.foundation)
api(compose.material)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
package io.github.alexzhirkevich.shared
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -21,10 +21,13 @@ 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.ImageFormat
import io.github.alexzhirkevich.qrose.QrCodePainter
import io.github.alexzhirkevich.qrose.QrData
import io.github.alexzhirkevich.qrose.email
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.options.DelicateQRoseApi
import io.github.alexzhirkevich.qrose.options.QrBallShape
import io.github.alexzhirkevich.qrose.options.QrBrush
Expand All @@ -33,7 +36,6 @@ import io.github.alexzhirkevich.qrose.options.QrErrorCorrectionLevel
import io.github.alexzhirkevich.qrose.options.QrFrameShape
import io.github.alexzhirkevich.qrose.options.QrLogoPadding
import io.github.alexzhirkevich.qrose.options.QrLogoShape
import io.github.alexzhirkevich.qrose.options.QrOptions
import io.github.alexzhirkevich.qrose.options.QrPixelShape
import io.github.alexzhirkevich.qrose.options.brush
import io.github.alexzhirkevich.qrose.options.circle
Expand All @@ -42,21 +44,106 @@ import io.github.alexzhirkevich.qrose.options.image
import io.github.alexzhirkevich.qrose.options.roundCorners
import io.github.alexzhirkevich.qrose.options.solid
import io.github.alexzhirkevich.qrose.rememberQrCodePainter
import io.github.alexzhirkevich.qrose.toByteArray
import io.github.alexzhirkevich.qrose.wifi
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource
import qrose.example.shared.generated.resources.Res
import qrose.example.shared.generated.resources.jc
import qrose.example.shared.generated.resources.jcbg

@Composable
fun App() {
QrCode()
}

@Composable
fun CodeEAN13() {
val painter = rememberEAN13Painter(
data = "9780201379624"
)

Image(
painter = painter,
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(.3f)
)
}


@Composable
fun CodeEAN8(){
val painter = rememberEAN8Painter(
data = "1234567"
)

Image(
painter = painter,
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(.3f)
)
}

@Composable
fun Code39(){
val painter = rememberCode39Painter(
data = "WIKIPEDIA"
)

Image(
painter = painter,
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(.3f)
)
}

@Composable
fun Code93(){
val painter = rememberCode93Painter(
data = "TEST123"
)

Image(
painter = painter,
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(.3f)
.padding(30.dp)
)
}


@Composable
fun Code128(){
val painter = rememberCode128Painter(
data = "test",
brush = Brush.horizontalGradient(0f to Color.Red, 1f to Color.Blue)
)

Image(
painter = painter,
contentDescription = null,
modifier = Modifier
.size(350.dp)
.padding(10.dp)
)
}

@OptIn(ExperimentalResourceApi::class)
@Composable
fun QrCode(){
var text by remember {
mutableStateOf("https://github.com/alexzhirkevich/qrose")
}

val bg = painterResource("jcbg.png")
val bg = painterResource(Res.drawable.jcbg)

val logo = painterResource("jc.png")
val logo = painterResource(Res.drawable.jc)

val painter = rememberQrCodePainter(text) {
logo {
Expand Down Expand Up @@ -113,8 +200,8 @@ fun App() {
@OptIn(DelicateQRoseApi::class)
@Composable
fun JetpackCompose(data : String) : Painter {
val bg = painterResource("jcbg.png")
val logo = painterResource("jc.png")
val bg = painterResource(Res.drawable.jcbg)
val logo = painterResource(Res.drawable.jc)

return rememberQrCodePainter(data) {
fourEyed = true
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ kotlin.mpp.androidSourceSetLayoutVersion=2

org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.wasm.enabled=true

android.compileSdk=34
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
kotlin="1.9.10"
kotlin="1.9.22"
dokka="1.9.0"
compose="1.5.10"
compose="1.6.0"
androidGradlePlugin = "8.1.1"
qrose = "1.0.0-beta02"
qrose = "1.0.0"

[plugins]
compose = { id = "org.jetbrains.compose", version.ref = "compose" }
Expand Down
Loading

0 comments on commit 63cca29

Please sign in to comment.