also looking at this
fix(native): retain keyed controls and correct map and tab chrome
#368
32 files
+449
-100
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -30,7 +30,8 @@ class CraftNativeMutationDocument { | ||
| 30 | 30 | var events: JSONObject, |
| 31 | 31 | var text: MutableList<String>, |
| 32 | 32 | var children: MutableList<String>, |
| 33 | var parent: String? | |
| 33 | var parent: String?, | |
| 34 | val key: String? = null | |
| 34 | 35 | ) { |
| 35 | 36 | fun duplicate(): Node = copy( |
| 36 | 37 | props = JSONObject(props.toString()), |
| @@ -175,7 +176,8 @@ class CraftNativeMutationDocument { | ||
| 175 | 176 | dictionary(value.opt("events")), |
| 176 | 177 | textChildren(if (value.has("children")) value.opt("children") else value.opt("text")), |
| 177 | 178 | mutableListOf(), |
| 178 | null | |
| 179 | null, | |
| 180 | key = value.opt("key") as? String | |
| 179 | 181 | ) |
| 180 | 182 | return if (makeRoot) id else root |
| 181 | 183 | } |
| @@ -299,6 +301,7 @@ class CraftNativeMutationDocument { | ||
| 299 | 301 | .put("style", node.style) |
| 300 | 302 | .put("events", node.events) |
| 301 | 303 | .put("children", children) |
| 304 | .also { value -> node.key?.let { value.put("key", it) } } | |
| 302 | 305 | } |
| 303 | 306 | |
| 304 | 307 | private fun importNode( |
| @@ -322,7 +325,8 @@ class CraftNativeMutationDocument { | ||
| 322 | 325 | dictionary(value.opt("events")), |
| 323 | 326 | mutableListOf(), |
| 324 | 327 | mutableListOf(), |
| 325 | parent | |
| 328 | parent, | |
| 329 | key = value.opt("key") as? String | |
| 326 | 330 | ) |
| 327 | 331 | nodes[id] = node |
| 328 | 332 | for (index in 0 until children.length()) { |
| @@ -29,6 +29,7 @@ struct CraftNativeMutationResult { | ||
| 29 | 29 | final class CraftNativeMutationDocument { |
| 30 | 30 | private struct Node { |
| 31 | 31 | let id: String |
| 32 | let key: String? | |
| 32 | 33 | var type: String |
| 33 | 34 | var props: [String: Any] |
| 34 | 35 | var style: [String: Any] |
| @@ -177,6 +178,7 @@ final class CraftNativeMutationDocument { | ||
| 177 | 178 | } |
| 178 | 179 | nodes[id] = Node( |
| 179 | 180 | id: id, |
| 181 | key: value["key"] as? String, | |
| 180 | 182 | type: type, |
| 181 | 183 | props: dictionary(value["props"]), |
| 182 | 184 | style: dictionary(value["style"]), |
| @@ -330,6 +332,7 @@ final class CraftNativeMutationDocument { | ||
| 330 | 332 | "style": node.style, |
| 331 | 333 | "events": node.events, |
| 332 | 334 | ] |
| 335 | if let key = node.key { value["key"] = key } | |
| 333 | 336 | let text: [Any] = node.text |
| 334 | 337 | let children: [Any] = node.children.compactMap { materialize($0, nodes: nodes) } |
| 335 | 338 | value["children"] = text + children |
| @@ -350,6 +353,7 @@ final class CraftNativeMutationDocument { | ||
| 350 | 353 | let children = value["children"] as? [Any] ?? [] |
| 351 | 354 | nodes[id] = Node( |
| 352 | 355 | id: id, |
| 356 | key: value["key"] as? String, | |
| 353 | 357 | type: value["type"] as? String ?? "View", |
| 354 | 358 | props: props, |
| 355 | 359 | style: dictionary(value["style"]), |