merging compose branch

This commit is contained in:
Alexander Nozik 2024-02-03 20:02:07 +03:00
parent 1022b74d23
commit 629923c03a
3 changed files with 15 additions and 7 deletions

View File

@ -1,4 +0,0 @@
job("Build") {
gradlew("openjdk:11", "build")
}

View File

@ -1,9 +1,14 @@
package space.kscience.visionforge.examples
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.html.h2
import kotlinx.html.p
import space.kscience.visionforge.VisionControlEvent
import space.kscience.visionforge.html.*
import space.kscience.visionforge.onClick
import kotlin.time.Duration.Companion.seconds
fun main() = serve {
@ -25,6 +30,7 @@ fun main() = serve {
}
}
}
h2 { +"Control elements" }
vision {
htmlCheckBox {
@ -41,13 +47,19 @@ fun main() = serve {
onValueChange(context) {
pushEvent(this)
}
context.launch {
while (isActive) {
delay(1.seconds)
numberValue = ((numberValue?.toInt() ?: 0) + 1) % 10
}
}
}
}
vision {
button("Click me"){
onClick(context){
button("Click me") {
onClick(context) {
pushEvent(this)
}
}

View File

@ -18,7 +18,7 @@ import space.kscience.visionforge.*
@Serializable
public abstract class VisionOfHtml : AbstractVision() {
public var classes: Set<String>
get() = properties.get(::classes.name,false).stringList?.toSet() ?: emptySet()
get() = properties[::classes.name, false].stringList?.toSet() ?: emptySet()
set(value) {
properties[::classes.name] = value.map { it.asValue() }
}