make it possible to connect modules in project

This commit is contained in:
2022-03-17 23:23:35 +06:00
parent 31047f9382
commit 1dafe0a679
8 changed files with 78 additions and 41 deletions

View File

@@ -2,6 +2,7 @@ plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
id "com.android.library"
alias(libs.plugins.compose)
}
apply from: "$mppProjectWithSerializationPresetPath"
@@ -12,6 +13,8 @@ kotlin {
dependencies {
api project(":postssystem.features.content.binary.common")
api project(":postssystem.features.common.client")
api project(":postssystem.features.content.client")
api libs.microutils.common.compose
}
}
}

View File

@@ -0,0 +1,44 @@
package dev.inmo.postssystem.features.content.binary.client
import androidx.compose.runtime.*
import dev.inmo.jsuikit.elements.DefaultButton
import dev.inmo.jsuikit.modifiers.UIKitWidth
import dev.inmo.micro_utils.common.selectFile
import dev.inmo.postssystem.features.common.common.*
import dev.inmo.postssystem.features.content.client.ContentClientProvider
import dev.inmo.postssystem.features.content.common.*
import org.koin.core.module.Module
object LoadingClientModule : ModuleLoader {
init {
AdditionalModules.addModule(this)
}
override fun Module.load() {
singleWithRandomQualifier<ContentClientProvider> {
BinaryContentClientProvider
}
}
}
private val loadingClientModuleForLoadingAtRuntime = LoadingClientModule
object BinaryContentClientProvider : ContentClientProvider {
override fun contentTypeNameForUser(): String = "File"
@Composable
override fun renderNewInstance(state: MutableState<Content?>) {
console.log(state.value)
val value = (state.value as? BinaryContent)
if (value == null) {
selectFile {
state.value = it.binaryContent()
}
}
DefaultButton(value ?.filename ?.name ?: "Select file", UIKitWidth.Expand) {
selectFile {
state.value = it.binaryContent()
}
}
}
}