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

Bump to compose 1.8 #22

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 2 commits into from
Jan 23, 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
8 changes: 8 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
`kotlin-dsl`
}
Expand All @@ -25,6 +27,12 @@ java {
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}

dependencies {
implementation(libs.jetbrains.compose.gradlePlugin)
implementation(libs.kotlin.gradlePlugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun org.gradle.api.Project.androidConfiguration(
extension: CommonExtension<*, *, *, *, *, *>
) = extension.apply {
namespace = "com.tunjid.composables.${project.name}"
compileSdk = 34
compileSdk = 35

defaultConfig {
minSdk = 23
Expand All @@ -58,16 +58,6 @@ fun org.gradle.api.Project.androidConfiguration(
configureKotlinJvm()
}

fun org.gradle.api.Project.coerceComposeVersion(configuration: Configuration) {
val independentGroups = setOf("compiler", "material3")
configuration.resolutionStrategy.eachDependency {
if (requested.group.startsWith("androidx.compose") && independentGroups.none(requested.group::contains)) {
useVersion(versionCatalog.findVersion("androidxCompose").get().requiredVersion)
because("I need the changes in lazyGrid")
}
}
}

val org.gradle.api.Project.versionCatalog
get() = extensions.getByType(VersionCatalogsExtension::class.java)
.named("libs")
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ android {
defaultConfig {
targetSdk = 33
}
configurations.all {
coerceComposeVersion(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,4 @@ android {
}
}
}
configurations.all {
coerceComposeVersion(this)
}
}
46 changes: 24 additions & 22 deletions build-logic/convention/src/main/kotlin/kotlin-jvm-convention.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.gradle.api.JavaVersion
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/*
Expand Down Expand Up @@ -57,29 +57,31 @@ internal fun org.gradle.api.Project.configureKotlinJvm() {
private fun org.gradle.api.Project.configureKotlin() {
// Use withType to workaround https://youtrack.jetbrains.com/issue/KT-55947
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
compilerOptions {
// Set JVM target to 11
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"
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"
)
)
}
}
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"
)
})
}
// 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,7 +38,7 @@ plugins {
}

kotlin {
android()
androidTarget()
jvm("desktop")
// js(IR) {
// browser()
Expand All @@ -65,9 +65,6 @@ kotlin {
}
}
configureKotlinJvm()
configurations.all {
coerceComposeVersion(this)
}
}

// a temporary workaround for a bug in jsRun invocation - see https://youtrack.jetbrains.com/issue/KT-48273
Expand Down
14 changes: 8 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
[versions]
androidGradlePlugin = "8.5.2"
androidxActivity = "1.9.2"
activity-compose = "1.9.2"
activity-compose = "1.10.0"
androidxAppCompat = "1.7.0"
androidxBenchmark = "1.3.3"
androidxCore = "1.13.1"
androidxCore = "1.15.0"
androidxCollection = "1.5.0-beta02"
androidxCompose = "1.7.0"
androidxPaging = "3.3.2"
androidxTestCore = "1.6.1"
androidxTestExt = "1.2.1"
androidxTestRunner = "1.6.2"
androidxTestRules = "1.6.1"
dokka = "1.8.20"
jetbrainsCompose = "1.7.1"
jetbrainsCompose = "1.8.0-alpha02"
jetbrainsLifecycle = "2.8.4"
jetbrainsMaterial3Adaptive = "1.0.0"
jetbrainsMaterial3Adaptive = "1.0.1"
junit4 = "4.13.2"
kotlin = "2.0.21"
kotlin = "2.1.0"
kotlinxCoroutines = "1.9.0"
kotlinxDatetime = "0.6.1"
lifecycle-runtime = "2.8.6"
tunjidStateHolder = "1.1.0"
tunjidComposables = "0.0.11"
tunjidComposables = "0.0.14"
junit = "4.13.2"
runner = "1.0.2"
espressoCore = "3.0.2"
Expand All @@ -34,6 +35,7 @@ compose-compiler-plugin = { group = "org.jetbrains.kotlin", name = "compose-comp
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" }
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" }
Expand Down
2 changes: 2 additions & 0 deletions library/compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ kotlin {
dependencies {
implementation(project(":library:treenav"))

implementation(libs.androidx.collection)

implementation(libs.jetbrains.compose.runtime)
implementation(libs.jetbrains.compose.foundation)
implementation(libs.jetbrains.compose.foundation.layout)
Expand Down
6 changes: 3 additions & 3 deletions libraryVersion.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# limitations under the License.
#
groupId=com.tunjid.treenav
treenav_version=0.0.12
strings_version=0.0.12
compose_version=0.0.12
treenav_version=0.0.13a
strings_version=0.0.13a
compose_version=0.0.13a
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.tunjid.demo.common.ui


import androidx.compose.animation.splineBasedDecay
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.statusBars
import androidx.compose.material.icons.Icons
Expand All @@ -29,30 +28,26 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.tunjid.composables.collapsingheader.CollapsingHeaderState
import com.tunjid.composables.collapsingheader.rememberCollapsingHeaderState

@Composable
fun rememberAppBarCollapsingHeaderState(
expandedHeight: Dp
): CollapsingHeaderState {
val density = LocalDensity.current
val collapsedHeight = with(density) { 56.dp.toPx() } +
WindowInsets.statusBars.getTop(density).toFloat() +
WindowInsets.statusBars.getBottom(density).toFloat()

return remember {
CollapsingHeaderState(
collapsedHeight = collapsedHeight,
initialExpandedHeight = with(density) { expandedHeight.toPx() },
decayAnimationSpec = splineBasedDecay(density)
)
}
val statusBars = WindowInsets.statusBars
return rememberCollapsingHeaderState(
collapsedHeight = {
56.dp.toPx() +
statusBars.getTop(this).toFloat() +
statusBars.getBottom(this).toFloat()
},
initialExpandedHeight = { expandedHeight.toPx() }
)
}

@OptIn(ExperimentalMaterial3Api::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,6 @@ fun App(
.fillMaxSize(),
state = appState.rememberPanedNavHostState {
this
.paneModifierConfiguration {
if (paneState.pane == ThreePane.TransientPrimary) Modifier
.fillMaxSize()
.backPreview(appState.backPreviewState)
.background(backPreviewSurfaceColor, RoundedCornerShape(16.dp))
else Modifier
.fillMaxSize()
}
.threePanedNavHostConfiguration(
windowWidthState = derivedStateOf {
appState.splitLayoutState.size
Expand Down Expand Up @@ -169,6 +161,14 @@ fun App(
}
}
)
.paneModifierConfiguration {
if (paneState.pane == ThreePane.TransientPrimary) Modifier
.fillMaxSize()
.backPreview(appState.backPreviewState)
.background(backPreviewSurfaceColor, RoundedCornerShape(16.dp))
else Modifier
.fillMaxSize()
}
},
) {
val filteredPaneOrder by remember {
Expand Down
Loading
Loading