这是indexloc提供的服务,不要输入任何密码
Skip to content

Add PaneMovableElementSharedTransitionScope #29

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

Merged
merged 11 commits into from
May 4, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,13 @@ import org.gradle.api.artifacts.VersionCatalogsExtension
fun org.gradle.api.Project.androidConfiguration(
extension: CommonExtension<*, *, *, *, *, *>
) = extension.apply {
namespace = "com.tunjid.composables.${project.name}"
compileSdk = 35
namespace = "com.tunjid.treenav.${project.name.replace("-", ".")}"
compileSdk = 36

defaultConfig {
minSdk = 23
}

buildFeatures {
compose = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand Down
23 changes: 5 additions & 18 deletions build-logic/convention/src/main/kotlin/kotlin-jvm-convention.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,13 @@ private fun org.gradle.api.Project.configureKotlin() {
jvmTarget.set(JvmTarget.JVM_11)
freeCompilerArgs.set(
freeCompilerArgs.get() + listOf(
"-Xuse-experimental=androidx.compose.animation.ExperimentalAnimationApi",
"-Xuse-experimental=androidx.compose.material.ExperimentalMaterialApi",
"-Xuse-experimental=kotlinx.serialization.ExperimentalSerializationApi",
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlinx.coroutines.FlowPreview"
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
"-opt-in=androidx.compose.material.ExperimentalMaterialApi",
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview"
)
)
}
}
// val kotlinOptions = "kotlinOptions"
// if (extensions.findByName(kotlinOptions) != null) {
// extensions.configure(kotlinOptions, Action<KotlinJvmOptions> {
// jvmTarget = JavaVersion.VERSION_11.toString()
// freeCompilerArgs = freeCompilerArgs + listOf(
// "-Xuse-experimental=androidx.compose.animation.ExperimentalAnimationApi",
// "-Xuse-experimental=androidx.compose.material.ExperimentalMaterialApi",
// "-Xuse-experimental=kotlinx.serialization.ExperimentalSerializationApi",
// "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
// "-Xuse-experimental=kotlinx.coroutines.FlowPreview"
// )
// })
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,25 @@ plugins {
}

kotlin {
androidTarget()
jvm("desktop")
// js(IR) {
// browser()
// nodejs()
// binaries.executable()
// }
applyDefaultHierarchyTemplate()
androidTarget {
publishLibraryVariants("release")
}
jvm {
testRuns["test"].executionTask.configure {
useJUnit()
}
}
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = project.name
isStatic = true
}
}
sourceSets {
all {
languageSettings.apply {
Expand All @@ -58,28 +70,6 @@ kotlin {
}
}
}

targets.withType(KotlinNativeTarget::class.java) {
binaries.all {
binaryOptions["memoryModel"] = "experimental"
}
}
configureKotlinJvm()
}

// a temporary workaround for a bug in jsRun invocation - see https://youtrack.jetbrains.com/issue/KT-48273
afterEvaluate {
rootProject.extensions.configure<NodeJsRootExtension> {
versions.webpackDevServer.version = "4.0.0"
versions.webpackCli.version = "4.10.0"
nodeVersion = "16.0.0"
}
}


// TODO: remove when https://youtrack.jetbrains.com/issue/KT-50778 fixed
project.tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile::class.java).configureEach {
kotlinOptions.freeCompilerArgs += listOf(
"-Xir-dce-runtime-diagnostic=log"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ publishing {
artifact(javadocJar)
pom {
name.set(project.name)
description.set("A collection of utility composable functions")
url.set("https://github.com/tunjid/composables")
description.set("A kotlin multiplatform experiment for representing app navigation with tree like data structures")
url.set("https://github.com/tunjid/treenav")
licenses {
license {
name.set("Apache License 2.0")
url.set("https://github.com/tunjid/composables/blob/main/LICENSE")
url.set("https://github.com/tunjid/treenav/blob/main/LICENSE.txt")
}
}
developers {
Expand All @@ -73,9 +73,9 @@ publishing {
}
}
scm {
connection.set("scm:git:github.com/tunjid/composables.git")
developerConnection.set("scm:git:ssh://github.com/tunjid/composables.git")
url.set("https://github.com/tunjid/composables/tree/main")
connection.set("scm:git:github.com/tunjid/treenav.git")
developerConnection.set("scm:git:ssh://github.com/tunjid/treenav.git")
url.set("https://github.com/tunjid/treenav/tree/main")
}
}
}
Expand Down
22 changes: 1 addition & 21 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
androidGradlePlugin = "8.9.2"
androidxActivity = "1.9.2"
activity-compose = "1.10.1"
activity-compose = "1.11.0-rc01"
androidxAppCompat = "1.7.0"
androidxBenchmark = "1.3.4"
androidxCore = "1.16.0"
Expand Down Expand Up @@ -39,26 +39,6 @@ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
androidx-collection = { group = "androidx.collection", name = "collection", version.ref = "androidxCollection" }
androidx-compose-animation = { group = "androidx.compose.animation", name = "animation" }
androidx-compose-foundation-foundation = { group = "androidx.compose.foundation", name = "foundation" }
androidx-compose-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout" }
androidx-compose-material-core = { group = "androidx.compose.material", name = "material" }
androidx-compose-material-iconsExtended = { group = "androidx.compose.material", name = "material-icons-extended" }
androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime" }
androidx-compose-ui-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-compose-ui-platform = { group = "androidx.compose.ui", name = "ui-platform" }
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-compose-material3-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-compose-material3-adaptive = { group = "androidx.compose.material3.adaptive", name = "adaptive" }
androidx-compose-material3-adaptive-layout = { group = "androidx.compose.material3.adaptive", name = "adaptive-layout" }
androidx-compose-material3-adaptive-navigation = { group = "androidx.compose.material3.adaptive", name = "adaptive-navigation" }
androidx-compose-material3-windowSizeClass = { group = "androidx.compose.material3", name = "material3-window-size-class" }
androidx-savedstate-savedstate = { group = "androidx.compose.savedstate", name = "savedstate", version.ref = "androidxSavedState" }
androidx-savedstate-compose = { group = "androidx.compose.savedstate", name = "savedstate-compose", version.ref = "androidxSavedState" }

jetbrains-compose-animation = { group = "org.jetbrains.compose.animation", name = "animation", version.ref = "jetbrainsCompose" }
jetbrains-compose-foundation = { group = "org.jetbrains.compose.foundation", name = "foundation", version.ref = "jetbrainsCompose" }
Expand Down
1 change: 1 addition & 0 deletions library/compose-threepane/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
34 changes: 34 additions & 0 deletions library/compose-threepane/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
kotlin("multiplatform")
id("publishing-library-convention")
id("android-library-convention")
id("kotlin-jvm-convention")
id("kotlin-library-convention")
id("maven-publish")
signing
id("org.jetbrains.dokka")
id("org.jetbrains.compose")
alias(libs.plugins.compose.compiler)
}

android {
buildFeatures {
compose = true
}
}

kotlin {
sourceSets {
commonMain {
dependencies {
implementation(project(":library:treenav"))
implementation(project(":library:compose"))

implementation(libs.jetbrains.compose.runtime)
implementation(libs.jetbrains.compose.foundation)
implementation(libs.jetbrains.compose.foundation.layout)
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tunjid.treenav.compose.threepane

import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import com.tunjid.treenav.Node
import com.tunjid.treenav.compose.PaneScope
import com.tunjid.treenav.compose.PaneSharedTransitionScope
import com.tunjid.treenav.compose.moveablesharedelement.MovableSharedElementScope
import com.tunjid.treenav.compose.threepane.transforms.requireMovableSharedElementScope

/**
* An interface providing both [MovableSharedElementScope] and [PaneSharedTransitionScope] for
* a [ThreePane] layout.
*/
@Stable
interface PaneMovableElementSharedTransitionScope<Destination : Node> :
PaneSharedTransitionScope<ThreePane, Destination>, MovableSharedElementScope

/**
* Remembers a [PaneMovableElementSharedTransitionScope] in the composition.
*
* @param movableSharedElementScope The [MovableSharedElementScope] used create a
* [PaneSharedTransitionScope] for this [PaneScope].
*
* If one is not provided, one is retrieved from this [PaneScope] using
* [requireMovableSharedElementScope].
*/
@OptIn(ExperimentalSharedTransitionApi::class)
@Composable
fun <Destination : Node> PaneScope<
ThreePane,
Destination
>.rememberPaneMovableElementSharedTransitionScope(
movableSharedElementScope: MovableSharedElementScope = requireMovableSharedElementScope()
): PaneMovableElementSharedTransitionScope<Destination> {
val paneSharedTransitionScope = rememberPaneSharedTransitionScope(
movableSharedElementScope.sharedTransitionScope
)
return remember {
DelegatingPaneMovableElementSharedTransitionScope(
paneSharedTransitionScope = paneSharedTransitionScope,
movableSharedElementScope = movableSharedElementScope,
)
}
}

@Stable
private class DelegatingPaneMovableElementSharedTransitionScope<Destination : Node>(
val paneSharedTransitionScope: PaneSharedTransitionScope<ThreePane, Destination>,
val movableSharedElementScope: MovableSharedElementScope,
) : PaneMovableElementSharedTransitionScope<Destination>,
PaneSharedTransitionScope<ThreePane, Destination> by paneSharedTransitionScope,
MovableSharedElementScope by movableSharedElementScope

Loading