mirror of
https://github.com/AdrianKuta/Tree-Data-Structure.git
synced 2026-06-19 19:00:14 +02:00
Add the `android` target to the Compose Multiplatform library and a sensible
default renderer, so the largest Compose audience is a first-class consumer.
- Core `tree-structure` and `tree-structure-compose` now build and publish an
`-android` variant (compileSdk 35, minSdk 21). The core needs it too: its
inline `tree { }` DSL is built per target, and Android consumers (JVM 11/17)
cannot inline a JVM-21 build.
- `TreeNodeRow`: a foundation-only default node row (clickable, indented, with a
`▾`/`▸` marker, no Material dependency), plus a no-content `LazyTree(root,
label = …)` overload that uses it. The existing lambda overload is unchanged.
- New `samples` Android app module demonstrating `LazyTree` + `@Preview`
(not published; excluded from API validation).
- Toolchain: Gradle wrapper 8.5 -> 8.10.2, Android Gradle Plugin 8.7.2.
- binary-compatibility-validator now emits per-target dumps (api/jvm, api/android)
for the two multi-JVM-target modules; CI assembles the Android outputs.
This commit is contained in:
48
samples-android/build.gradle.kts
Normal file
48
samples-android/build.gradle.kts
Normal file
@@ -0,0 +1,48 @@
|
||||
plugins {
|
||||
alias(libs.plugins.androidApplication)
|
||||
alias(libs.plugins.kotlinAndroid)
|
||||
alias(libs.plugins.composeMultiplatform)
|
||||
alias(libs.plugins.composeCompiler)
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(21)
|
||||
// Match the Kotlin bytecode target to the Java level in android.compileOptions below.
|
||||
compilerOptions {
|
||||
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.github.adriankuta.treestructure.sample"
|
||||
compileSdk = libs.versions.androidCompileSdk.get().toInt()
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.github.adriankuta.treestructure.sample"
|
||||
minSdk = libs.versions.androidMinSdk.get().toInt()
|
||||
targetSdk = libs.versions.androidCompileSdk.get().toInt()
|
||||
versionCode = 1
|
||||
versionName = rootProject.version.toString()
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":"))
|
||||
implementation(project(":tree-structure-compose"))
|
||||
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.material3)
|
||||
implementation(compose.components.uiToolingPreview)
|
||||
implementation(libs.androidx.activity.compose)
|
||||
debugImplementation(compose.uiTooling)
|
||||
}
|
||||
18
samples-android/src/main/AndroidManifest.xml
Normal file
18
samples-android/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:label="Tree Sample"
|
||||
android:theme="@android:style/Theme.Material.Light.NoActionBar">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.github.adriankuta.treestructure.sample
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.github.adriankuta.datastructure.tree.TreeNode
|
||||
import com.github.adriankuta.datastructure.tree.compose.LazyTree
|
||||
import com.github.adriankuta.datastructure.tree.compose.TreeNodeRow
|
||||
import com.github.adriankuta.datastructure.tree.tree
|
||||
import org.jetbrains.compose.ui.tooling.preview.Preview
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
MaterialTheme {
|
||||
Surface(modifier = Modifier.fillMaxSize()) {
|
||||
TreeSampleScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Renders the [sampleTree] with the library's default [TreeNodeRow] via the one-line [LazyTree]. */
|
||||
@Composable
|
||||
fun TreeSampleScreen() {
|
||||
LazyTree(sampleTree())
|
||||
}
|
||||
|
||||
private fun sampleTree(): TreeNode<String> = tree("World") {
|
||||
child("North America") {
|
||||
child("USA")
|
||||
child("Canada")
|
||||
}
|
||||
child("Europe") {
|
||||
child("Poland")
|
||||
child("Germany")
|
||||
child("Spain")
|
||||
}
|
||||
child("Asia") {
|
||||
child("Japan")
|
||||
child("India")
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun TreeSampleScreenPreview() {
|
||||
MaterialTheme {
|
||||
Surface {
|
||||
TreeSampleScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun TreeNodeRowPreview() {
|
||||
MaterialTheme {
|
||||
TreeNodeRow(
|
||||
node = TreeNode("Europe").apply { addChild(TreeNode("Poland")) },
|
||||
depth = 1,
|
||||
expanded = true,
|
||||
toggle = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user