diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 952c7063c..b097d4ceb 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -44,10 +44,23 @@ kotlin { implementation(compose.ui) implementation(compose.components.resources) implementation(compose.components.uiToolingPreview) + + // Lifecycle implementation(libs.jetbrains.lifecycle.viewmodel) + + // Koin + implementation(project.dependencies.platform(libs.koin.bom)) + api(libs.koin.annotations) + implementation(libs.koin.core) + implementation(libs.koin.compose) + implementation(libs.koin.viewmodel) } commonTest.dependencies { implementation(libs.kotlin.test) + + // Koin + implementation(project.dependencies.platform(libs.koin.bom)) + implementation(libs.koin.test) } androidMain.dependencies { implementation(compose.preview) @@ -58,8 +71,24 @@ kotlin { implementation(libs.jetbrains.kotlinx.coroutinesSwing) } } + + // Koin + sourceSets.named("commonMain").configure { + kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") + } } +// Koin +dependencies { + add("kspCommonMainMetadata", libs.koin.annotations) + add("kspAndroid", libs.koin.compiler) + add("kspIosArm64", libs.koin.compiler) + add("kspIosSimulatorArm64", libs.koin.compiler) +} + +tasks.matching { it.name.startsWith("ksp") && it.name != "kspCommonMainKotlinMetadata" } + .configureEach { dependsOn("kspCommonMainKotlinMetadata") } + compose.desktop { application { mainClass = "net.newpipe.app.MainKt" diff --git a/composeApp/src/commonMain/kotlin/net/newpipe/app/App.kt b/composeApp/src/commonMain/kotlin/net/newpipe/app/App.kt index dd5d556c7..5ac426ed8 100644 --- a/composeApp/src/commonMain/kotlin/net/newpipe/app/App.kt +++ b/composeApp/src/commonMain/kotlin/net/newpipe/app/App.kt @@ -6,13 +6,22 @@ package net.newpipe.app import androidx.compose.runtime.Composable +import net.newpipe.app.module.appModules import net.newpipe.app.theme.AppTheme -import org.jetbrains.compose.ui.tooling.preview.Preview +import org.koin.compose.KoinMultiplatformApplication +import org.koin.core.annotation.KoinExperimentalAPI +import org.koin.dsl.koinConfiguration +@OptIn(KoinExperimentalAPI::class) @Composable -@Preview fun App() { - AppTheme { + KoinMultiplatformApplication( + config = koinConfiguration { + modules(appModules) + } + ) { + AppTheme { + } } } diff --git a/composeApp/src/commonMain/kotlin/net/newpipe/app/module/Koin.kt b/composeApp/src/commonMain/kotlin/net/newpipe/app/module/Koin.kt new file mode 100644 index 000000000..12654bb25 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/net/newpipe/app/module/Koin.kt @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2026 NewPipe e.V. + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package net.newpipe.app.module + +import org.koin.dsl.module + +val appModules = module { + +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ad2591358..8c544195e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -26,6 +26,8 @@ hotreload = "1.0.0" jsoup = "1.21.2" junit = "4.13.2" junit-ext = "1.3.0" +koin-annotations = "2.3.1" +koin-bom = "4.1.1" kotlin = "2.2.21" ksp = "2.3.2" ktlint = "1.8.0" @@ -117,6 +119,13 @@ jetbrains-kotlinx-coroutinesSwing = { module = "org.jetbrains.kotlinx:kotlinx-co jetbrains-lifecycle-viewmodel = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycle-jetbrains" } jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" } junit = { module = "junit:junit", version.ref = "junit" } +koin-annotations = { module = "io.insert-koin:koin-annotations", version.ref = "koin-annotations" } +koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin-bom" } +koin-compiler = { module = "io.insert-koin:koin-ksp-compiler", version.ref = "koin-annotations" } +koin-compose = { module = "io.insert-koin:koin-compose" } +koin-core = { module = "io.insert-koin:koin-core" } +koin-test = { module = "io.insert-koin:koin-test" } +koin-viewmodel = { module = "io.insert-koin:koin-compose-viewmodel" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } lisawray-groupie-core = { module = "com.github.lisawray.groupie:groupie", version.ref = "groupie" } lisawray-groupie-viewbinding = { module = "com.github.lisawray.groupie:groupie-viewbinding", version.ref = "groupie" }