feat: интеграция Koin DI
This commit is contained in:
1 parent
1b54e9cfc9
commit
3f84de7d16
4 files changed
+32
No files matched your search
@@ -74,4 +74,5 @@ dependencies {
|
||||
implementation(libs.androidx.compose.material3.adaptive.nav.suite)
|
||||
|
||||
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||
implementation(libs.koin.androidx.compose)
|
||||
}
|
||||
@@ -10,5 +10,11 @@ class App : Application() {
|
||||
if (Security.getProvider("EdDSA") == null) {
|
||||
Security.addProvider(EdDSASecurityProvider())
|
||||
}
|
||||
|
||||
org.koin.core.context.startKoin {
|
||||
org.koin.android.ext.koin.androidLogger()
|
||||
org.koin.android.ext.koin.androidContext(this@App)
|
||||
org.koin.core.context.loadKoinModules(com.freeturn.app.di.appModule)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.freeturn.app.di
|
||||
|
||||
import com.freeturn.app.data.AppPreferences
|
||||
import com.freeturn.app.domain.AppUpdater
|
||||
import com.freeturn.app.domain.LocalProxyManager
|
||||
import com.freeturn.app.domain.SshRepository
|
||||
import com.freeturn.app.viewmodel.ProxyViewModel
|
||||
import com.freeturn.app.viewmodel.ServerViewModel
|
||||
import com.freeturn.app.viewmodel.SettingsViewModel
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.androidx.viewmodel.dsl.viewModel
|
||||
import org.koin.dsl.module
|
||||
|
||||
val appModule = module {
|
||||
single { AppPreferences(androidContext()) }
|
||||
single { LocalProxyManager(androidContext()) }
|
||||
single { SshRepository(androidContext()) }
|
||||
single { AppUpdater(androidContext()) }
|
||||
|
||||
viewModel { ProxyViewModel(get(), get()) }
|
||||
viewModel { ServerViewModel(get(), get(), get(), androidContext()) }
|
||||
viewModel { SettingsViewModel(get(), get(), get(), get(), androidContext()) }
|
||||
}
|
||||
@@ -14,6 +14,7 @@ jsch = "2.28.0"
|
||||
coroutinesAndroid = "1.10.2"
|
||||
securityCrypto = "1.1.0"
|
||||
eddsa = "0.3.0"
|
||||
koin = "3.5.6"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
@@ -35,6 +36,7 @@ androidx-security-crypto = { group = "androidx.security", name = "security-crypt
|
||||
jsch = { group = "com.github.mwiede", name = "jsch", version.ref = "jsch" }
|
||||
eddsa = { group = "net.i2p.crypto", name = "eddsa", version.ref = "eddsa" }
|
||||
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutinesAndroid" }
|
||||
koin-androidx-compose = { group = "io.insert-koin", name = "koin-androidx-compose", version.ref = "koin" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
||||
Reference in new issue
Block a user