Skip to content

Commit

Permalink
Koin and compose dependencies added (#2677)
Browse files Browse the repository at this point in the history
koin modules added and dependencies updated

Koin initialized for AndroidMain and IOSMain

AndroidMain and IOSMain implemented
  • Loading branch information
Saifuddin53 authored Sep 2, 2024
1 parent de3eb47 commit 96ae816
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 10 deletions.
15 changes: 15 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ compose-material = "1.6.8"

countrycodechooserVersion = "1.0"

# Multiplatform Dependencies
compose-plugin = "1.6.11"

detekt = "1.23.5"
dependencyGuard = "0.4.3"
dbflowVersion = "4.2.4"
Expand Down Expand Up @@ -111,6 +114,11 @@ vectordrawableVersion = "1.1.0"

zxingVersion = "3.5.3"

koin = "3.6.0-Beta4"
koinComposeMultiplatform = "1.2.0-Beta4"
navigationCompose = "2.8.0-alpha02"
lifecycleViewModel = "2.8.2"

[bundles]
androidx-compose-ui-test = ["androidx-compose-ui-test", "androidx-compose-ui-test-manifest"]

Expand Down Expand Up @@ -174,6 +182,12 @@ hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref
hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
hilt-android-testing = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "hilt" }

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

squareup-retrofit2 = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofitVersion" }
squareup-retrofit-adapter-rxjava = { module = "com.squareup.retrofit2:adapter-rxjava2", version.ref = "retrofitVersion" }
squareup-retrofit-converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofitVersion" }
Expand Down Expand Up @@ -265,6 +279,7 @@ firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "
firebase-perf = { id = "com.google.firebase.firebase-perf", version.ref = "firebasePerfPlugin" }
dependencyGuard = { id = "com.dropbox.dependency-guard", version.ref = "dependencyGuard" }
secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secrets" }
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" }
Expand Down
15 changes: 14 additions & 1 deletion shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
kotlin("multiplatform")
alias(libs.plugins.android.library)
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.jetbrainsCompose)
}

kotlin {
Expand All @@ -24,8 +25,20 @@ kotlin {
}

sourceSets {
androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)

implementation(libs.koin.android)
implementation(libs.koin.androidx.compose)
}
commonMain.dependencies {
//put your multiplatform dependencies here
implementation(compose.material)
implementation(compose.material3)
api(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.koin.compose.viewmodel)
}
commonTest.dependencies {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.mifos.mobile.shared

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
App()
}
}
}

@Preview
@Composable
fun AppAndroidPreview() {
App()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.mifos.mobile.shared

import android.app.Application
import org.koin.android.ext.koin.androidContext
import org.mifos.mobile.shared.di.initKoin

class MyApplication: Application() {

override fun onCreate() {
super.onCreate()
initKoin {
androidContext(this@MyApplication)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.mifos.mobile.shared.di

import org.koin.core.module.Module

actual val platformModule: Module
get() = TODO("Not yet implemented")
29 changes: 29 additions & 0 deletions shared/src/commonMain/kotlin/org/mifos/mobile/shared/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.mifos.mobile.shared

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import org.koin.compose.KoinContext

@Composable
fun App() {
KoinContext {
Box(
modifier = Modifier
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text(
text = "Mifos Mobile",
style = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.Bold,
color = MaterialTheme.colorScheme.onSurface)
)
}
}
}

This file was deleted.

10 changes: 10 additions & 0 deletions shared/src/commonMain/kotlin/org/mifos/mobile/shared/di/Modules.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.mifos.mobile.shared.di

import org.koin.core.module.Module
import org.koin.dsl.module

expect val platformModule: Module

val sharedModule = module {
single { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.mifos.mobile.shared.di

import org.koin.core.context.startKoin
import org.koin.dsl.KoinAppDeclaration

fun initKoin(config: KoinAppDeclaration? = null) {
startKoin {
config?.invoke(this)
modules(sharedModule, platformModule)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.mifos.mobile.shared

import androidx.compose.ui.window.ComposeUIViewController
import org.mifos.mobile.shared.di.initKoin

fun MainViewController() = ComposeUIViewController(
configure = {
initKoin()
}
) {
App()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.mifos.mobile.shared.di

import org.koin.core.module.Module

actual val platformModule: Module
get() = TODO("Not yet implemented")

0 comments on commit 96ae816

Please sign in to comment.