Skip to content

Commit a1ce0ea

Browse files
committed
finish decompose navigation for desktop
1 parent fdb5402 commit a1ce0ea

File tree

38 files changed

+207
-346
lines changed

38 files changed

+207
-346
lines changed

androidApp/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ dependencies {
8181
implementation(project(":common:integration"))
8282
implementation(project(":common:features:about"))
8383
implementation(project(":common:features:settings"))
84-
implementation(project(":common:features:thinkpad_list"))
84+
implementation(project(":common:features:list"))
8585
implementation(project(":common:features:details"))
8686
implementation(project(":common:features:donate"))
8787

androidApp/src/main/java/work/racka/thinkrchive/v2/android/ui/components/TestThinkpadList.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import androidx.compose.ui.unit.sp
1919
import org.koin.androidx.compose.getViewModel
2020
import states.list.ThinkpadListSideEffect
2121
import timber.log.Timber
22-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.viewmodel.ThinkpadListViewModel
22+
import work.racka.thinkrchive.v2.common.features.list.viewmodel.ThinkpadListViewModel
2323

2424
@ExperimentalAnimationApi
2525
@Composable

androidApp/src/main/java/work/racka/thinkrchive/v2/android/ui/main/screens/list/ThinkpadListScreen.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import work.racka.thinkrchive.v2.android.utils.scaleInEnterTransition
1818
import work.racka.thinkrchive.v2.android.utils.scaleInPopEnterTransition
1919
import work.racka.thinkrchive.v2.android.utils.scaleOutExitTransition
2020
import work.racka.thinkrchive.v2.android.utils.scaleOutPopExitTransition
21-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.viewmodel.ThinkpadListViewModel
21+
import work.racka.thinkrchive.v2.common.features.list.viewmodel.ThinkpadListViewModel
2222

2323
@ExperimentalMaterial3Api
2424
@ExperimentalComposeUiApi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="work.racka.thinkrchive.v2.common.features.list" />
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.di
1+
package work.racka.thinkrchive.v2.common.features.list.di
22

33
import kotlinx.coroutines.CoroutineDispatcher
44
import kotlinx.coroutines.Dispatchers
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.di
1+
package work.racka.thinkrchive.v2.common.features.list.di
22

33
import org.koin.androidx.viewmodel.dsl.viewModel
44
import org.koin.dsl.module
5-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.viewmodel.ThinkpadListViewModel
5+
import work.racka.thinkrchive.v2.common.features.list.viewmodel.ThinkpadListViewModel
66

77
internal actual object Platform {
88
actual fun platformSettingsModule() = module {
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.viewmodel
1+
package work.racka.thinkrchive.v2.common.features.list.viewmodel
22

33
import androidx.lifecycle.ViewModel
44
import androidx.lifecycle.viewModelScope
5+
import work.racka.thinkrchive.v2.common.features.list.container.ThinkpadListContainerHost
6+
import work.racka.thinkrchive.v2.common.features.list.container.ThinkpadListContainerHostImpl
7+
import work.racka.thinkrchive.v2.common.features.list.container.ThinkpadListHelper
58
import work.racka.thinkrchive.v2.common.features.settings.AppSettings
6-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.container.ThinkpadListContainerHost
7-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.container.ThinkpadListContainerHostImpl
8-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.container.ThinkpadListHelper
99

1010
actual class ThinkpadListViewModel(
1111
helper: ThinkpadListHelper,
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.container
1+
package work.racka.thinkrchive.v2.common.features.list.container
22

33
import kotlinx.coroutines.flow.Flow
44
import kotlinx.coroutines.flow.StateFlow
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.container
1+
package work.racka.thinkrchive.v2.common.features.list.container
22

33
import co.touchlab.kermit.Logger
44
import kotlinx.coroutines.CoroutineScope
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.container
1+
package work.racka.thinkrchive.v2.common.features.list.container
22

33
import data.remote.response.ThinkpadResponse
4-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.repository.ListRepository
4+
import work.racka.thinkrchive.v2.common.features.list.repository.ListRepository
55

66
class ThinkpadListHelper(
77
val repository: ListRepository
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.di
1+
package work.racka.thinkrchive.v2.common.features.list.di
22

33
import kotlinx.coroutines.CoroutineDispatcher
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.di
1+
package work.racka.thinkrchive.v2.common.features.list.di
22

33
import org.koin.core.module.Module
44

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.di
1+
package work.racka.thinkrchive.v2.common.features.list.di
22

33
import org.koin.core.KoinApplication
44
import org.koin.dsl.module
5-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.container.ThinkpadListHelper
6-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.repository.ListRepository
7-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.repository.ListRepositoryImpl
5+
import work.racka.thinkrchive.v2.common.features.list.container.ThinkpadListHelper
6+
import work.racka.thinkrchive.v2.common.features.list.repository.ListRepository
7+
import work.racka.thinkrchive.v2.common.features.list.repository.ListRepositoryImpl
88

99
object ThinkpadList {
1010

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.repository
1+
package work.racka.thinkrchive.v2.common.features.list.repository
22

33
import data.remote.response.ThinkpadResponse
44
import domain.Thinkpad
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.repository
1+
package work.racka.thinkrchive.v2.common.features.list.repository
22

33
import co.touchlab.kermit.Logger
44
import data.remote.response.ThinkpadResponse
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package work.racka.thinkrchive.v2.common.features.list.viewmodel
2+
3+
expect class ThinkpadListViewModel
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.di
1+
package work.racka.thinkrchive.v2.common.features.list.di
22

33
import kotlinx.coroutines.CoroutineDispatcher
44
import kotlinx.coroutines.Dispatchers
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.di
1+
package work.racka.thinkrchive.v2.common.features.list.di
22

33
import kotlinx.coroutines.CoroutineScope
44
import kotlinx.coroutines.Dispatchers
55
import org.koin.dsl.module
6-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.viewmodel.ThinkpadListViewModel
6+
import work.racka.thinkrchive.v2.common.features.list.viewmodel.ThinkpadListViewModel
77

88
internal actual object Platform {
99
actual fun platformSettingsModule() = module {
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package work.racka.thinkrchive.v2.common.features.thinkpad_list.viewmodel
1+
package work.racka.thinkrchive.v2.common.features.list.viewmodel
22

33
import kotlinx.coroutines.CoroutineScope
4+
import work.racka.thinkrchive.v2.common.features.list.container.ThinkpadListContainerHost
5+
import work.racka.thinkrchive.v2.common.features.list.container.ThinkpadListContainerHostImpl
6+
import work.racka.thinkrchive.v2.common.features.list.container.ThinkpadListHelper
47
import work.racka.thinkrchive.v2.common.features.settings.AppSettings
5-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.container.ThinkpadListContainerHost
6-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.container.ThinkpadListContainerHostImpl
7-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.container.ThinkpadListHelper
88

99
actual class ThinkpadListViewModel(
1010
helper: ThinkpadListHelper,

common/features/thinkpad_list/src/androidMain/AndroidManifest.xml

-2
This file was deleted.

common/features/thinkpad_list/src/commonMain/kotlin/work.racka.thinkrchive.v2.common/features/thinkpad_list/viewmodel/ThinkpadListViewModel.kt

-3
This file was deleted.

common/integration/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ kotlin {
3939
// Feature Modules
4040
implementation(project(":common:features:about"))
4141
implementation(project(":common:features:settings"))
42-
implementation(project(":common:features:thinkpad_list"))
42+
implementation(project(":common:features:list"))
4343
implementation(project(":common:features:details"))
4444
implementation(project(":common:features:donate"))
4545

common/integration/src/commonMain/kotlin/work.racka.thinkrchive.v2.common.integration/di/FeatureModules.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import org.koin.core.KoinApplication
44
import work.racka.thinkrchive.v2.common.features.about.di.About
55
import work.racka.thinkrchive.v2.common.features.details.di.ThinkpadDetails
66
import work.racka.thinkrchive.v2.common.features.donate.di.Donate
7+
import work.racka.thinkrchive.v2.common.features.list.di.ThinkpadList
78
import work.racka.thinkrchive.v2.common.features.settings.di.UserPreferences
8-
import work.racka.thinkrchive.v2.common.features.thinkpad_list.di.ThinkpadList
99

1010
internal object FeatureModules {
1111

desktopApp/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ kotlin {
2121
implementation(project(":common:integration"))
2222
implementation(project(":common:features:about"))
2323
implementation(project(":common:features:settings"))
24-
implementation(project(":common:features:thinkpad_list"))
24+
implementation(project(":common:features:list"))
2525
implementation(project(":common:features:details"))
2626
implementation(project(":common:features:donate"))
2727

desktopApp/src/jvmMain/kotlin/work/racka/thinkrchive/v2/desktop/Main.kt

-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
package work.racka.thinkrchive.v2.desktop
22

3-
import androidx.compose.animation.ExperimentalAnimationApi
4-
import androidx.compose.material.ExperimentalMaterialApi
5-
import androidx.compose.ui.ExperimentalComposeUiApi
63
import androidx.compose.ui.window.Window
74
import androidx.compose.ui.window.application
85
import work.racka.thinkrchive.v2.common.integration.di.KoinMain
96
import work.racka.thinkrchive.v2.desktop.ui.navigation.App
107

11-
@ExperimentalAnimationApi
12-
@ExperimentalMaterialApi
13-
@ExperimentalComposeUiApi
148
fun main() = application {
159

1610
KoinMain.initKoin()

desktopApp/src/jvmMain/kotlin/work/racka/thinkrchive/v2/desktop/ui/navigation/App.kt

-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
package work.racka.thinkrchive.v2.desktop.ui.navigation
22

3-
import androidx.compose.animation.ExperimentalAnimationApi
4-
import androidx.compose.material.ExperimentalMaterialApi
53
import androidx.compose.material.Scaffold
64
import androidx.compose.runtime.Composable
75
import androidx.compose.runtime.collectAsState
86
import androidx.compose.runtime.getValue
9-
import androidx.compose.ui.ExperimentalComposeUiApi
107
import com.arkivanov.decompose.DefaultComponentContext
118
import com.arkivanov.essenty.lifecycle.LifecycleRegistry
129
import org.koin.java.KoinJavaComponent.inject
1310
import states.settings.ThinkpadSettingsState
1411
import work.racka.thinkrchive.v2.common.features.settings.AppSettings
1512
import work.racka.thinkrchive.v2.desktop.ui.theme.ThinkRchiveTheme
1613

17-
@ExperimentalAnimationApi
18-
@ExperimentalMaterialApi
19-
@ExperimentalComposeUiApi
2014
@Composable
2115
fun App() {
2216
val settings: AppSettings by inject(AppSettings::class.java)
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
package work.racka.thinkrchive.v2.desktop.ui.navigation
22

33
import com.arkivanov.essenty.parcelable.Parcelable
4-
import com.arkivanov.essenty.parcelable.Parcelize
54

65
sealed class Configuration : Parcelable {
7-
@Parcelize
86
object ThinkpadListScreen : Configuration()
9-
10-
@Parcelize
117
data class ThinkpadDetailsScreen(val model: String) : Configuration()
12-
13-
@Parcelize
14-
object ThinkpadSettingsScreen : Configuration()
15-
16-
@Parcelize
17-
object ThinkpadAboutScreen : Configuration()
18-
19-
@Parcelize
208
object DonationScreen : Configuration()
9+
object ThinkpadAboutScreen : Configuration()
10+
object ThinkpadSettingsScreen : Configuration()
2111
}

desktopApp/src/jvmMain/kotlin/work/racka/thinkrchive/v2/desktop/ui/navigation/NavHostComponent.kt

+38-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package work.racka.thinkrchive.v2.desktop.ui.navigation
22

3+
import androidx.compose.animation.core.tween
34
import androidx.compose.runtime.Composable
45
import com.arkivanov.decompose.ComponentContext
56
import com.arkivanov.decompose.ExperimentalDecomposeApi
67
import com.arkivanov.decompose.extensions.compose.jetbrains.Children
78
import com.arkivanov.decompose.extensions.compose.jetbrains.animation.child.crossfadeScale
8-
import com.arkivanov.decompose.router.pop
9-
import com.arkivanov.decompose.router.push
109
import com.arkivanov.decompose.router.router
10+
import work.racka.thinkrchive.v2.desktop.ui.screens.about.AboutScreen
1111
import work.racka.thinkrchive.v2.desktop.ui.screens.details.ThinkpadDetailsScreen
12+
import work.racka.thinkrchive.v2.desktop.ui.screens.donate.DonateScreen
1213
import work.racka.thinkrchive.v2.desktop.ui.screens.list.ThinkpadListScreen
14+
import work.racka.thinkrchive.v2.desktop.ui.screens.settings.SettingsScreen
1315

1416
class NavHostComponent(
1517
private val componentContext: ComponentContext
@@ -28,25 +30,48 @@ class NavHostComponent(
2830
is Configuration.ThinkpadListScreen -> {
2931
ThinkpadListScreen(
3032
componentContext = componentContext,
31-
onDetailsClicked = {
32-
router.push(Configuration.ThinkpadDetailsScreen(it))
33-
}
33+
onEntryClick = { model ->
34+
NavigationActions.List.onEntryClick(router, model)
35+
},
36+
onAboutClicked = { NavigationActions.List.onAboutClicked(router) },
37+
onDonateClicked = { NavigationActions.List.onDonateClicked(router) },
38+
onSettingsClicked = { NavigationActions.List.onSettingsClicked(router) }
3439
)
3540
}
3641
is Configuration.ThinkpadDetailsScreen -> {
37-
3842
ThinkpadDetailsScreen(
3943
componentContext = componentContext,
40-
onBackClicked = router::pop,
44+
onBackClicked = { NavigationActions.goBack(router) },
4145
model = config.model
4246
)
4347
}
48+
is Configuration.DonationScreen -> {
49+
DonateScreen(
50+
componentContext = componentContext,
51+
onBackClicked = { NavigationActions.goBack(router) }
52+
)
53+
}
54+
is Configuration.ThinkpadAboutScreen -> {
55+
AboutScreen(
56+
componentContext = componentContext,
57+
onBackClicked = { NavigationActions.goBack(router) }
58+
)
59+
}
60+
is Configuration.ThinkpadSettingsScreen -> {
61+
SettingsScreen(
62+
componentContext = componentContext,
63+
onBackClicked = { NavigationActions.goBack(router) }
64+
)
65+
}
4466
else -> {
4567
ThinkpadListScreen(
4668
componentContext = componentContext,
47-
onDetailsClicked = {
48-
router.push(Configuration.ThinkpadDetailsScreen(it))
49-
}
69+
onEntryClick = { model ->
70+
NavigationActions.List.onEntryClick(router, model)
71+
},
72+
onAboutClicked = { NavigationActions.List.onAboutClicked(router) },
73+
onDonateClicked = { NavigationActions.List.onDonateClicked(router) },
74+
onSettingsClicked = { NavigationActions.List.onSettingsClicked(router) }
5075
)
5176
}
5277
}
@@ -57,7 +82,9 @@ class NavHostComponent(
5782
override fun render() {
5883
Children(
5984
routerState = router.state,
60-
animation = crossfadeScale()
85+
animation = crossfadeScale(
86+
animationSpec = tween(300)
87+
)
6188
) { child ->
6289
child.instance.render()
6390
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package work.racka.thinkrchive.v2.desktop.ui.navigation
2+
3+
import com.arkivanov.decompose.router.Router
4+
import com.arkivanov.decompose.router.pop
5+
import com.arkivanov.decompose.router.push
6+
7+
object NavigationActions {
8+
9+
fun goBack(router: Router<Configuration, Component>) {
10+
router.pop()
11+
}
12+
13+
object List {
14+
fun onEntryClick(
15+
router: Router<Configuration, Component>,
16+
model: String
17+
) {
18+
router.push(Configuration.ThinkpadDetailsScreen(model))
19+
}
20+
21+
fun onSettingsClicked(router: Router<Configuration, Component>) {
22+
router.push(Configuration.ThinkpadSettingsScreen)
23+
}
24+
25+
fun onAboutClicked(router: Router<Configuration, Component>) {
26+
router.push(Configuration.ThinkpadAboutScreen)
27+
}
28+
29+
fun onDonateClicked(router: Router<Configuration, Component>) {
30+
router.push(Configuration.DonationScreen)
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)