Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DI: Bump Koin to 4.0.2 #581

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ 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() {

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContent {
KrailApp {
androidContext(this@MainActivity)
androidLogger(Level.DEBUG)
}
KrailApp()
}
}
}

This file was deleted.

11 changes: 3 additions & 8 deletions composeApp/src/commonMain/kotlin/xyz/ksharma/krail/KrailApp.kt
Original file line number Diff line number Diff line change
@@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {
Expand All @@ -41,5 +44,3 @@ val splashModule = module {
)
}
}

expect fun nativeConfig(): KoinAppDeclaration

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 5 additions & 2 deletions iosApp/iosApp/iOSApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import SwiftUI
import FirebaseCore
import FirebaseFirestore
import FirebaseAuth
import KrailApp

class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
Expand All @@ -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
Expand Down