diff --git a/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/KrailApplication.kt b/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/KrailApplication.kt index 84224088..177e43a1 100644 --- a/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/KrailApplication.kt +++ b/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/KrailApplication.kt @@ -3,18 +3,18 @@ package xyz.ksharma.krail import android.app.Application import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.initialize +import org.koin.android.ext.koin.androidContext +import org.koin.android.ext.koin.androidLogger +import xyz.ksharma.krail.di.initKoin class KrailApplication : Application() { override fun onCreate() { super.onCreate() -// instance = this + initKoin { + androidContext(this@KrailApplication) + androidLogger() + } Firebase.initialize(context = this) } - -/* - companion object { - var instance: Application? = null - } -*/ } diff --git a/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/MainActivity.kt b/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/MainActivity.kt index b863fc3b..34329db8 100644 --- a/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/MainActivity.kt +++ b/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/MainActivity.kt @@ -4,9 +4,6 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge -import org.koin.android.ext.koin.androidContext -import org.koin.android.ext.koin.androidLogger -import org.koin.core.logger.Level class MainActivity : ComponentActivity() { @@ -14,10 +11,7 @@ class MainActivity : ComponentActivity() { enableEdgeToEdge() super.onCreate(savedInstanceState) setContent { - KrailApp { - androidContext(this@MainActivity) - androidLogger(Level.DEBUG) - } + KrailApp() } } } diff --git a/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/di/AppModule.android.kt b/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/di/AppModule.android.kt deleted file mode 100644 index 3dcac494..00000000 --- a/composeApp/src/androidMain/kotlin/xyz/ksharma/krail/di/AppModule.android.kt +++ /dev/null @@ -1,8 +0,0 @@ -package xyz.ksharma.krail.di - -import org.koin.android.ext.koin.androidLogger -import org.koin.dsl.koinConfiguration - -actual fun nativeConfig() = koinConfiguration { - androidLogger() -} diff --git a/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/KrailApp.kt b/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/KrailApp.kt index 5b3e8728..6aa53ba3 100644 --- a/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/KrailApp.kt +++ b/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/KrailApp.kt @@ -1,17 +1,12 @@ package xyz.ksharma.krail import androidx.compose.runtime.Composable -import org.koin.compose.KoinApplication -import org.koin.dsl.KoinAppDeclaration -import xyz.ksharma.krail.di.koinConfig +import org.koin.compose.KoinContext import xyz.ksharma.krail.taj.theme.KrailTheme @Composable -fun KrailApp(koinDeclaration: KoinAppDeclaration? = null) { - KoinApplication(application = { - koinDeclaration?.invoke(this) - koinConfig() - }) { +fun KrailApp() { + KoinContext { KrailTheme { KrailNavHost() } diff --git a/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/di/AppModule.kt b/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/di/KoinApp.kt similarity index 70% rename from composeApp/src/commonMain/kotlin/xyz/ksharma/krail/di/AppModule.kt rename to composeApp/src/commonMain/kotlin/xyz/ksharma/krail/di/KoinApp.kt index fad73dd0..845b2c3f 100644 --- a/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/di/AppModule.kt +++ b/composeApp/src/commonMain/kotlin/xyz/ksharma/krail/di/KoinApp.kt @@ -1,10 +1,10 @@ package xyz.ksharma.krail.di +import org.koin.core.context.startKoin import org.koin.core.module.dsl.viewModel import org.koin.core.qualifier.named import org.koin.dsl.KoinAppDeclaration import org.koin.dsl.includes -import org.koin.dsl.koinConfiguration import org.koin.dsl.module import xyz.ksharma.krail.core.analytics.di.analyticsModule import xyz.ksharma.krail.core.appinfo.di.appInfoModule @@ -16,18 +16,21 @@ import xyz.ksharma.krail.splash.SplashViewModel import xyz.ksharma.krail.trip.planner.network.api.di.networkModule import xyz.ksharma.krail.trip.planner.ui.di.viewModelsModule -val koinConfig = koinConfiguration { - includes(nativeConfig()) - modules( - networkModule, - viewModelsModule, - sandookModule, - splashModule, - appInfoModule, - analyticsModule, - remoteConfigModule, - coroutineDispatchersModule, - ) +fun initKoin(config: KoinAppDeclaration? = null) { + startKoin { + printLogger() + includes(config) + modules( + networkModule, + viewModelsModule, + sandookModule, + splashModule, + appInfoModule, + analyticsModule, + remoteConfigModule, + coroutineDispatchersModule, + ) + } } val splashModule = module { @@ -41,5 +44,3 @@ val splashModule = module { ) } } - -expect fun nativeConfig(): KoinAppDeclaration diff --git a/composeApp/src/iosMain/kotlin/xyz/ksharma/krail/di/AppModule.ios.kt b/composeApp/src/iosMain/kotlin/xyz/ksharma/krail/di/AppModule.ios.kt deleted file mode 100644 index 7d51e1d7..00000000 --- a/composeApp/src/iosMain/kotlin/xyz/ksharma/krail/di/AppModule.ios.kt +++ /dev/null @@ -1,7 +0,0 @@ -package xyz.ksharma.krail.di - -import org.koin.dsl.koinConfiguration - -actual fun nativeConfig() = koinConfiguration { - printLogger() -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fbb150f6..20ff5aea 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -22,7 +22,7 @@ kotlinxCoroutines = "1.10.1" buildkonfigGradlePlugin = "0.15.2" kermit = "2.0.5" sqlDelight = "2.0.2" -koin = "4.0.1-Beta1" +koin = "4.0.2" firebaseGitLive = "2.1.0" [libraries] diff --git a/iosApp/iosApp/iOSApp.swift b/iosApp/iosApp/iOSApp.swift index 59abad64..b2f8d1c5 100644 --- a/iosApp/iosApp/iOSApp.swift +++ b/iosApp/iosApp/iOSApp.swift @@ -2,6 +2,7 @@ import SwiftUI import FirebaseCore import FirebaseFirestore import FirebaseAuth +import KrailApp class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, @@ -14,8 +15,10 @@ class AppDelegate: NSObject, UIApplicationDelegate { @main struct iOSApp: App { - init() { - } + + init() { + KoinAppKt.doInitKoin() + } // register app delegate for Firebase setup @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate