Skip to content

Commit c7b9bee

Browse files
author
hotmule
committed
Settings moved to Scrobbles screen
1 parent 9bc043c commit c7b9bee

File tree

40 files changed

+480
-632
lines changed

40 files changed

+480
-632
lines changed

feature-library/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ kotlin {
88
named("commonMain") {
99
dependencies {
1010
implementation(projects.featureTop)
11+
implementation(projects.featureMain)
1112
implementation(projects.featureProfile)
12-
implementation(projects.featureScrobbles)
1313
implementation(projects.featureNowPlaying)
1414
}
1515
}
1616
}
17-
}
17+
}

feature-library/src/commonMain/kotlin/ru/hotmule/lastik/feature/library/LibraryComponent.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ package ru.hotmule.lastik.feature.library
33
import com.arkivanov.decompose.router.stack.ChildStack
44
import com.arkivanov.decompose.value.Value
55
import ru.hotmule.lastik.feature.app.NowPlayingComponent
6-
import ru.hotmule.lastik.feature.profile.ProfileComponent
7-
import ru.hotmule.lastik.feature.scrobbles.ScrobblesComponent
6+
import ru.hotmule.lastik.feature.main.MainComponent
87
import ru.hotmule.lastik.feature.top.TopComponent
8+
import ru.hotmule.lastik.feature.profile.ProfileComponent
99

1010
interface LibraryComponent {
1111

1212
val nowPlayingComponent: NowPlayingComponent
1313

1414
sealed class Child(val index: Int) {
15-
data class Scrobbles(val component: ScrobblesComponent) : Child(0)
15+
data class Scrobbles(val component: MainComponent) : Child(0)
1616
data class Artists(val component: TopComponent) : Child(1)
1717
data class Albums(val component: TopComponent) : Child(2)
1818
data class Tracks(val component: TopComponent) : Child(3)
@@ -24,4 +24,4 @@ interface LibraryComponent {
2424
val activeChildIndex: Value<Int>
2525

2626
fun onShelfSelect(index: Int)
27-
}
27+
}

feature-library/src/commonMain/kotlin/ru/hotmule/lastik/feature/library/LibraryComponentImpl.kt

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
package ru.hotmule.lastik.feature.library
22

3-
import com.arkivanov.decompose.*
4-
import com.arkivanov.decompose.router.stack.*
3+
import com.arkivanov.decompose.ComponentContext
4+
import com.arkivanov.decompose.router.stack.ChildStack
5+
import com.arkivanov.decompose.router.stack.StackNavigation
6+
import com.arkivanov.decompose.router.stack.bringToFront
7+
import com.arkivanov.decompose.router.stack.childStack
58
import com.arkivanov.decompose.value.Value
69
import com.arkivanov.decompose.value.operator.map
710
import kotlinx.serialization.Serializable
8-
import org.kodein.di.*
11+
import org.kodein.di.DI
12+
import org.kodein.di.DIAware
13+
import org.kodein.di.factory
14+
import org.kodein.di.instance
915
import ru.hotmule.lastik.feature.app.NowPlayingComponent
1016
import ru.hotmule.lastik.feature.library.LibraryComponent.Child
11-
import ru.hotmule.lastik.feature.profile.ProfileComponent
12-
import ru.hotmule.lastik.feature.scrobbles.ScrobblesComponent
17+
import ru.hotmule.lastik.feature.main.MainComponent
1318
import ru.hotmule.lastik.feature.top.TopComponent
1419
import ru.hotmule.lastik.feature.top.TopComponentParams
20+
import ru.hotmule.lastik.feature.profile.ProfileComponent
1521

1622
internal class LibraryComponentImpl(
1723
override val di: DI,
1824
private val componentContext: ComponentContext
1925
) : LibraryComponent, DIAware, ComponentContext by componentContext {
2026

21-
private val scrobbles by factory<ComponentContext, ScrobblesComponent>()
27+
private val scrobbles by factory<ComponentContext, MainComponent>()
2228
private val profile by factory<ComponentContext, ProfileComponent>()
2329
private val top by factory<TopComponentParams, TopComponent>()
2430

@@ -70,4 +76,4 @@ internal class LibraryComponentImpl(
7076
@Serializable
7177
data object Profile : Config()
7278
}
73-
}
79+
}

feature-library/src/commonMain/kotlin/ru/hotmule/lastik/feature/library/module.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import com.arkivanov.decompose.ComponentContext
44
import org.kodein.di.DI
55
import org.kodein.di.bindFactory
66
import ru.hotmule.lastik.feature.app.nowPlayingComponentModule
7-
import ru.hotmule.lastik.feature.profile.profileComponentModule
8-
import ru.hotmule.lastik.feature.scrobbles.scrobblesComponentModule
7+
import ru.hotmule.lastik.feature.main.mainComponentModule
98
import ru.hotmule.lastik.feature.top.topComponentModule
9+
import ru.hotmule.lastik.feature.profile.profileComponentModule
1010

1111
val libraryComponentModule = DI.Module("libraryComponent") {
1212

1313
import(nowPlayingComponentModule)
14-
import(scrobblesComponentModule)
1514
import(profileComponentModule)
15+
import(mainComponentModule)
1616
import(topComponentModule)
1717

1818
bindFactory<ComponentContext, LibraryComponent> { componentContext ->
1919
LibraryComponentImpl(di, componentContext)
2020
}
21-
}
21+
}
File renamed without changes.

feature-main/build.gradle.kts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
id("lastik.component")
3+
id("kotlinx-serialization")
4+
}
5+
6+
kotlin {
7+
sourceSets {
8+
named("commonMain") {
9+
dependencies {
10+
implementation(projects.featureScrobbles)
11+
implementation(projects.featureSettings)
12+
}
13+
}
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package ru.hotmule.lastik.feature.main
2+
3+
import com.arkivanov.decompose.router.stack.ChildStack
4+
import com.arkivanov.decompose.value.Value
5+
import ru.hotmule.lastik.feature.scrobbles.ScrobblesComponent
6+
import ru.hotmule.lastik.feature.settings.SettingsComponent
7+
8+
interface MainComponent {
9+
10+
sealed class Child {
11+
data class Scrobbles(val component: ScrobblesComponent) : Child()
12+
data class Settings(val component: SettingsComponent) : Child()
13+
}
14+
15+
val stack: Value<ChildStack<*, Child>>
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package ru.hotmule.lastik.feature.main
2+
3+
import com.arkivanov.decompose.ComponentContext
4+
import com.arkivanov.decompose.router.stack.ChildStack
5+
import com.arkivanov.decompose.router.stack.StackNavigation
6+
import com.arkivanov.decompose.router.stack.childStack
7+
import com.arkivanov.decompose.router.stack.pop
8+
import com.arkivanov.decompose.router.stack.push
9+
import com.arkivanov.decompose.value.Value
10+
import kotlinx.serialization.Serializable
11+
import org.kodein.di.DI
12+
import org.kodein.di.DIAware
13+
import org.kodein.di.factory
14+
import ru.hotmule.lastik.feature.main.MainComponent.Child
15+
import ru.hotmule.lastik.feature.scrobbles.ScrobblesComponent
16+
import ru.hotmule.lastik.feature.scrobbles.ScrobblesComponentParams
17+
import ru.hotmule.lastik.feature.settings.SettingsComponent
18+
import ru.hotmule.lastik.feature.settings.SettingsComponentParams
19+
20+
internal class MainComponentImpl(
21+
override val di: DI,
22+
private val componentContext: ComponentContext
23+
) : MainComponent, DIAware, ComponentContext by componentContext {
24+
25+
private val scrobbles by factory<ScrobblesComponentParams, ScrobblesComponent>()
26+
private val settings by factory<SettingsComponentParams, SettingsComponent>()
27+
28+
private val navigation = StackNavigation<Config>()
29+
private val _stack = childStack(
30+
source = navigation,
31+
serializer = Config.serializer(),
32+
initialConfiguration = Config.Scrobbles,
33+
handleBackButton = true,
34+
) { configuration, componentContext ->
35+
when (configuration) {
36+
is Config.Scrobbles -> Child.Scrobbles(scrobbles(ScrobblesComponentParams(
37+
componentContext = componentContext,
38+
onSettingsOpen = ::goToSettings
39+
)))
40+
Config.Settings -> Child.Settings(settings(SettingsComponentParams(
41+
componentContext = componentContext,
42+
onBack = ::goBack
43+
)))
44+
}
45+
}
46+
47+
private fun goToSettings() {
48+
navigation.push(Config.Settings)
49+
}
50+
51+
private fun goBack() {
52+
navigation.pop()
53+
}
54+
55+
override val stack: Value<ChildStack<*, Child>> = _stack
56+
57+
@Serializable
58+
private sealed class Config {
59+
@Serializable
60+
data object Scrobbles : Config()
61+
@Serializable
62+
data object Settings : Config()
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package ru.hotmule.lastik.feature.main
2+
3+
import com.arkivanov.decompose.ComponentContext
4+
import org.kodein.di.DI
5+
import org.kodein.di.bindFactory
6+
import ru.hotmule.lastik.feature.scrobbles.scrobblesComponentModule
7+
import ru.hotmule.lastik.feature.settings.settingsComponentModule
8+
9+
val mainComponentModule = DI.Module("mainComponent") {
10+
11+
import(scrobblesComponentModule)
12+
import(settingsComponentModule)
13+
14+
bindFactory<ComponentContext, MainComponent> { componentContext ->
15+
MainComponentImpl(di, componentContext)
16+
}
17+
}

feature-menu/build.gradle.kts

-13
This file was deleted.

feature-menu/src/commonMain/kotlin/ru/hotmule/lastik/feature/menu/MenuComponent.kt

-23
This file was deleted.

feature-menu/src/commonMain/kotlin/ru/hotmule/lastik/feature/menu/MenuComponentImpl.kt

-56
This file was deleted.

feature-menu/src/commonMain/kotlin/ru/hotmule/lastik/feature/menu/module.kt

-21
This file was deleted.

feature-menu/src/commonMain/kotlin/ru/hotmule/lastik/feature/menu/store/MenuStore.kt

-25
This file was deleted.

0 commit comments

Comments
 (0)