unbuildable version
This commit is contained in:
client/src/jsMain/kotlin/dev/inmo/postssystem/client/fsm/ui
features/content
client
src
jsMain
kotlin
dev
inmo
postssystem
features
content
client
text
client
gradle
kotlin-js-store
@ -1,39 +1,11 @@
|
||||
package dev.inmo.postssystem.features.content.client
|
||||
|
||||
import androidx.compose.runtime.*
|
||||
import dev.inmo.postssystem.features.content.common.Content
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import org.w3c.dom.HTMLElement
|
||||
|
||||
interface ContentClientProvider {
|
||||
fun contentTypeNameForUser(): String
|
||||
|
||||
interface ContentRenderer {
|
||||
val state: State<Content?>
|
||||
val render: @Composable () -> Unit
|
||||
|
||||
class Default<T : Content?>(
|
||||
initValue: T,
|
||||
private val onRender: @Composable (MutableState<T>) -> Unit
|
||||
) : ContentRenderer {
|
||||
private val mutableState = mutableStateOf(initValue)
|
||||
override val state: State<Content?>
|
||||
get() = mutableState
|
||||
|
||||
override val render: @Composable () -> Unit = @Composable {
|
||||
onRender(mutableState)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun <T: Content> default(onRender: @Composable (MutableState<T?>) -> Unit) = Default(
|
||||
null,
|
||||
onRender
|
||||
)
|
||||
fun <T: Content?> default(initValue: T, onRender: @Composable (MutableState<T>) -> Unit) = Default(
|
||||
initValue,
|
||||
onRender
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun createNewContentRenderer(): ContentRenderer
|
||||
fun drawNewContent(root: HTMLElement): StateFlow<Content>
|
||||
}
|
||||
|
Reference in New Issue
Block a user