diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index feaeba6..f51833c 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -14,6 +14,8 @@ * limitations under the License. */ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { `kotlin-dsl` } @@ -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) diff --git a/build-logic/convention/src/main/kotlin/android-app-library-convention.kt b/build-logic/convention/src/main/kotlin/android-app-library-convention.kt index a8a42d8..a124a5a 100644 --- a/build-logic/convention/src/main/kotlin/android-app-library-convention.kt +++ b/build-logic/convention/src/main/kotlin/android-app-library-convention.kt @@ -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 @@ -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") \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/android-application-convention.gradle.kts b/build-logic/convention/src/main/kotlin/android-application-convention.gradle.kts index 4a86a79..5caf597 100644 --- a/build-logic/convention/src/main/kotlin/android-application-convention.gradle.kts +++ b/build-logic/convention/src/main/kotlin/android-application-convention.gradle.kts @@ -24,7 +24,4 @@ android { defaultConfig { targetSdk = 33 } - configurations.all { - coerceComposeVersion(this) - } } \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/android-library-convention.gradle.kts b/build-logic/convention/src/main/kotlin/android-library-convention.gradle.kts index 00494ba..25762d6 100644 --- a/build-logic/convention/src/main/kotlin/android-library-convention.gradle.kts +++ b/build-logic/convention/src/main/kotlin/android-library-convention.gradle.kts @@ -30,7 +30,4 @@ android { } } } - configurations.all { - coerceComposeVersion(this) - } } \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/kotlin-jvm-convention.kt b/build-logic/convention/src/main/kotlin/kotlin-jvm-convention.kt index 74096e8..8e6d183 100644 --- a/build-logic/convention/src/main/kotlin/kotlin-jvm-convention.kt +++ b/build-logic/convention/src/main/kotlin/kotlin-jvm-convention.kt @@ -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 /* @@ -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().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 { - 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 { +// 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" +// ) +// }) +// } } \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/kotlin-library-convention.gradle.kts b/build-logic/convention/src/main/kotlin/kotlin-library-convention.gradle.kts index f1ac78d..608cc29 100644 --- a/build-logic/convention/src/main/kotlin/kotlin-library-convention.gradle.kts +++ b/build-logic/convention/src/main/kotlin/kotlin-library-convention.gradle.kts @@ -38,7 +38,7 @@ plugins { } kotlin { - android() + androidTarget() jvm("desktop") // js(IR) { // browser() @@ -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 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b74b4d3..8a22658 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,11 @@ [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" @@ -12,16 +13,16 @@ 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" @@ -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" } diff --git a/library/compose/build.gradle.kts b/library/compose/build.gradle.kts index e22400a..75b9b7d 100644 --- a/library/compose/build.gradle.kts +++ b/library/compose/build.gradle.kts @@ -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) diff --git a/libraryVersion.properties b/libraryVersion.properties index ca7f099..5522978 100644 --- a/libraryVersion.properties +++ b/libraryVersion.properties @@ -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 \ No newline at end of file +treenav_version=0.0.13a +strings_version=0.0.13a +compose_version=0.0.13a \ No newline at end of file diff --git a/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/AppBars.kt b/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/AppBars.kt index d1d71f4..ea490ce 100644 --- a/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/AppBars.kt +++ b/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/AppBars.kt @@ -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 @@ -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) diff --git a/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/DemoApp.kt b/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/DemoApp.kt index a0a61c9..fde1912 100644 --- a/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/DemoApp.kt +++ b/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/DemoApp.kt @@ -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 @@ -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 { diff --git a/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/data/AppData.kt b/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/data/AppData.kt index aa07cd4..344abb7 100644 --- a/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/data/AppData.kt +++ b/sample/common/src/commonMain/kotlin/com/tunjid/demo/common/ui/data/AppData.kt @@ -155,6 +155,311 @@ private val chatData = ChatData( content = "Count me in too!" ) ) + ), + "Project Updates" to ChatRoom( + name = "Project Updates", + messages = listOf( + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-06T09:00:00Z"), + content = "Good morning everyone! Just wanted to share a quick update on the project timeline." + ), + Message( + sender = "Aisha", + timestamp = Instant.parse("2024-10-06T09:05:00Z"), + content = "Thanks Diego! Looking forward to seeing the updated roadmap." + ), + Message( + sender = "Kenji", + timestamp = Instant.parse("2024-10-06T09:10:00Z"), + content = "Any news on the release date?" + ) + ) + ), + "Weekend Plans" to ChatRoom( + name = "Weekend Plans", + messages = listOf( + Message( + sender = "Bjorn", + timestamp = Instant.parse("2024-10-06T10:00:00Z"), + content = "Any fun plans for the weekend?" + ), + Message( + sender = "Lin", + timestamp = Instant.parse("2024-10-06T10:05:00Z"), + content = "I'm planning to go hiking!" + ), + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-06T10:10:00Z"), + content = "I'm going to a concert on Saturday night." + ) + ) + ), + "UI/UX Feedback" to ChatRoom( + name = "UI/UX Feedback", + messages = listOf( + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-07T11:00:00Z"), + content = "Hey team, I've got some initial designs for the chat UI. Any feedback?" + ), + Message( + sender = "Aisha", + timestamp = Instant.parse("2024-10-07T11:05:00Z"), + content = "Looks good! I think the message bubbles could be a bit bigger though." + ), + Message( + sender = "Bjorn", + timestamp = Instant.parse("2024-10-07T11:10:00Z"), + content = "Agreed, and maybe add some more whitespace between messages?" + ) + ) + ), + "Team Building" to ChatRoom( + name = "Team Building", + messages = listOf( + Message( + sender = "Kenji", + timestamp = Instant.parse("2024-10-07T14:00:00Z"), + content = "We should plan a team building activity soon!" + ), + Message( + sender = "Lin", + timestamp = Instant.parse("2024-10-07T14:05:00Z"), + content = "Great idea! How about bowling?" + ), + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-07T14:10:00Z"), + content = "Escape room?" + ) + ) + ), + "Bug Reports" to ChatRoom( + name = "Bug Reports", + messages = listOf( + Message( + sender = "Bjorn", + timestamp = Instant.parse("2024-10-08T10:00:00Z"), + content = "Found a bug in the message sending function. It crashes when sending a message with an empty string." + ), + Message( + sender = "Kenji", + timestamp = Instant.parse("2024-10-08T10:05:00Z"), + content = "Thanks for reporting! I'll take a look." + ) + ) + ), + "Feature Requests" to ChatRoom( + name = "Feature Requests", + messages = listOf( + Message( + sender = "Aisha", + timestamp = Instant.parse("2024-10-08T15:00:00Z"), + content = "It would be great to have a feature for sending voice messages." + ), + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-08T15:05:00Z"), + content = "Good idea! I'll add it to the roadmap." + ) + ) + ), + "Coffee Break" to ChatRoom( + name = "Coffee Break", + messages = listOf( + Message( + sender = "Lin", + timestamp = Instant.parse("2024-10-09T11:00:00Z"), + content = "Coffee break anyone?" + ), + Message( + sender = "Aisha", + timestamp = Instant.parse("2024-10-09T11:05:00Z"), + content = "I'm in!" + ) + ) + ), + "Funny Memes" to ChatRoom( + name = "Funny Memes", + messages = listOf( + Message( + sender = "Bjorn", + timestamp = Instant.parse("2024-10-09T16:00:00Z"), + content = "Check out this hilarious meme! [link to meme]" + ), + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-09T16:05:00Z"), + content = "LOL! That's a good one." + ) + ) + ), + "Productivity Tips" to ChatRoom( + name = "Productivity Tips", + messages = listOf( + Message( + sender = "Kenji", + timestamp = Instant.parse("2024-10-10T09:00:00Z"), + content = "Any tips for staying focused and productive?" + ), + Message( + sender = "Lin", + timestamp = Instant.parse("2024-10-10T09:05:00Z"), + content = "I use the Pomodoro Technique. It really helps!" + ) + ) + ), + "Travel Recommendations" to ChatRoom( // New chat room + name = "Travel Recommendations", + messages = listOf( + Message( + sender = "Aisha", + timestamp = Instant.parse("2024-10-10T11:00:00Z"), + content = "I'm planning a trip to Europe next month. Any recommendations?" + ), + Message( + sender = "Bjorn", + timestamp = Instant.parse("2024-10-10T11:05:00Z"), + content = "You should definitely visit Stockholm! It's a beautiful city." + ) + ) + ), + "Food Talk" to ChatRoom( // New chat room + name = "Food Talk", + messages = listOf( + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-10T14:00:00Z"), + content = "What's everyone having for lunch?" + ), + Message( + sender = "Kenji", + timestamp = Instant.parse("2024-10-10T14:05:00Z"), + content = "Sushi!" + ) + ) + ), + "Book Club" to ChatRoom( // New chat room + name = "Book Club", + messages = listOf( + Message( + sender = "Lin", + timestamp = Instant.parse("2024-10-11T09:00:00Z"), + content = "Has anyone read the new book by [author name]?" + ), + Message( + sender = "Aisha", + timestamp = Instant.parse("2024-10-11T09:05:00Z"), + content = "I have! It was amazing." + ) + ) + ), + "Movie Night" to ChatRoom( // New chat room + name = "Movie Night", + messages = listOf( + Message( + sender = "Bjorn", + timestamp = Instant.parse("2024-10-11T12:00:00Z"), + content = "Anyone up for a movie night this weekend?" + ), + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-11T12:05:00Z"), + content = "I'm in!" + ) + ) + ), + "Pet Pictures" to ChatRoom( // New chat room + name = "Pet Pictures", + messages = listOf( + Message( + sender = "Kenji", + timestamp = Instant.parse("2024-10-11T15:00:00Z"), + content = "Share pictures of your pets!" + ), + Message( + sender = "Lin", + timestamp = Instant.parse("2024-10-11T15:05:00Z"), + content = "Here's my cat, Mittens! [picture of cat]" + ) + ) + ), + "Gardening Enthusiasts" to ChatRoom( // New chat room + name = "Gardening Enthusiasts", + messages = listOf( + Message( + sender = "Aisha", + timestamp = Instant.parse("2024-10-12T10:00:00Z"), + content = "Anyone else have a green thumb?" + ), + Message( + sender = "Bjorn", + timestamp = Instant.parse("2024-10-12T10:05:00Z"), + content = "I love gardening! I have a small balcony garden." + ) + ) + ), + "Gaming Group" to ChatRoom( // New chat room + name = "Gaming Group", + messages = listOf( + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-12T13:00:00Z"), + content = "Anyone play [game name]?" + ), + Message( + sender = "Kenji", + timestamp = Instant.parse("2024-10-12T13:05:00Z"), + content = "I do! I'm a huge fan." + ) + ) + ), + "Music Lovers" to ChatRoom( // New chat room + name = "Music Lovers", + messages = listOf( + Message( + sender = "Lin", + timestamp = Instant.parse("2024-10-12T16:00:00Z"), + content = "What's everyone listening to these days?" + ), + Message( + sender = "Aisha", + timestamp = Instant.parse("2024-10-12T16:05:00Z"), + content = "I'm really into [artist name] lately." + ) + ) + ), + "Photography Club" to ChatRoom( // New chat room + name = "Photography Club", + messages = listOf( + Message( + sender = "Bjorn", + timestamp = Instant.parse("2024-10-13T09:00:00Z"), + content = "Anyone interested in photography?" + ), + Message( + sender = "Diego", + timestamp = Instant.parse("2024-10-13T09:05:00Z"), + content = "I am! I love taking pictures." + ) + ) + ), + "DIY Projects" to ChatRoom( // New chat room + name = "DIY Projects", + messages = listOf( + Message( + sender = "Kenji", + timestamp = Instant.parse("2024-10-13T11:00:00Z"), + content = "Anyone working on any cool DIY projects?" + ), + Message( + sender = "Lin", + timestamp = Instant.parse("2024-10-13T11:05:00Z"), + content = "I'm building a bookshelf!" + ) + ) ) ), profiles = mapOf(