unworkable version of content adding
This commit is contained in:
parent
ab10f20723
commit
93b6902080
@ -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.ui.fsm.UIFSMState
|
||||||
import dev.inmo.postssystem.client.utils.renderComposableAndLinkToContext
|
import dev.inmo.postssystem.client.utils.renderComposableAndLinkToContext
|
||||||
import dev.inmo.postssystem.features.content.client.ContentClientProvider
|
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 dev.inmo.postssystem.services.posts.client.ui.create.PostCreateUIViewModel
|
||||||
import kotlinx.coroutines.CompletableDeferred
|
import kotlinx.coroutines.CompletableDeferred
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import org.jetbrains.compose.web.dom.Div
|
import org.jetbrains.compose.web.dom.Div
|
||||||
|
import org.jetbrains.compose.web.dom.Text
|
||||||
import org.w3c.dom.HTMLElement
|
import org.w3c.dom.HTMLElement
|
||||||
import org.w3c.dom.Text
|
|
||||||
|
|
||||||
class PostCreateView(
|
class PostCreateView(
|
||||||
private val createPostCreateUIModel: PostCreateUIViewModel,
|
private val createPostCreateUIModel: PostCreateUIViewModel,
|
||||||
@ -35,9 +36,9 @@ class PostCreateView(
|
|||||||
UIKitFlex.Alignment.Horizontal.Center
|
UIKitFlex.Alignment.Horizontal.Center
|
||||||
) {
|
) {
|
||||||
Div ({ include(UIKitWidth.Fixed.XLarge) }) {
|
Div ({ include(UIKitWidth.Fixed.XLarge) }) {
|
||||||
contentProvidersList.forEachIndexed { i, it ->
|
contentProvidersList.forEachIndexed { i, renderer ->
|
||||||
Flex(UIKitWidth.Expand) {
|
Flex(UIKitWidth.Expand) {
|
||||||
it.render()
|
renderer.render()
|
||||||
|
|
||||||
DefaultButton("Remove") {
|
DefaultButton("Remove") {
|
||||||
contentProvidersList.removeAt(i)
|
contentProvidersList.removeAt(i)
|
||||||
|
@ -8,9 +8,7 @@ interface ContentClientProvider {
|
|||||||
|
|
||||||
interface ContentRenderer {
|
interface ContentRenderer {
|
||||||
val state: State<Content?>
|
val state: State<Content?>
|
||||||
|
val render: @Composable () -> Unit
|
||||||
@Composable
|
|
||||||
fun render()
|
|
||||||
|
|
||||||
class Default<T : Content?>(
|
class Default<T : Content?>(
|
||||||
initValue: T,
|
initValue: T,
|
||||||
@ -20,8 +18,9 @@ interface ContentClientProvider {
|
|||||||
override val state: State<Content?>
|
override val state: State<Content?>
|
||||||
get() = mutableState
|
get() = mutableState
|
||||||
|
|
||||||
@Composable
|
override val render: @Composable () -> Unit = @Composable {
|
||||||
override fun render() { onRender(mutableState) }
|
onRender(mutableState)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -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.common.Content
|
||||||
import dev.inmo.postssystem.features.content.text.common.TextContent
|
import dev.inmo.postssystem.features.content.text.common.TextContent
|
||||||
import org.jetbrains.compose.web.dom.TextArea
|
import org.jetbrains.compose.web.dom.TextArea
|
||||||
import org.w3c.dom.Text
|
|
||||||
|
|
||||||
val loadingClientModule = ModuleLoader {
|
val loadingClientModule = ModuleLoader {
|
||||||
singleWithRandomQualifier<ContentClientProvider> {
|
singleWithRandomQualifier<ContentClientProvider> {
|
||||||
@ -22,8 +21,8 @@ object TextContentClientProvider : ContentClientProvider {
|
|||||||
override fun contentTypeNameForUser(): String = "Text"
|
override fun contentTypeNameForUser(): String = "Text"
|
||||||
|
|
||||||
override fun createNewContentRenderer(): ContentClientProvider.ContentRenderer {
|
override fun createNewContentRenderer(): ContentClientProvider.ContentRenderer {
|
||||||
return ContentClientProvider.ContentRenderer.default(TextContent("")) { state ->
|
return ContentClientProvider.ContentRenderer.default<TextContent> @Composable { state ->
|
||||||
TextArea(state.value.text) {
|
TextArea(state.value ?. text ?: "") {
|
||||||
include(UIKitWidth.Expand)
|
include(UIKitWidth.Expand)
|
||||||
onInput { state.value = TextContent(it.value) }
|
onInput { state.value = TextContent(it.value) }
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user