unworkable version of content adding

This commit is contained in:
InsanusMokrassar 2022-03-14 15:10:34 +06:00
parent ab10f20723
commit 93b6902080
4 changed files with 11 additions and 12 deletions

View File

@ -10,12 +10,13 @@ import dev.inmo.postssystem.client.ui.fsm.CreatePostUIFSMState
import dev.inmo.postssystem.client.ui.fsm.UIFSMState
import dev.inmo.postssystem.client.utils.renderComposableAndLinkToContext
import dev.inmo.postssystem.features.content.client.ContentClientProvider
import dev.inmo.postssystem.features.content.common.Content
import dev.inmo.postssystem.services.posts.client.ui.create.PostCreateUIViewModel
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.compose.web.dom.Div
import org.jetbrains.compose.web.dom.Text
import org.w3c.dom.HTMLElement
import org.w3c.dom.Text
class PostCreateView(
private val createPostCreateUIModel: PostCreateUIViewModel,
@ -35,9 +36,9 @@ class PostCreateView(
UIKitFlex.Alignment.Horizontal.Center
) {
Div ({ include(UIKitWidth.Fixed.XLarge) }) {
contentProvidersList.forEachIndexed { i, it ->
contentProvidersList.forEachIndexed { i, renderer ->
Flex(UIKitWidth.Expand) {
it.render()
renderer.render()
DefaultButton("Remove") {
contentProvidersList.removeAt(i)

View File

@ -8,9 +8,7 @@ interface ContentClientProvider {
interface ContentRenderer {
val state: State<Content?>
@Composable
fun render()
val render: @Composable () -> Unit
class Default<T : Content?>(
initValue: T,
@ -20,8 +18,9 @@ interface ContentClientProvider {
override val state: State<Content?>
get() = mutableState
@Composable
override fun render() { onRender(mutableState) }
override val render: @Composable () -> Unit = @Composable {
onRender(mutableState)
}
}
companion object {

View File

@ -8,7 +8,6 @@ import dev.inmo.postssystem.features.content.client.ContentClientProvider
import dev.inmo.postssystem.features.content.common.Content
import dev.inmo.postssystem.features.content.text.common.TextContent
import org.jetbrains.compose.web.dom.TextArea
import org.w3c.dom.Text
val loadingClientModule = ModuleLoader {
singleWithRandomQualifier<ContentClientProvider> {
@ -22,8 +21,8 @@ object TextContentClientProvider : ContentClientProvider {
override fun contentTypeNameForUser(): String = "Text"
override fun createNewContentRenderer(): ContentClientProvider.ContentRenderer {
return ContentClientProvider.ContentRenderer.default(TextContent("")) { state ->
TextArea(state.value.text) {
return ContentClientProvider.ContentRenderer.default<TextContent> @Composable { state ->
TextArea(state.value ?. text ?: "") {
include(UIKitWidth.Expand)
onInput { state.value = TextContent(it.value) }
}

File diff suppressed because one or more lines are too long