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")
|
@SerialName("vision.group")
|
||||||
public open class VisionGroupBase : VisionBase(), MutableVisionGroup {
|
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")
|
@SerialName("children")
|
||||||
protected val childrenInternal = LinkedHashMap<NameToken, Vision>()
|
protected open val childrenInternal: MutableMap<NameToken, Vision> = LinkedHashMap()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of top level named children
|
* A map of top level named children
|
||||||
|
@ -93,13 +93,17 @@ public fun MutableVisionGroup.group(name: String, action: SolidGroup.() -> Unit
|
|||||||
*/
|
*/
|
||||||
@Serializable(PrototypesSerializer::class)
|
@Serializable(PrototypesSerializer::class)
|
||||||
internal class Prototypes(
|
internal class Prototypes(
|
||||||
override var children: MutableMap<NameToken, Vision> = LinkedHashMap(),
|
children: Map<NameToken, Vision> = emptyMap(),
|
||||||
) : VisionGroupBase(), PrototypeHolder {
|
) : VisionGroupBase(), PrototypeHolder {
|
||||||
|
|
||||||
override fun styleSheet(block: StyleSheet.() -> Unit) {
|
override fun styleSheet(block: StyleSheet.() -> Unit) {
|
||||||
error("Can't define stylesheet for prototypes block")
|
error("Can't define stylesheet for prototypes block")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.childrenInternal.putAll(children)
|
||||||
|
}
|
||||||
|
|
||||||
override var properties: Config?
|
override var properties: Config?
|
||||||
get() = null
|
get() = null
|
||||||
set(_) {
|
set(_) {
|
||||||
|
@ -91,7 +91,7 @@ internal object PrototypesSerializer : KSerializer<MutableVisionGroup> {
|
|||||||
|
|
||||||
override fun deserialize(decoder: Decoder): MutableVisionGroup {
|
override fun deserialize(decoder: Decoder): MutableVisionGroup {
|
||||||
val map = mapSerializer.deserialize(decoder)
|
val map = mapSerializer.deserialize(decoder)
|
||||||
return Prototypes(map as? MutableMap<NameToken, Vision> ?: LinkedHashMap(map))
|
return Prototypes(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: MutableVisionGroup) {
|
override fun serialize(encoder: Encoder, value: MutableVisionGroup) {
|
||||||
|
@ -60,7 +60,7 @@ class PropertyTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testProxyStyleProperty() {
|
fun testProxyStyleProperty() {
|
||||||
var box: Proxy? = null
|
var box: Proxy? = null
|
||||||
val group = SolidGroup().apply {
|
val group = SolidGroup{
|
||||||
styleSheet {
|
styleSheet {
|
||||||
set("testStyle") {
|
set("testStyle") {
|
||||||
SolidMaterial.MATERIAL_COLOR_KEY put "#555555"
|
SolidMaterial.MATERIAL_COLOR_KEY put "#555555"
|
||||||
|
Loading…
Reference in New Issue
Block a user