Skip to content

Commit

Permalink
Merge pull request #945 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored Dec 31, 2023
2 parents 8b806e6 + 1a849d2 commit e044cb7
Show file tree
Hide file tree
Showing 35 changed files with 1,318 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ jobs:
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
run: |
./gradlew aboutlibraries-core:publishAllPublicationsToMavenCentralRepository --no-daemon -Plibrary_core_only --no-configure-on-demand --no-parallel
./gradlew aboutlibraries-compose:publishAllPublicationsToMavenCentralRepository -x test -x lint -Plibrary_compose_only --no-configure-on-demand --no-parallel
./gradlew aboutlibraries-compose-m2:publishAllPublicationsToMavenCentralRepository -x test -x lint -Plibrary_compose_only --no-configure-on-demand --no-parallel
./gradlew aboutlibraries-compose-m3:publishAllPublicationsToMavenCentralRepository -x test -x lint -Plibrary_compose_m3_only --no-configure-on-demand --no-parallel
- name: Publish the windows artifact
if: matrix.os == 'windows-latest'
Expand Down
5 changes: 4 additions & 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.10.0-rc02](https://github.com/mikepenz/AboutLibraries/tree/v10.10.0-rc02)
- (Next Gen) Kotlin && Multiplatform && Plugin | [v10.10.0](https://github.com/mikepenz/AboutLibraries/tree/v10.10.0)
- Kotlin && Gradle Plugin | [v8.9.4](https://github.com/mikepenz/AboutLibraries/tree/v8.9.4)

## Gradle Plugin
Expand Down Expand Up @@ -214,6 +214,9 @@ for (lib in libraries) {

```gradle
implementation "com.mikepenz:aboutlibraries-compose:${latestAboutLibsRelease}"
// Alternative Material3 based module
implementation "com.mikepenz:aboutlibraries-compose-m3:${latestAboutLibsRelease}"
```

### Usage
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions aboutlibraries-compose-m3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
142 changes: 142 additions & 0 deletions aboutlibraries-compose-m3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
@file:OptIn(ExperimentalWasmDsl::class)

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

plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose")
id("org.jetbrains.dokka")
id("com.vanniktech.maven.publish")
}

android {
compileSdk = libs.versions.compileSdk.get().toInt()
namespace = "com.mikepenz.aboutlibraries.ui.compose.m3"

defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "11"

kotlinOptions {
if (project.findProperty("composeCompilerReports") == "true") {
freeCompilerArgs += listOf(
"-P",
"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.layout.buildDirectory.asFile.get().absolutePath}/compose_compiler"
)
}
}
}

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}

lint {
abortOnError = false
}
}


compose {
//kotlinCompilerPlugin.set("androidx.compose.compiler:compiler")
//kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=${libs.versions.kotlinCore.get()}")
}

kotlin {
applyDefaultHierarchyTemplate()

jvm()

androidTarget {
publishLibraryVariants("release")
}

js(IR) {
browser()
}

iosX64()
iosArm64()
iosSimulatorArm64()
macosX64()
macosArm64()
wasmJs {
nodejs()
}

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

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

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

"androidMainImplementation"(libs.androidx.core.ktx)
}

configurations.configureEach {
// We forcefully exclude AppCompat + MDC from any transitive dependencies. This is a Compose module, so there's no need for these
// https://github.com/chrisbanes/tivi/blob/5e7586465337d326a1f1e40e0b412ecd2779bb5c/build.gradle#L72
exclude(group = "androidx.appcompat")
exclude(group = "com.google.android.material", module = "material")
exclude(group = "com.google.android.material", module = "material3")
}

tasks.dokkaHtml.configure {
dokkaSourceSets {
configureEach {
noAndroidSdkLink.set(false)
}
}
}



if (project.hasProperty("pushall") || project.hasProperty("library_compose_m3_only")) {
mavenPublishing {
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()
}
}
3 changes: 3 additions & 0 deletions aboutlibraries-compose-m3/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_NAME=AboutLibraries Library
POM_DESCRIPTION=AboutLibraries automatically detects all dependencies of a project and collects their information including the license. Optionally visualising it via the provided ui components.
POM_ARTIFACT_ID=aboutlibraries-compose-m3
2 changes: 2 additions & 0 deletions aboutlibraries-compose-m3/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package com.mikepenz.aboutlibraries.ui.compose.m3

import android.content.Context
import android.widget.TextView
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.produceState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.text.HtmlCompat
import com.mikepenz.aboutlibraries.Libs
import com.mikepenz.aboutlibraries.ui.compose.m3.data.fakeData
import com.mikepenz.aboutlibraries.ui.compose.m3.util.StableLibrary
import com.mikepenz.aboutlibraries.ui.compose.m3.util.htmlReadyLicenseContent
import com.mikepenz.aboutlibraries.ui.compose.m3.util.stable
import com.mikepenz.aboutlibraries.util.withContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

/**
* Displays all provided libraries in a simple list.
*/
@Composable
fun LibrariesContainer(
modifier: Modifier = Modifier,
librariesBlock: (Context) -> Libs = { context ->
Libs.Builder().withContext(context).build()
},
lazyListState: LazyListState = rememberLazyListState(),
contentPadding: PaddingValues = PaddingValues(0.dp),
showAuthor: Boolean = true,
showVersion: Boolean = true,
showLicenseBadges: Boolean = true,
colors: LibraryColors = LibraryDefaults.libraryColors(),
padding: LibraryPadding = LibraryDefaults.libraryPadding(),
itemContentPadding: PaddingValues = LibraryDefaults.ContentPadding,
itemSpacing: Dp = LibraryDefaults.LibraryItemSpacing,
header: (LazyListScope.() -> Unit)? = null,
onLibraryClick: ((StableLibrary) -> Unit)? = null,
) {
val context = LocalContext.current

val libraries = produceState<Libs?>(null) {
value = withContext(Dispatchers.IO) {
librariesBlock(context)
}
}
LibrariesContainer(
libraries.value?.stable,
modifier,
lazyListState,
contentPadding,
showAuthor,
showVersion,
showLicenseBadges,
colors,
padding,
itemContentPadding,
itemSpacing,
header,
onLibraryClick,
licenseDialogBody = { library ->
HtmlText(
html = library.library.licenses.firstOrNull()?.htmlReadyLicenseContent.orEmpty(),
color = colors.contentColor,
)
}
)
}

@Composable
fun HtmlText(
html: String,
modifier: Modifier = Modifier,
color: Color = LibraryDefaults.libraryColors().contentColor,
) {
AndroidView(modifier = modifier, factory = { context ->
TextView(context).apply {
setTextColor(color.toArgb())
}
}, update = { it.text = HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_COMPACT) })
}

@Preview("Library items (Default)")
@Composable
fun PreviewLibraries() {
MaterialTheme {
Surface {
Libraries(fakeData.libraries.stable)
}
}
}


@Preview("Library items (Off)")
@Composable
fun PreviewLibrariesOff() {
MaterialTheme {
Surface {
Libraries(fakeData.libraries.stable, showAuthor = false, showLicenseBadges = false)
}
}
}

@Preview("Library item")
@Composable
fun PreviewLibrary() {
MaterialTheme {
Surface {
Library(
fakeData.libraries.first().stable
) {
// on-click
}
}
}
}
Loading

0 comments on commit e044cb7

Please sign in to comment.