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

View File

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