File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 4 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ kotlin {
4545
4646 // Koin Android
4747 implementation(libs.koin.android)
48+ implementation(libs.koin.androidx.compose)
4849 }
4950 }
5051 }
Original file line number Diff line number Diff line change @@ -11,21 +11,26 @@ import com.hoc081098.solivagant.navigation.NavDestination
1111import com.hoc081098.solivagant.navigation.NavHost
1212import io.github.aakira.napier.Napier
1313import kotlinx.collections.immutable.toImmutableSet
14+ import org.koin.androidx.compose.KoinAndroidContext
15+ import org.koin.core.annotation.KoinExperimentalAPI
1416
17+ @OptIn(KoinExperimentalAPI ::class )
1518class MainActivity : AppCompatActivity () {
1619 override fun onCreate (savedInstanceState : Bundle ? ) {
1720 super .onCreate(savedInstanceState)
1821
1922 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+ }
2934 }
3035 }
3136 }
Original file line number Diff line number Diff line change @@ -20,11 +20,11 @@ import java.util.logging.Level
2020import java.util.logging.SimpleFormatter
2121import java.util.logging.StreamHandler
2222import kotlinx.collections.immutable.toImmutableSet
23- import org.koin.compose.KoinApplication
23+ import org.koin.compose.KoinContext
2424import org.koin.compose.koinInject
25+ import org.koin.core.context.startKoin
2526import org.koin.core.logger.Level as KoinLoggerLevel
2627import org.koin.core.logger.PrintLogger
27- import org.koin.dsl.KoinAppDeclaration
2828
2929fun main () {
3030 Napier .base(
@@ -36,7 +36,7 @@ fun main() {
3636 ),
3737 )
3838
39- val koinApplication : KoinAppDeclaration = {
39+ startKoin {
4040 logger(PrintLogger (level = KoinLoggerLevel .DEBUG ))
4141
4242 modules(
@@ -63,7 +63,7 @@ fun main() {
6363 LifecycleOwnerProvider (
6464 lifecycleOwner = rememberLifecycleOwner(lifecycleRegistry),
6565 ) {
66- KoinApplication (application = koinApplication) {
66+ KoinContext {
6767 AppTheme {
6868 NavHost (
6969 startRoute = SearchPhotoScreenRoute ,
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ ksp = "1.9.22-1.0.16"
3939
4040[libraries ]
4141koin-android = { module = " io.insert-koin:koin-android" , version.ref = " koinVersion" }
42+ koin-androidx-compose = { module = " io.insert-koin:koin-androidx-compose" , version.ref = " koinVersion" }
4243kotlin-stdlib = { module = " org.jetbrains.kotlin:kotlin-stdlib" , version.ref = " kotlin" }
4344kotlin-parcelize = { module = " org.jetbrains.kotlin:kotlin-parcelize-runtime" , version.ref = " kotlin" }
4445kotlin-compiler = { module = " org.jetbrains.kotlin:kotlin-compiler-embeddable" , version.ref = " kotlin" }
You can’t perform that action at this time.
0 commit comments