diff --git a/compose/build.gradle.kts b/compose/build.gradle.kts index 5f4e82b..eb216d7 100644 --- a/compose/build.gradle.kts +++ b/compose/build.gradle.kts @@ -71,6 +71,7 @@ dependencies { api(projects.core) implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.foundation) implementation(libs.hilt) ksp(libs.hilt.compiler) implementation(libs.kotlinx.collections.immutable) diff --git a/compose/src/main/java/com/naturecurly/deck/compose/Deck.kt b/compose/src/main/java/com/naturecurly/deck/compose/Deck.kt index b50781a..feaec53 100644 --- a/compose/src/main/java/com/naturecurly/deck/compose/Deck.kt +++ b/compose/src/main/java/com/naturecurly/deck/compose/Deck.kt @@ -40,7 +40,7 @@ fun Deck(provider: DeckProvider<*>, content: @Composable DeckScope.() -> Unit) { @Composable private fun rememberDeckScope(containers: ImmutableMap>) = remember(containers) { - DeckScopeImpl(containers) + DeckScope(containers) } @Composable diff --git a/compose/src/main/java/com/naturecurly/deck/compose/DeckScope.kt b/compose/src/main/java/com/naturecurly/deck/compose/DeckScope.kt index 252da14..980c904 100644 --- a/compose/src/main/java/com/naturecurly/deck/compose/DeckScope.kt +++ b/compose/src/main/java/com/naturecurly/deck/compose/DeckScope.kt @@ -23,16 +23,16 @@ package com.naturecurly.deck.compose import android.annotation.SuppressLint +import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import com.naturecurly.deck.compose.log.DeckLog +import kotlinx.collections.immutable.ImmutableMap @Immutable -abstract class DeckScope { - protected abstract val containerUis: Map> - +class DeckScope(private val containerUis: ImmutableMap>) { @SuppressLint("RememberReturnType") @Composable fun Stub(containerUiId: String, modifier: Modifier = Modifier) { @@ -40,4 +40,15 @@ abstract class DeckScope { DeckLog.w("Not found containerId: $containerUiId") } } + + fun LazyListScope.itemStub( + containerUiId: String, + modifier: Modifier = Modifier, + key: Any? = null, + contentType: Any? = null, + ) { + item(key, contentType) { + Stub(containerUiId, modifier) + } + } } diff --git a/compose/src/main/java/com/naturecurly/deck/compose/DeckScopeImpl.kt b/compose/src/main/java/com/naturecurly/deck/compose/DeckScopeImpl.kt deleted file mode 100644 index cbdd572..0000000 --- a/compose/src/main/java/com/naturecurly/deck/compose/DeckScopeImpl.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2025 naturecurly - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.naturecurly.deck.compose - -class DeckScopeImpl( - override val containerUis: Map>, -) : DeckScope() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8b71f9b..dfed1d6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -40,7 +40,7 @@ androidx-activity-compose = { group = "androidx.activity", name = "activity-comp androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime" } androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" } -androidx-ui = { group = "androidx.compose.ui", name = "ui" } +androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation" } androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } diff --git a/sample/app/build.gradle.kts b/sample/app/build.gradle.kts index 3517dd0..3eac78f 100644 --- a/sample/app/build.gradle.kts +++ b/sample/app/build.gradle.kts @@ -65,7 +65,7 @@ dependencies { implementation(libs.androidx.lifecycle.viewmodel.compose) implementation(libs.androidx.activity.compose) implementation(platform(libs.androidx.compose.bom)) - implementation(libs.androidx.ui) + implementation(libs.androidx.compose.ui) implementation(libs.androidx.ui.graphics) implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.material3) diff --git a/sample/mainFeature/src/main/java/com/naturecurly/deck/sample/feature1/MainScreen.kt b/sample/mainFeature/src/main/java/com/naturecurly/deck/sample/feature1/MainScreen.kt index 3d636b1..6a20805 100644 --- a/sample/mainFeature/src/main/java/com/naturecurly/deck/sample/feature1/MainScreen.kt +++ b/sample/mainFeature/src/main/java/com/naturecurly/deck/sample/feature1/MainScreen.kt @@ -25,6 +25,7 @@ package com.naturecurly.deck.sample.feature1 import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -56,6 +57,9 @@ private fun DeckScope.Content() { ) Stub("FeatureOne") Stub("FeatureTwo", modifier = Modifier.padding(top = 20.dp)) + LazyColumn { + itemStub("FeatureOne") + } } } }