Fix serialization problems in Group
This commit is contained in:
parent
7e037b57fc
commit
62a76f2c86
@ -13,10 +13,12 @@ import kotlinx.serialization.Transient
|
||||
@SerialName("vision.group")
|
||||
public open class VisionGroupBase : VisionBase(), MutableVisionGroup {
|
||||
|
||||
//protected abstract val _children: MutableMap<NameToken, T>
|
||||
|
||||
/**
|
||||
* Internal mutable container for group children
|
||||
* TODO made protected due to https://github.com/Kotlin/kotlinx.serialization/issues/1200
|
||||
*/
|
||||
@SerialName("children")
|
||||
protected val childrenInternal = LinkedHashMap<NameToken, Vision>()
|
||||
protected open val childrenInternal: MutableMap<NameToken, Vision> = LinkedHashMap()
|
||||
|
||||
/**
|
||||
* A map of top level named children
|
||||
|
@ -93,13 +93,17 @@ public fun MutableVisionGroup.group(name: String, action: SolidGroup.() -> Unit
|
||||
*/
|
||||
@Serializable(PrototypesSerializer::class)
|
||||
internal class Prototypes(
|
||||
override var children: MutableMap<NameToken, Vision> = LinkedHashMap(),
|
||||
children: Map<NameToken, Vision> = emptyMap(),
|
||||
) : VisionGroupBase(), PrototypeHolder {
|
||||
|
||||
override fun styleSheet(block: StyleSheet.() -> Unit) {
|
||||
error("Can't define stylesheet for prototypes block")
|
||||
}
|
||||
|
||||
init {
|
||||
this.childrenInternal.putAll(children)
|
||||
}
|
||||
|
||||
override var properties: Config?
|
||||
get() = null
|
||||
set(_) {
|
||||
|
@ -91,7 +91,7 @@ internal object PrototypesSerializer : KSerializer<MutableVisionGroup> {
|
||||
|
||||
override fun deserialize(decoder: Decoder): MutableVisionGroup {
|
||||
val map = mapSerializer.deserialize(decoder)
|
||||
return Prototypes(map as? MutableMap<NameToken, Vision> ?: LinkedHashMap(map))
|
||||
return Prototypes(map)
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: MutableVisionGroup) {
|
||||
|
@ -60,7 +60,7 @@ class PropertyTest {
|
||||
@Test
|
||||
fun testProxyStyleProperty() {
|
||||
var box: Proxy? = null
|
||||
val group = SolidGroup().apply {
|
||||
val group = SolidGroup{
|
||||
styleSheet {
|
||||
set("testStyle") {
|
||||
SolidMaterial.MATERIAL_COLOR_KEY put "#555555"
|
||||
|
Loading…
Reference in New Issue
Block a user