Skip to content

Commit

Permalink
Added Koin Dependency (#31)
Browse files Browse the repository at this point in the history
* Added Koin Dependency

At this stage, have only added in build.gradle.kts file under comman
code.

* Added sample code on android side

* Added di under shared package

* Added Koin under ios

* Fix - Renaming files

* Added Koin to Android Node

* Fix - Reformat the code

* Fix - fomatting again
  • Loading branch information
nis-ship-it authored Nov 12, 2024
1 parent 9b702b3 commit 3de24c6
Show file tree
Hide file tree
Showing 23 changed files with 296 additions and 147 deletions.
2 changes: 2 additions & 0 deletions bisqapps/androidClient/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ kotlin {
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
implementation(libs.koin.core)
implementation(libs.koin.android)
}
androidUnitTest.dependencies {
implementation(libs.kotlin.test)
Expand Down
1 change: 1 addition & 0 deletions bisqapps/androidClient/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import androidx.compose.ui.tooling.preview.Preview
import network.bisq.mobile.domain.data.repository.GreetingRepository
import network.bisq.mobile.presentation.MainPresenter
import network.bisq.mobile.presentation.ui.App
import org.koin.android.ext.android.inject

class MainActivity : ComponentActivity() {
private val presenter = MainPresenter(GreetingRepository())
private val presenter: MainPresenter by inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
presenter.attachView(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package network.bisq.mobile.client

import android.app.Application
import network.bisq.mobile.client.di.androidModule
import network.bisq.mobile.domain.di.domainModule
import network.bisq.mobile.presentation.di.presentationModule
import org.koin.android.ext.koin.androidContext

import org.koin.core.context.startKoin

class MainApplication: Application() {
override fun onCreate() {
super.onCreate()

startKoin {
androidContext(this@MainApplication)
modules(domainModule + presentationModule + androidModule)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package network.bisq.mobile.client.di

import network.bisq.mobile.presentation.MainPresenter
import org.koin.dsl.module

val androidModule = module {
// add your own modules
}
3 changes: 3 additions & 0 deletions bisqapps/androidNode/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,7 @@ dependencies {
implementation(libs.protobuf.lite)
implementation(libs.protobuf.gradle.plugin)
implementation(libs.protoc)

implementation(libs.koin.core)
implementation(libs.koin.android)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import androidx.compose.ui.tooling.preview.Preview
import network.bisq.mobile.domain.data.repository.GreetingRepository
import network.bisq.mobile.presentation.MainPresenter
import network.bisq.mobile.presentation.ui.App
import org.koin.android.ext.android.inject

class MainActivity : ComponentActivity() {
// TODO use a DI framework to provide implementations
private val greetingRepository = GreetingRepository(AndroidNodeGreetingFactory())
private val presenter = MainPresenter(greetingRepository)
private val presenter : MainPresenter by inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
presenter.attachView(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package network.bisq.mobile.android.node

import android.app.Application
import network.bisq.mobile.android.node.di.androidNodeModule
import network.bisq.mobile.domain.di.domainModule
import network.bisq.mobile.presentation.di.presentationModule
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin
import org.koin.dsl.module

class MainApplication : Application() {
override fun onCreate() {
super.onCreate()

startKoin {
androidContext(this@MainApplication)
module { androidNodeModule + presentationModule + domainModule }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package network.bisq.mobile.android.node.di

import network.bisq.mobile.android.node.AndroidNodeGreetingFactory
import network.bisq.mobile.domain.GreetingFactory
import org.koin.dsl.module

val androidNodeModule = module {
single<GreetingFactory> { AndroidNodeGreetingFactory() }
}
11 changes: 10 additions & 1 deletion bisqapps/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ i2p-lib = { strictly = '1.8.0' }
i2p-v2 = { strictly = '2.4.0' }
jackson-lib = { strictly = '2.17.2' }

koin = "4.0.0"
koin-compose = "4.0.0"
koin-android = "4.0.0"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
Expand Down Expand Up @@ -124,6 +128,11 @@ jackson-core = { module = 'com.fasterxml.jackson.core:jackson-core', version.ref
jackson-annotations = { module = 'com.fasterxml.jackson.core:jackson-annotations', version.ref = 'jackson-lib' }
jackson-databind = { module = 'com.fasterxml.jackson.core:jackson-databind', version.ref = 'jackson-lib' }

# koin
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koin-compose" }
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin-android" }

[bundles]
glassfish-jersey = ['glassfish-jersey-jdk-http', 'glassfish-jersey-json-jackson', 'glassfish-jersey-inject-hk2', 'glassfish-jaxb-runtime']
grpc = ['grpc-protobuf', 'grpc-services', 'grpc-stub']
Expand All @@ -139,4 +148,4 @@ jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
buildconfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildconfig" }
protobuf = { id = "com.google.protobuf", version.ref = "protobuf" }
protobuf = { id = "com.google.protobuf", version.ref = "protobuf" }
8 changes: 4 additions & 4 deletions bisqapps/iosClient/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- domain (0.0.1)
- presentation (0.0.1)
- domain (0.0.2)
- presentation (0.0.2)

DEPENDENCIES:
- domain (from `../shared/domain`)
Expand All @@ -13,8 +13,8 @@ EXTERNAL SOURCES:
:path: "../shared/presentation"

SPEC CHECKSUMS:
domain: 398a8494649d845aa57f022a9ffb8be987298e80
presentation: afb0cb7a678bc1771eb3882a43a82f0acdff0258
domain: 47abf0eea12f1e6f5b4f15c05dd23f437ec5478f
presentation: 55df2024e1ee347459ecf9349d6e1fde59450eef

PODFILE CHECKSUM: e4e5bb187d8247572973af90a35b57b84c96b4c6

Expand Down
2 changes: 1 addition & 1 deletion bisqapps/iosClient/Pods/Local Podspecs/domain.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions bisqapps/iosClient/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3de24c6

Please sign in to comment.