File tree 4 files changed +20
-13
lines changed
src/androidMain/kotlin/com/hoc081098/compose_multiplatform_kmpviewmodel_sample
desktopApp/src/jvmMain/kotlin/com/hoc081098/compose_multiplatform_kmpviewmodel_sample
4 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ kotlin {
45
45
46
46
// Koin Android
47
47
implementation(libs.koin.android)
48
+ implementation(libs.koin.androidx.compose)
48
49
}
49
50
}
50
51
}
Original file line number Diff line number Diff line change @@ -11,21 +11,26 @@ import com.hoc081098.solivagant.navigation.NavDestination
11
11
import com.hoc081098.solivagant.navigation.NavHost
12
12
import io.github.aakira.napier.Napier
13
13
import kotlinx.collections.immutable.toImmutableSet
14
+ import org.koin.androidx.compose.KoinAndroidContext
15
+ import org.koin.core.annotation.KoinExperimentalAPI
14
16
17
+ @OptIn(KoinExperimentalAPI ::class )
15
18
class MainActivity : AppCompatActivity () {
16
19
override fun onCreate (savedInstanceState : Bundle ? ) {
17
20
super .onCreate(savedInstanceState)
18
21
19
22
setContent {
20
- AppTheme {
21
- NavHost (
22
- startRoute = SearchPhotoScreenRoute ,
23
- destinations = koinInjectSetMultibinding<NavDestination >(AllDestinationsQualifier )
24
- .let { remember(it) { it.toImmutableSet() } },
25
- destinationChangedCallback = { route ->
26
- Napier .d(message = " Destination changed: $route " , tag = " MainActivity" )
27
- },
28
- )
23
+ KoinAndroidContext {
24
+ AppTheme {
25
+ NavHost (
26
+ startRoute = SearchPhotoScreenRoute ,
27
+ destinations = koinInjectSetMultibinding<NavDestination >(AllDestinationsQualifier )
28
+ .let { remember(it) { it.toImmutableSet() } },
29
+ destinationChangedCallback = { route ->
30
+ Napier .d(message = " Destination changed: $route " , tag = " MainActivity" )
31
+ },
32
+ )
33
+ }
29
34
}
30
35
}
31
36
}
Original file line number Diff line number Diff line change @@ -20,11 +20,11 @@ import java.util.logging.Level
20
20
import java.util.logging.SimpleFormatter
21
21
import java.util.logging.StreamHandler
22
22
import kotlinx.collections.immutable.toImmutableSet
23
- import org.koin.compose.KoinApplication
23
+ import org.koin.compose.KoinContext
24
24
import org.koin.compose.koinInject
25
+ import org.koin.core.context.startKoin
25
26
import org.koin.core.logger.Level as KoinLoggerLevel
26
27
import org.koin.core.logger.PrintLogger
27
- import org.koin.dsl.KoinAppDeclaration
28
28
29
29
fun main () {
30
30
Napier .base(
@@ -36,7 +36,7 @@ fun main() {
36
36
),
37
37
)
38
38
39
- val koinApplication : KoinAppDeclaration = {
39
+ startKoin {
40
40
logger(PrintLogger (level = KoinLoggerLevel .DEBUG ))
41
41
42
42
modules(
@@ -63,7 +63,7 @@ fun main() {
63
63
LifecycleOwnerProvider (
64
64
lifecycleOwner = rememberLifecycleOwner(lifecycleRegistry),
65
65
) {
66
- KoinApplication (application = koinApplication) {
66
+ KoinContext {
67
67
AppTheme {
68
68
NavHost (
69
69
startRoute = SearchPhotoScreenRoute ,
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ ksp = "1.9.22-1.0.16"
39
39
40
40
[libraries ]
41
41
koin-android = { module = " io.insert-koin:koin-android" , version.ref = " koinVersion" }
42
+ koin-androidx-compose = { module = " io.insert-koin:koin-androidx-compose" , version.ref = " koinVersion" }
42
43
kotlin-stdlib = { module = " org.jetbrains.kotlin:kotlin-stdlib" , version.ref = " kotlin" }
43
44
kotlin-parcelize = { module = " org.jetbrains.kotlin:kotlin-parcelize-runtime" , version.ref = " kotlin" }
44
45
kotlin-compiler = { module = " org.jetbrains.kotlin:kotlin-compiler-embeddable" , version.ref = " kotlin" }
You can’t perform that action at this time.
0 commit comments