make it possible to connect modules in project
This commit is contained in:
client/src/jsMain/kotlin/dev/inmo/postssystem/client/fsm/ui
features/content
server
44
features/content/binary/client/src/jsMain/kotlin/dev/inmo/postssystem/features/content/binary/client/BinaryContentClientProvider.kt
Normal file
44
features/content/binary/client/src/jsMain/kotlin/dev/inmo/postssystem/features/content/binary/client/BinaryContentClientProvider.kt
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user