45 lines
1.4 KiB
Kotlin
45 lines
1.4 KiB
Kotlin
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()
|
|
}
|
|
}
|
|
}
|
|
}
|