diff --git a/sample/app-android/src/main/java/com/arkivanov/sample/app/MainActivity.kt b/sample/app-android/src/main/java/com/arkivanov/sample/app/MainActivity.kt index 185d4cf09..72f10ae87 100644 --- a/sample/app-android/src/main/java/com/arkivanov/sample/app/MainActivity.kt +++ b/sample/app-android/src/main/java/com/arkivanov/sample/app/MainActivity.kt @@ -4,16 +4,14 @@ import android.os.Bundle import androidx.activity.compose.setContent import androidx.appcompat.app.AppCompatActivity import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface import androidx.compose.ui.Modifier import com.arkivanov.decompose.ExperimentalDecomposeApi import com.arkivanov.decompose.defaultComponentContext import com.arkivanov.decompose.extensions.android.DefaultViewContext import com.arkivanov.essenty.lifecycle.essentyLifecycle import com.arkivanov.sample.shared.dynamicfeatures.dynamicfeature.DefaultFeatureInstaller -import com.arkivanov.sample.shared.root.RootComponent import com.arkivanov.sample.shared.root.DefaultRootComponent +import com.arkivanov.sample.shared.root.RootComponent import com.arkivanov.sample.shared.root.RootContent import com.arkivanov.sample.shared.root.RootView @@ -38,11 +36,7 @@ class MainActivity : AppCompatActivity() { private fun drawViaCompose(root: RootComponent) { setContent { - MaterialTheme { - Surface(color = MaterialTheme.colors.background) { - RootContent(component = root, modifier = Modifier.fillMaxSize()) - } - } + RootContent(component = root, modifier = Modifier.fillMaxSize()) } } diff --git a/sample/app-desktop/src/jvmMain/kotlin/com/arkivanov/sample/app/Main.kt b/sample/app-desktop/src/jvmMain/kotlin/com/arkivanov/sample/app/Main.kt index c0cb0985f..b15d102a6 100644 --- a/sample/app-desktop/src/jvmMain/kotlin/com/arkivanov/sample/app/Main.kt +++ b/sample/app-desktop/src/jvmMain/kotlin/com/arkivanov/sample/app/Main.kt @@ -1,7 +1,5 @@ package com.arkivanov.sample.app -import androidx.compose.foundation.LocalScrollbarStyle -import androidx.compose.foundation.defaultScrollbarStyle import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize @@ -10,12 +8,10 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.material.AlertDialog import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text import androidx.compose.material.TextButton import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -73,11 +69,7 @@ fun main() { title = "Decompose Sample" ) { Surface(modifier = Modifier.fillMaxSize()) { - MaterialTheme { - CompositionLocalProvider(LocalScrollbarStyle provides defaultScrollbarStyle()) { - RootContent(root) - } - } + RootContent(root) } if (isCloseRequested) { diff --git a/sample/app-ios/app-ios/CounterView.swift b/sample/app-ios/app-ios/CounterView.swift index d26a1658c..f95e12f8e 100644 --- a/sample/app-ios/app-ios/CounterView.swift +++ b/sample/app-ios/app-ios/CounterView.swift @@ -71,21 +71,3 @@ struct CounterView_Previews: PreviewProvider { CounterView(PreviewCounterComponent()) } } - -class PreviewCounterComponent : CounterComponent { - let model: Value = mutableValue( - CounterComponentModel( - title: "Counter 0", - text: "123", - isBackEnabled: false - ) - ) - - let dialogSlot: Value> = - mutableValue(ChildSlot(child: nil)) - - func onInfoClicked() {} - func onNextClicked() {} - func onPrevClicked() {} -} - diff --git a/sample/app-ios/app-ios/CountersView.swift b/sample/app-ios/app-ios/CountersView.swift index a1be1a78e..ac5f97413 100644 --- a/sample/app-ios/app-ios/CountersView.swift +++ b/sample/app-ios/app-ios/CountersView.swift @@ -30,11 +30,3 @@ struct CountersView_Previews: PreviewProvider { CountersView(PreviewCountersComponent()) } } - -class PreviewCountersComponent: CountersComponent { - var backHandler: BackHandler = BackDispatcherKt.BackDispatcher() - let childStack: Value> = simpleChildStack(PreviewCounterComponent()) - - func onBackClicked(toIndex: Int32) {} - func onBackClicked() {} -} diff --git a/sample/app-ios/app-ios/RootView.swift b/sample/app-ios/app-ios/RootView.swift index 3054ae4fd..0507814a8 100644 --- a/sample/app-ios/app-ios/RootView.swift +++ b/sample/app-ios/app-ios/RootView.swift @@ -76,14 +76,3 @@ struct RootView_Previews: PreviewProvider { RootView(PreviewRootComponent()) } } - -class PreviewRootComponent : RootComponent { - let childStack: Value> = - simpleChildStack(RootComponentChild.CountersChild(component: PreviewCountersComponent())) - - func onCountersTabClicked() {} - func onCardsTabClicked() {} - func onMultiPaneTabClicked() {} - func onDynamicFeaturesTabClicked() {} - func onCustomNavigationTabClicked() {} -} diff --git a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/CardsContent.kt b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/CardsContent.kt index 51deb9524..6ed0af223 100644 --- a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/CardsContent.kt +++ b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/CardsContent.kt @@ -277,26 +277,3 @@ private data class Item( internal fun CardsContentPreview() { CardsContent(PreviewCardsComponent()) } - -internal class PreviewCardsComponent : CardsComponent { - override val stack: Value> = - MutableValue( - ChildStack( - active = Child.Created( - configuration = 1, - instance = PreviewCardComponent(color = 0xFFFF0000), - ), - backStack = listOf( - Child.Created( - configuration = 2, - instance = PreviewCardComponent(color = 0xFF0000FF), - ) - ), - ) - ) - - override fun onCardSwiped(index: Int) {} - override fun onAddClicked() {} - override fun onRemoveClicked() {} -} - diff --git a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/card/CardContent.kt b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/card/CardContent.kt index dc8863565..2b4fa020c 100644 --- a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/card/CardContent.kt +++ b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/card/CardContent.kt @@ -74,17 +74,3 @@ private fun Title(text: String) { internal fun CardContentPreview() { CardContent(component = PreviewCardComponent()) } - -internal class PreviewCardComponent( - color: Long = 0xFFFF0000, -) : CardComponent { - override val model: Value = - MutableValue( - Model( - color = color, - title = "1", - status = "Status: Resumed", - text = "Count: 10", - ) - ) -} diff --git a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/CountersContent.kt b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/CountersContent.kt index 7673531c5..55ee2f76d 100644 --- a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/CountersContent.kt +++ b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/CountersContent.kt @@ -1,3 +1,5 @@ +@file:Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE") // Workaround for KTIJ-22326 + package com.arkivanov.sample.shared.counters import androidx.compose.desktop.ui.tooling.preview.Preview @@ -12,14 +14,7 @@ import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.plus import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.predictiveBackAnimation import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.scale import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation -import com.arkivanov.decompose.router.stack.ChildStack -import com.arkivanov.decompose.value.MutableValue -import com.arkivanov.decompose.value.Value -import com.arkivanov.essenty.backhandler.BackDispatcher -import com.arkivanov.essenty.backhandler.BackHandler -import com.arkivanov.sample.shared.counters.counter.CounterComponent import com.arkivanov.sample.shared.counters.counter.CounterContent -import com.arkivanov.sample.shared.counters.counter.PreviewCounterComponent @Composable internal fun CountersContent(component: CountersComponent, modifier: Modifier = Modifier) { @@ -52,18 +47,3 @@ internal fun CountersContent(component: CountersComponent, modifier: Modifier = internal fun CountersPreview() { CountersContent(component = PreviewCountersComponent()) } - -internal class PreviewCountersComponent : CountersComponent { - override val backHandler: BackHandler = BackDispatcher() - - override val childStack: Value> = - MutableValue( - ChildStack( - configuration = Unit, - instance = PreviewCounterComponent(), - ) - ) - - override fun onBackClicked() {} - override fun onBackClicked(toIndex: Int) {} -} diff --git a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/counter/CounterContent.kt b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/counter/CounterContent.kt index bb59b359f..678b092e1 100644 --- a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/counter/CounterContent.kt +++ b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/counter/CounterContent.kt @@ -1,3 +1,5 @@ +@file:Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE") // Workaround for KTIJ-22326 + package com.arkivanov.sample.shared.counters.counter import androidx.compose.desktop.ui.tooling.preview.Preview @@ -18,11 +20,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState -import com.arkivanov.decompose.router.slot.ChildSlot -import com.arkivanov.decompose.value.MutableValue -import com.arkivanov.decompose.value.Value -import com.arkivanov.sample.shared.counters.counter.CounterComponent.Model -import com.arkivanov.sample.shared.dialog.DialogComponent import com.arkivanov.sample.shared.dialog.DialogContent @Composable @@ -94,21 +91,3 @@ internal fun CounterContent(component: CounterComponent, modifier: Modifier = Mo internal fun CounterContentPreview() { CounterContent(component = PreviewCounterComponent()) } - -internal class PreviewCounterComponent : CounterComponent { - override val model: Value = - MutableValue( - Model( - title = "Counter 0", - text = "123", - isBackEnabled = false, - ) - ) - - override val dialogSlot: Value> = - MutableValue(ChildSlot()) - - override fun onNextClicked() {} - override fun onPrevClicked() {} - override fun onInfoClicked() {} -} diff --git a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/root/RootContent.kt b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/root/RootContent.kt index 0d499f8f2..4d7128666 100644 --- a/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/root/RootContent.kt +++ b/sample/shared/compose/src/commonMain/kotlin/com/arkivanov/sample/shared/root/RootContent.kt @@ -4,11 +4,18 @@ package com.arkivanov.sample.shared.root import androidx.compose.desktop.ui.tooling.preview.Preview import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.only +import androidx.compose.foundation.layout.systemBars +import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.material.BottomNavigation import androidx.compose.material.BottomNavigationItem import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Surface import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Favorite import androidx.compose.material.icons.filled.List @@ -26,13 +33,9 @@ import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.isEn import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.slide import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState -import com.arkivanov.decompose.router.stack.ChildStack -import com.arkivanov.decompose.value.MutableValue -import com.arkivanov.decompose.value.Value import com.arkivanov.sample.shared.SwipeUp import com.arkivanov.sample.shared.cards.CardsContent import com.arkivanov.sample.shared.counters.CountersContent -import com.arkivanov.sample.shared.counters.PreviewCountersComponent import com.arkivanov.sample.shared.customnavigation.CustomNavigationComponent import com.arkivanov.sample.shared.customnavigation.CustomNavigationContent import com.arkivanov.sample.shared.dynamicfeatures.DynamicFeaturesContent @@ -46,83 +49,100 @@ import com.arkivanov.sample.shared.root.RootComponent.Child.MultiPaneChild @Composable fun RootContent(component: RootComponent, modifier: Modifier = Modifier) { - val childStack by component.childStack.subscribeAsState() - val activeComponent = childStack.active.instance + MaterialTheme { + Surface(modifier = modifier, color = MaterialTheme.colors.background) { + Column( + modifier = Modifier + .fillMaxSize() + .windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal)), + ) { + Children(component = component, modifier = Modifier.weight(1F)) + BottomBar(component = component, modifier = Modifier.fillMaxWidth()) + } + } + } +} - Column(modifier = modifier) { - Children( - stack = childStack, - modifier = Modifier.weight(weight = 1F), +@Composable +private fun Children(component: RootComponent, modifier: Modifier = Modifier) { + Children( + stack = component.childStack, + modifier = modifier, - // Workaround for https://issuetracker.google.com/issues/270656235 - animation = stackAnimation(fade()), + // Workaround for https://issuetracker.google.com/issues/270656235 + animation = stackAnimation(fade()), // animation = tabAnimation(), - ) { - when (val child = it.instance) { - is CountersChild -> CountersContent(component = child.component, modifier = Modifier.fillMaxSize()) - is CardsChild -> CardsContent(component = child.component, modifier = Modifier.fillMaxSize()) - is MultiPaneChild -> MultiPaneContent(component = child.component, modifier = Modifier.fillMaxSize()) - is DynamicFeaturesChild -> DynamicFeaturesContent(component = child.component, modifier = Modifier.fillMaxSize()) - is CustomNavigationChild -> CustomNavigationContent(component = child.component, modifier.fillMaxSize()) - } + ) { + when (val child = it.instance) { + is CountersChild -> CountersContent(component = child.component, modifier = Modifier.fillMaxSize()) + is CardsChild -> CardsContent(component = child.component, modifier = Modifier.fillMaxSize()) + is MultiPaneChild -> MultiPaneContent(component = child.component, modifier = Modifier.fillMaxSize()) + is DynamicFeaturesChild -> DynamicFeaturesContent(component = child.component, modifier = Modifier.fillMaxSize()) + is CustomNavigationChild -> CustomNavigationContent(component = child.component, Modifier.fillMaxSize()) } + } +} - BottomNavigation(modifier = Modifier.fillMaxWidth()) { - BottomNavigationItem( - selected = activeComponent is CountersChild, - onClick = component::onCountersTabClicked, - icon = { - Icon( - imageVector = Icons.Default.Refresh, - contentDescription = "Counters", - ) - }, - ) - - BottomNavigationItem( - selected = activeComponent is CardsChild, - onClick = component::onCardsTabClicked, - icon = { - Icon( - imageVector = Icons.Filled.SwipeUp, - contentDescription = "Cards", - ) - }, - ) - - BottomNavigationItem( - selected = activeComponent is MultiPaneChild, - onClick = component::onMultiPaneTabClicked, - icon = { - Icon( - imageVector = Icons.Default.List, - contentDescription = "Multi-Pane", - ) - }, - ) - - BottomNavigationItem( - selected = activeComponent is DynamicFeaturesChild, - onClick = component::onDynamicFeaturesTabClicked, - icon = { - Icon( - imageVector = Icons.Default.Favorite, - contentDescription = "Dynamic Features", - ) - }, - ) - - BottomNavigationItem( - selected = activeComponent is CustomNavigationComponent, - onClick = component::onCustomNavigationTabClicked, - icon = { - Icon( - imageVector = Icons.Default.LocationOn, - contentDescription = "Custom Navigation", - ) - }, - ) - } +@Composable +private fun BottomBar(component: RootComponent, modifier: Modifier = Modifier) { + val childStack by component.childStack.subscribeAsState() + val activeComponent = childStack.active.instance + + BottomNavigation(modifier = modifier) { + BottomNavigationItem( + selected = activeComponent is CountersChild, + onClick = component::onCountersTabClicked, + icon = { + Icon( + imageVector = Icons.Default.Refresh, + contentDescription = "Counters", + ) + }, + ) + + BottomNavigationItem( + selected = activeComponent is CardsChild, + onClick = component::onCardsTabClicked, + icon = { + Icon( + imageVector = Icons.Filled.SwipeUp, + contentDescription = "Cards", + ) + }, + ) + + BottomNavigationItem( + selected = activeComponent is MultiPaneChild, + onClick = component::onMultiPaneTabClicked, + icon = { + Icon( + imageVector = Icons.Default.List, + contentDescription = "Multi-Pane", + ) + }, + ) + + BottomNavigationItem( + selected = activeComponent is DynamicFeaturesChild, + onClick = component::onDynamicFeaturesTabClicked, + icon = { + Icon( + imageVector = Icons.Default.Favorite, + contentDescription = "Dynamic Features", + ) + }, + ) + + BottomNavigationItem( + selected = activeComponent is CustomNavigationComponent, + onClick = component::onCustomNavigationTabClicked, + icon = { + Icon( + imageVector = Icons.Default.LocationOn, + contentDescription = "Custom Navigation", + ) + }, + ) } } @@ -169,18 +189,3 @@ internal fun RootContentPreview() { RootContent(PreviewRootComponent()) } -internal class PreviewRootComponent : RootComponent { - override val childStack: Value> = - MutableValue( - ChildStack( - configuration = Unit, - instance = CountersChild(component = PreviewCountersComponent()), - ) - ) - - override fun onCountersTabClicked() {} - override fun onCardsTabClicked() {} - override fun onMultiPaneTabClicked() {} - override fun onDynamicFeaturesTabClicked() {} - override fun onCustomNavigationTabClicked() {} -} diff --git a/sample/shared/shared/build.gradle.kts b/sample/shared/shared/build.gradle.kts index bfa6e918f..406a211c1 100644 --- a/sample/shared/shared/build.gradle.kts +++ b/sample/shared/shared/build.gradle.kts @@ -37,7 +37,6 @@ kotlin { baseName = "Shared" export(project(":decompose")) export(deps.essenty.lifecycle) - export(deps.essenty.backHandler) // Optional, only if you need state preservation on Darwin (Apple) targets export(deps.essenty.stateKeeper) diff --git a/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/PreviewComponentContext.kt b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/PreviewComponentContext.kt new file mode 100644 index 000000000..f23fed85c --- /dev/null +++ b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/PreviewComponentContext.kt @@ -0,0 +1,9 @@ +package com.arkivanov.sample.shared + +import com.arkivanov.decompose.ComponentContext +import com.arkivanov.decompose.DefaultComponentContext +import com.arkivanov.essenty.lifecycle.LifecycleRegistry + +internal object PreviewComponentContext : ComponentContext by DefaultComponentContext( + lifecycle = LifecycleRegistry(), +) diff --git a/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/PreviewCardsComponent.kt b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/PreviewCardsComponent.kt new file mode 100644 index 000000000..339bb7e9f --- /dev/null +++ b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/PreviewCardsComponent.kt @@ -0,0 +1,31 @@ +package com.arkivanov.sample.shared.cards + +import com.arkivanov.decompose.Child +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.value.MutableValue +import com.arkivanov.decompose.value.Value +import com.arkivanov.sample.shared.cards.card.CardComponent +import com.arkivanov.sample.shared.cards.card.PreviewCardComponent + +class PreviewCardsComponent : CardsComponent { + + override val stack: Value> = + MutableValue( + ChildStack( + active = Child.Created( + configuration = 1, + instance = PreviewCardComponent(color = 0xFFFF0000), + ), + backStack = listOf( + Child.Created( + configuration = 2, + instance = PreviewCardComponent(color = 0xFF0000FF), + ) + ), + ) + ) + + override fun onCardSwiped(index: Int) {} + override fun onAddClicked() {} + override fun onRemoveClicked() {} +} diff --git a/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/card/PreviewCardComponent.kt b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/card/PreviewCardComponent.kt new file mode 100644 index 000000000..69ec4ac92 --- /dev/null +++ b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/cards/card/PreviewCardComponent.kt @@ -0,0 +1,20 @@ +package com.arkivanov.sample.shared.cards.card + +import com.arkivanov.decompose.value.MutableValue +import com.arkivanov.decompose.value.Value +import com.arkivanov.sample.shared.cards.card.CardComponent.Model + +class PreviewCardComponent( + color: Long = 0xFFFF0000, +) : CardComponent { + + override val model: Value = + MutableValue( + Model( + color = color, + title = "1", + status = "Status: Resumed", + text = "Count: 10", + ) + ) +} diff --git a/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/PreviewCountersComponent.kt b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/PreviewCountersComponent.kt new file mode 100644 index 000000000..ee0c32b6e --- /dev/null +++ b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/PreviewCountersComponent.kt @@ -0,0 +1,23 @@ +package com.arkivanov.sample.shared.counters + +import com.arkivanov.decompose.ComponentContext +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.value.MutableValue +import com.arkivanov.decompose.value.Value +import com.arkivanov.sample.shared.PreviewComponentContext +import com.arkivanov.sample.shared.counters.counter.CounterComponent +import com.arkivanov.sample.shared.counters.counter.PreviewCounterComponent + +class PreviewCountersComponent : CountersComponent, ComponentContext by PreviewComponentContext { + + override val childStack: Value> = + MutableValue( + ChildStack( + configuration = Unit, + instance = PreviewCounterComponent(), + ) + ) + + override fun onBackClicked() {} + override fun onBackClicked(toIndex: Int) {} +} diff --git a/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/counter/PreviewCounterComponent.kt b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/counter/PreviewCounterComponent.kt new file mode 100644 index 000000000..0837d6403 --- /dev/null +++ b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/counter/PreviewCounterComponent.kt @@ -0,0 +1,26 @@ +package com.arkivanov.sample.shared.counters.counter + +import com.arkivanov.decompose.router.slot.ChildSlot +import com.arkivanov.decompose.value.MutableValue +import com.arkivanov.decompose.value.Value +import com.arkivanov.sample.shared.counters.counter.CounterComponent.Model +import com.arkivanov.sample.shared.dialog.DialogComponent + +class PreviewCounterComponent : CounterComponent { + + override val model: Value = + MutableValue( + Model( + title = "Counter 0", + text = "123", + isBackEnabled = false, + ) + ) + + override val dialogSlot: Value> = + MutableValue(ChildSlot()) + + override fun onNextClicked() {} + override fun onPrevClicked() {} + override fun onInfoClicked() {} +} diff --git a/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/root/PreviewRootComponent.kt b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/root/PreviewRootComponent.kt new file mode 100644 index 000000000..f785767dd --- /dev/null +++ b/sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/root/PreviewRootComponent.kt @@ -0,0 +1,25 @@ +package com.arkivanov.sample.shared.root + +import com.arkivanov.decompose.router.stack.ChildStack +import com.arkivanov.decompose.value.MutableValue +import com.arkivanov.decompose.value.Value +import com.arkivanov.sample.shared.counters.PreviewCountersComponent +import com.arkivanov.sample.shared.root.RootComponent.Child +import com.arkivanov.sample.shared.root.RootComponent.Child.CountersChild + +class PreviewRootComponent : RootComponent { + + override val childStack: Value> = + MutableValue( + ChildStack( + configuration = Unit, + instance = CountersChild(component = PreviewCountersComponent()), + ) + ) + + override fun onCountersTabClicked() {} + override fun onCardsTabClicked() {} + override fun onMultiPaneTabClicked() {} + override fun onDynamicFeaturesTabClicked() {} + override fun onCustomNavigationTabClicked() {} +}