Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev -> main #942

Merged
merged 10 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:

steps:
- name: Checkout the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: |
Expand Down Expand Up @@ -103,11 +103,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 100

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: |
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
find . -name "*-release.aab" -type f -exec cp {} "artifacts" \;

- name: Archive Artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "App-Artifacts"
path: artifacts/*
Expand All @@ -197,7 +197,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release
uses: mikepenz/action-gh-release@v0.2.0-a03
uses: mikepenz/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
body: ${{steps.github_release.outputs.changelog}}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/gradle-dependency-submission.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
contents: write
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: |
Expand All @@ -36,7 +36,7 @@ jobs:
gradle-${{ runner.os }}-

- name: Submit Dependency Graph
uses: mikepenz/gradle-dependency-submission@v0.8.3
uses: mikepenz/gradle-dependency-submission@v0.9.1
with:
gradle-build-module: |-
:app
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

## Latest releases 🛠

- (Next Gen) Kotlin && Multiplatform && Plugin | [v10.9.2](https://github.com/mikepenz/AboutLibraries/tree/v10.9.2)
- (Next Gen) Kotlin && Multiplatform && Plugin | [v10.10.0-rc01](https://github.com/mikepenz/AboutLibraries/tree/v10.10.0-rc01)
- Kotlin && Gradle Plugin | [v8.9.4](https://github.com/mikepenz/AboutLibraries/tree/v8.9.4)

## Gradle Plugin
Expand Down
30 changes: 20 additions & 10 deletions aboutlibraries-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@file:OptIn(ExperimentalWasmDsl::class)

import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
Expand Down Expand Up @@ -37,13 +40,13 @@ android {
if (project.findProperty("composeCompilerReports") == "true") {
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${project.buildDir.absolutePath}/compose_compiler"
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${project.layout.buildDirectory.asFile.get().absolutePath}/compose_compiler"
)
}
if (project.findProperty("composeCompilerMetrics") == "true") {
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${project.buildDir.absolutePath}/compose_compiler"
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${project.layout.buildDirectory.asFile.get().absolutePath}/compose_compiler"
)
}
}
Expand All @@ -69,7 +72,7 @@ compose {
}

kotlin {
targetHierarchy.default()
applyDefaultHierarchyTemplate()

jvm()

Expand All @@ -82,22 +85,27 @@ kotlin {
iosSimulatorArm64()
macosX64()
macosArm64()
wasmJs {
nodejs()
}

sourceSets {
val commonMain by getting
val commonMain by getting {
dependencies {
implementation(compose.runtime)
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material)
implementation(libs.kotlinx.collections)
}
}
val commonTest by getting
}
}

dependencies {
commonMainApi(project(":aboutlibraries-core"))

commonMainImplementation(compose.runtime)
commonMainImplementation(compose.ui)
commonMainImplementation(compose.foundation)
commonMainImplementation(compose.material)
commonMainImplementation(libs.kotlinx.collections)

debugImplementation(compose.uiTooling)
"androidMainImplementation"(compose.preview)

Expand All @@ -109,6 +117,8 @@ configurations.configureEach {
// https://github.com/chrisbanes/tivi/blob/5e7586465337d326a1f1e40e0b412ecd2779bb5c/build.gradle#L72
exclude(group = "androidx.appcompat")
exclude(group = "com.google.android.material", module = "material")


}

tasks.dokkaHtml.configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.mikepenz.aboutlibraries.entity.Library
import com.mikepenz.aboutlibraries.ui.compose.util.StableLibrary
import com.mikepenz.aboutlibraries.ui.compose.util.StableLibs
import com.mikepenz.aboutlibraries.ui.compose.util.author
import com.mikepenz.aboutlibraries.ui.compose.util.htmlReadyLicenseContent
import com.mikepenz.aboutlibraries.ui.compose.util.stable
import com.mikepenz.aboutlibraries.ui.compose.util.*
import kotlinx.collections.immutable.ImmutableList


Expand Down Expand Up @@ -73,7 +69,13 @@ fun LibrariesContainer(
} else if (!license?.htmlReadyLicenseContent.isNullOrBlank()) {
openDialog.value = library
} else if (!license?.url.isNullOrBlank()) {
license?.url?.also { uriHandler.openUri(it) }
license?.url?.also {
try {
uriHandler.openUri(it)
} catch (t: Throwable) {
println("Failed to open url: ${it}")
}
}
}
},
)
Expand All @@ -96,7 +98,7 @@ fun LicenseDialog(
onDismiss: () -> Unit,
) {
val scrollState = rememberScrollState()

Dialog(
onDismissRequest = onDismiss,
properties = DialogProperties(),
Expand Down Expand Up @@ -173,7 +175,13 @@ fun Libraries(
if (onLibraryClick != null) {
onLibraryClick.invoke(library)
} else if (!license?.url.isNullOrBlank()) {
license?.url?.also { uriHandler.openUri(it) }
license?.url?.also {
try {
uriHandler.openUri(it)
} catch (t: Throwable) {
println("Failed to open url: ${it}")
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions aboutlibraries-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
}

kotlin {
targetHierarchy.default()
applyDefaultHierarchyTemplate()

jvm()
js(IR) {
Expand All @@ -54,7 +54,7 @@ kotlin {
androidTarget {
publishAllLibraryVariants()
}
wasm {
wasmJs {
nodejs()
}

Expand Down
13 changes: 13 additions & 0 deletions app-wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Usage

### Generate Dependency Information

```bash
./gradlew app-wasm:exportLibraryDefinitions -PaboutLibraries.exportPath=src/wasmJsMain/resources/
```

### Run Wasm app

```
./gradlew :app-wasm:wasmJsRun
```
66 changes: 66 additions & 0 deletions app-wasm/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("com.mikepenz.aboutlibraries.plugin")
}

// val copyWasmResources = tasks.create("copyWasmResourcesWorkaround", Copy::class.java) {
// from(project(":shared").file("src/commonMain/resources"))
// into("build/processedResources/wasm/main")
// }
//
// afterEvaluate {
// project.tasks.getByName("wasmProcessResources").finalizedBy(copyWasmResources)
// }

kotlin {
wasmJs {
moduleName = "aboutlibraries"
browser {
commonWebpackConfig {
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).copy(
open = mapOf(
"app" to mapOf(
"name" to "google chrome canary",
"arguments" to listOf("--js-flags=--experimental-wasm-gc ")
)
),
static = (devServer?.static ?: mutableListOf()).apply {
add(project.rootDir.path)
add(project.rootDir.path + "/common/")
add(project.rootDir.path + "/nonAndroidMain/")
add(project.rootDir.path + "/web/")
},
)
}
}
binaries.executable()
}

sourceSets {
val wasmJsMain by getting {
dependencies {
implementation(compose.runtime)
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)

implementation(project(":aboutlibraries-core"))
implementation(project(":aboutlibraries-compose"))
}
}
}
}

compose.experimental {
web.application {}
}

compose {
kotlinCompilerPlugin.set(libs.versions.composeCompilerJb.get())
// kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=${libs.versions.kotlinCore.get()}")
}
8 changes: 8 additions & 0 deletions app-wasm/src/wasmJsMain/kotlin/Color.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import androidx.compose.ui.graphics.Color

val Green = Color(0xff09B3AF)
val GreenDark = Color(0xff008380)
val GreenLight = Color(0x5de6e1)

val Red200 = Color(0xfff297a2)
val Red800 = Color(0xffd00036)
40 changes: 40 additions & 0 deletions app-wasm/src/wasmJsMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.produceState
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.window.CanvasBasedWindow
import com.mikepenz.aboutlibraries.Libs
import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer
import com.mikepenz.aboutlibraries.ui.compose.util.StableLibs
import com.mikepenz.aboutlibraries.ui.compose.util.stable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.resource

@OptIn(ExperimentalComposeUiApi::class, ExperimentalResourceApi::class)
fun main() {
CanvasBasedWindow("AboutLibraries", canvasElementId = "aboutLibsCanvas") {
SampleTheme {
Scaffold(
topBar = { TopAppBar(title = { Text("AboutLibraries Compose Desktop Sample") }) }
) {
val libraries = produceState<StableLibs?>(null) {
value = withContext(Dispatchers.Default) {
Libs.Builder()
.withJson(resource("aboutlibraries.json").readBytes().decodeToString())
.build().stable
}
}

LibrariesContainer(
libraries.value,
Modifier.fillMaxSize()
)
}
}
}
}
42 changes: 42 additions & 0 deletions app-wasm/src/wasmJsMain/kotlin/Theme.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

private val DarkColorPalette = darkColors(
primary = Green,
primaryVariant = GreenDark,
onPrimary = Color.White,
secondary = Green,
onSecondary = Color.White,
error = Red200
)

private val LightColorPalette = lightColors(
primary = Green,
primaryVariant = GreenDark,
onPrimary = Color.White,
secondary = Green,
secondaryVariant = GreenDark,
onSecondary = Color.White,
error = Red800
)

@Composable
fun SampleTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable() () -> Unit,
) {
val colors = if (darkTheme) {
DarkColorPalette
} else {
LightColorPalette
}

MaterialTheme(
colors = colors,
content = content
)
}
1 change: 1 addition & 0 deletions app-wasm/src/wasmJsMain/resources/aboutlibraries.json

Large diffs are not rendered by default.

Loading
Loading