Skip to content

Commit

Permalink
Merge pull request #529 from arkivanov/update-samples
Browse files Browse the repository at this point in the history
Updated samples
  • Loading branch information
arkivanov authored Nov 17, 2023
2 parents 6da132c + 93257c5 commit 54e56e0
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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())
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -73,11 +69,7 @@ fun main() {
title = "Decompose Sample"
) {
Surface(modifier = Modifier.fillMaxSize()) {
MaterialTheme {
CompositionLocalProvider(LocalScrollbarStyle provides defaultScrollbarStyle()) {
RootContent(root)
}
}
RootContent(root)
}

if (isCloseRequested) {
Expand Down
18 changes: 0 additions & 18 deletions sample/app-ios/app-ios/CounterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,3 @@ struct CounterView_Previews: PreviewProvider {
CounterView(PreviewCounterComponent())
}
}

class PreviewCounterComponent : CounterComponent {
let model: Value<CounterComponentModel> = mutableValue(
CounterComponentModel(
title: "Counter 0",
text: "123",
isBackEnabled: false
)
)

let dialogSlot: Value<ChildSlot<AnyObject, DialogComponent>> =
mutableValue(ChildSlot(child: nil))

func onInfoClicked() {}
func onNextClicked() {}
func onPrevClicked() {}
}

8 changes: 0 additions & 8 deletions sample/app-ios/app-ios/CountersView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,3 @@ struct CountersView_Previews: PreviewProvider {
CountersView(PreviewCountersComponent())
}
}

class PreviewCountersComponent: CountersComponent {
var backHandler: BackHandler = BackDispatcherKt.BackDispatcher()
let childStack: Value<ChildStack<AnyObject, CounterComponent>> = simpleChildStack(PreviewCounterComponent())

func onBackClicked(toIndex: Int32) {}
func onBackClicked() {}
}
11 changes: 0 additions & 11 deletions sample/app-ios/app-ios/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,3 @@ struct RootView_Previews: PreviewProvider {
RootView(PreviewRootComponent())
}
}

class PreviewRootComponent : RootComponent {
let childStack: Value<ChildStack<AnyObject, RootComponentChild>> =
simpleChildStack(RootComponentChild.CountersChild(component: PreviewCountersComponent()))

func onCountersTabClicked() {}
func onCardsTabClicked() {}
func onMultiPaneTabClicked() {}
func onDynamicFeaturesTabClicked() {}
func onCustomNavigationTabClicked() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,26 +277,3 @@ private data class Item<out T : Any>(
internal fun CardsContentPreview() {
CardsContent(PreviewCardsComponent())
}

internal class PreviewCardsComponent : CardsComponent {
override val stack: Value<ChildStack<*, CardComponent>> =
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() {}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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<Model> =
MutableValue(
Model(
color = color,
title = "1",
status = "Status: Resumed",
text = "Count: 10",
)
)
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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<ChildStack<*, CounterComponent>> =
MutableValue(
ChildStack(
configuration = Unit,
instance = PreviewCounterComponent(),
)
)

override fun onBackClicked() {}
override fun onBackClicked(toIndex: Int) {}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<Model> =
MutableValue(
Model(
title = "Counter 0",
text = "123",
isBackEnabled = false,
)
)

override val dialogSlot: Value<ChildSlot<Unit, DialogComponent>> =
MutableValue(ChildSlot())

override fun onNextClicked() {}
override fun onPrevClicked() {}
override fun onInfoClicked() {}
}
Loading

0 comments on commit 54e56e0

Please sign in to comment.