-
-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #945 from mikepenz/develop
dev -> main
- Loading branch information
Showing
35 changed files
with
1,318 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
2
aboutlibraries-compose-m3/src/androidMain/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest /> |
128 changes: 128 additions & 0 deletions
128
...e-m3/src/androidMain/kotlin/com/mikepenz/aboutlibraries/ui/compose/m3/AndroidLibraries.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.