Add koin first declarations in compose module

This commit is contained in:
Shinokuni 2023-03-08 22:45:52 +01:00
parent e372609298
commit 4e09c16d53
8 changed files with 62 additions and 3 deletions

View File

@ -76,8 +76,18 @@ dependencies {
implementation "cafe.adriel.voyager:voyager-bottom-sheet-navigator:$voyager"
implementation "cafe.adriel.voyager:voyager-tab-navigator:$voyager"
implementation "cafe.adriel.voyager:voyager-androidx:$voyager"
//implementation "cafe.adriel.voyager:voyager-koin:$voyager"
implementation "cafe.adriel.voyager:voyager-koin:$voyager"
debugImplementation "androidx.compose.ui:ui-tooling:1.3.3"
implementation "androidx.compose.ui:ui-tooling-preview:1.3.3"
def lifecycle_version = "2.5.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
/*def koin_version = "3.3.3"
implementation "io.insert-koin:koin-core:$koin_version"
implementation "io.insert-koin:koin-android:$koin_version"
implementation "io.insert-koin:koin-androidx-compose:3.4.2"*/
}

View File

@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name=".ReadropsApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"

View File

@ -0,0 +1,10 @@
package com.readrops.app.compose
import com.readrops.app.compose.timelime.TimelineViewModel
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module
val composeAppModule = module {
viewModel { TimelineViewModel(get()) }
}

View File

@ -0,0 +1,23 @@
package com.readrops.app.compose
import android.app.Application
import com.readrops.api.apiModule
import com.readrops.db.dbModule
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
import org.koin.core.logger.Level
open class ReadropsApp : Application() {
override fun onCreate() {
super.onCreate()
startKoin {
androidLogger(Level.ERROR)
androidContext(this@ReadropsApp)
modules(apiModule, dbModule, composeAppModule)
}
}
}

View File

@ -3,12 +3,15 @@ package com.readrops.app.compose.timelime
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import cafe.adriel.voyager.androidx.AndroidScreen
import org.koin.androidx.compose.getViewModel
class TimelineScreen : AndroidScreen() {
@Composable
override fun Content() {
val viewModel = getViewModel<TimelineViewModel>()
Column {
TimelineItem()
}

View File

@ -0,0 +1,12 @@
package com.readrops.app.compose.timelime
import androidx.lifecycle.ViewModel
import com.readrops.db.Database
class TimelineViewModel(
val database: Database
) : ViewModel() {
}

View File

@ -35,7 +35,7 @@ ext {
targetSdkVersion = 33
buildToolsVersion = "33.0.2"
koin_version = "3.1.2"
koin_version = "3.3.3"
}
task clean(type: Delete) {

View File

@ -93,7 +93,7 @@ dependencies {
api "io.insert-koin:koin-core:$rootProject.ext.koin_version"
api "io.insert-koin:koin-android:$rootProject.ext.koin_version"
api "io.insert-koin:koin-android-compat:$rootProject.ext.koin_version"
api "io.insert-koin:koin-androidx-compose:3.4.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'