Skip to content

Commit 435dcf8

Browse files
authored
Merge pull request #86 from stslex/dev
update libraries
2 parents 5b2d29d + f0e755e commit 435dcf8

File tree

91 files changed

+260
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+260
-577
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
local.properties
1212
play_config.*
1313
keystore.*
14-
Gemfile.lock
14+
Gemfile.lock

app/src/main/java/st/slex/csplashscreen/SplashApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class SplashApplication : Application() {
1616

1717
private fun initKoin() {
1818
startKoin {
19+
androidContext(this@SplashApplication)
1920
androidLogger(
2021
level = if (BuildConfig.DEBUG) Level.ERROR else Level.NONE
2122
)
22-
androidContext(this@SplashApplication)
2323
modules(AppModules)
2424
}
2525
}

app/src/main/java/st/slex/csplashscreen/di/AppComponent.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package st.slex.csplashscreen.di
22

3-
import org.koin.androidx.viewmodel.dsl.viewModelOf
3+
import org.koin.core.module.dsl.viewModelOf
44
import org.koin.dsl.module
55
import st.slex.csplashscreen.core.collection.di.moduleCoreCollection
66
import st.slex.csplashscreen.core.core.di.moduleCore
@@ -10,8 +10,8 @@ import st.slex.csplashscreen.core.network.di.moduleCoreNetwork
1010
import st.slex.csplashscreen.core.photos.di.moduleCorePhotos
1111
import st.slex.csplashscreen.feature.collection.di.moduleFeatureSingleCollection
1212
import st.slex.csplashscreen.feature.favourite.di.moduleFeatureFavourite
13-
import st.slex.csplashscreen.feature.feature_photo_detail.di.moduleFeatureImageDetail
1413
import st.slex.csplashscreen.feature.home.di.moduleFeatureHome
14+
import st.slex.csplashscreen.feature.photo_detail.di.moduleFeatureImageDetail
1515
import st.slex.csplashscreen.feature.search.di.moduleFeatureSearchPhotos
1616
import st.slex.csplashscreen.feature.user.di.moduleFeatureUser
1717
import st.slex.csplashscreen.ui.InitialAppViewModel
@@ -33,5 +33,6 @@ val AppModules = listOf(
3333
moduleFeatureHome,
3434
moduleFeatureImageDetail,
3535
moduleFeatureSearchPhotos,
36-
moduleFeatureUser
36+
moduleFeatureUser,
37+
moduleCoreNavigation
3738
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package st.slex.csplashscreen.di
2+
3+
import org.koin.core.module.dsl.bind
4+
import org.koin.core.module.dsl.singleOf
5+
import org.koin.dsl.module
6+
import st.slex.csplashscreen.core.navigation.navigator.Navigator
7+
import st.slex.csplashscreen.core.navigation.navigator.NavigatorImpl
8+
import st.slex.csplashscreen.core.navigation.navigator.holder.NavigatorHolder
9+
import st.slex.csplashscreen.navigation.BaseNavigationHolder
10+
import st.slex.csplashscreen.navigation.NavigatorHolderImpl
11+
12+
val moduleCoreNavigation = module {
13+
val navigatorHolder = NavigatorHolderImpl()
14+
single<NavigatorHolder> { navigatorHolder }
15+
single<BaseNavigationHolder> { navigatorHolder }
16+
17+
singleOf(::NavigatorImpl) { bind<Navigator>() }
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package st.slex.csplashscreen.navigation
2+
3+
import st.slex.csplashscreen.core.navigation.navigator.holder.NavigatorHolder
4+
import st.slex.csplashscreen.ui.components.NavHostControllerHolder
5+
6+
interface BaseNavigationHolder : NavigatorHolder {
7+
8+
fun setNavController(navHostController: NavHostControllerHolder)
9+
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package st.slex.csplashscreen.navigation
2+
3+
import androidx.navigation.NavHostController
4+
import st.slex.csplashscreen.ui.components.NavHostControllerHolder
5+
6+
class NavigatorHolderImpl : BaseNavigationHolder {
7+
8+
private var _navigator: NavHostController? = null
9+
10+
override val navigator: NavHostController
11+
get() = requireNotNull(_navigator) { "NavController is not initialized" }
12+
13+
override fun setNavController(navHostController: NavHostControllerHolder) {
14+
_navigator = navHostController.navController
15+
}
16+
17+
}

app/src/main/java/st/slex/csplashscreen/ui/MainActivity.kt

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ package st.slex.csplashscreen.ui
33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
6-
import androidx.compose.runtime.Composable
7-
import androidx.compose.runtime.Stable
86
import androidx.compose.runtime.remember
97
import androidx.core.view.WindowCompat
108
import androidx.navigation.compose.rememberNavController
11-
import org.koin.androidx.compose.getKoin
129
import org.koin.androidx.compose.koinViewModel
13-
import st.slex.csplashscreen.core.navigation.di.moduleCoreNavigation
10+
import org.koin.compose.getKoin
1411
import st.slex.csplashscreen.core.ui.theme.AppTheme
12+
import st.slex.csplashscreen.navigation.BaseNavigationHolder
1513
import st.slex.csplashscreen.ui.components.NavHostControllerHolder
1614

1715
class MainActivity : ComponentActivity() {
@@ -23,13 +21,10 @@ class MainActivity : ComponentActivity() {
2321
setContent {
2422
AppTheme {
2523
val navHostControllerHolder = NavHostControllerHolder(rememberNavController())
26-
SetupComposeDependencies(navHostControllerHolder)
24+
getKoin().get<BaseNavigationHolder>().setNavController(navHostControllerHolder)
2725

2826
val viewModel = koinViewModel<InitialAppViewModel>()
2927
InitialApp(
30-
/*TODO AFTER reconfiguration controller in VM don't change it State,
31-
so it need to have latest instance.
32-
Need Research to find more efficient way */
3328
navControllerHolder = navHostControllerHolder,
3429
onBottomAppBarClick = remember {
3530
{ screen ->
@@ -40,16 +35,4 @@ class MainActivity : ComponentActivity() {
4035
}
4136
}
4237
}
43-
44-
@Composable
45-
@Stable
46-
private fun SetupComposeDependencies(
47-
holder: NavHostControllerHolder
48-
) {
49-
getKoin().loadModules(
50-
listOf(
51-
moduleCoreNavigation(holder.navController),
52-
)
53-
)
54-
}
5538
}

app/src/main/java/st/slex/csplashscreen/ui/components/NavigationHost.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import st.slex.csplashscreen.core.navigation.Screen
1212
import st.slex.csplashscreen.core.ui.theme.LocalSharedTransitionScope
1313
import st.slex.csplashscreen.feature.collection.navigation.singleCollectionGraph
1414
import st.slex.csplashscreen.feature.favourite.navigation.favouriteGraph
15-
import st.slex.csplashscreen.feature.feature_photo_detail.navigation.imageDetailGraph
15+
import st.slex.csplashscreen.feature.photo_detail.navigation.imageDetailGraph
1616
import st.slex.csplashscreen.feature.home.navigation.homeGraph
1717
import st.slex.csplashscreen.feature.search.navigation.searchPhotosGraph
1818
import st.slex.csplashscreen.feature.user.navigation.userGraph

app/src/test/kotlin/di/AppModuleTest.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package di
22

33
import android.content.Context
4-
import androidx.navigation.NavHostController
54
import kotlinx.coroutines.Dispatchers
65
import kotlinx.coroutines.ExperimentalCoroutinesApi
76
import kotlinx.coroutines.test.StandardTestDispatcher
@@ -17,7 +16,6 @@ import org.koin.test.KoinTest
1716
import org.koin.test.check.checkModules
1817
import org.koin.test.mock.MockProviderRule
1918
import org.mockito.Mockito
20-
import st.slex.csplashscreen.core.navigation.di.moduleCoreNavigation
2119
import st.slex.csplashscreen.di.AppModules
2220

2321
class AppModuleTest : KoinTest {
@@ -33,13 +31,8 @@ class AppModuleTest : KoinTest {
3331

3432
@Test
3533
fun `check koin configuration`() {
36-
val navController = Mockito.mock(NavHostController::class.java)
37-
3834
koinApplication {
39-
modules(
40-
listOf(moduleCoreNavigation(navController)) +
41-
AppModules
42-
)
35+
modules(AppModules)
4336
checkModules {
4437
withInstance<Context>()
4538
}

build-logic/dependencies/src/main/kotlin/AppExt.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import org.gradle.kotlin.dsl.getByType
66

77
object AppExt {
88

9+
const val APP_PREFIX = "st.slex.csplashscreen"
10+
911
/**
1012
* Get the version catalog for the project
1113
* */

0 commit comments

Comments
 (0)