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.
| @@ -5881,17 +5881,23 @@ class MainActivity : AppCompatActivity() { | ||
| 5881 | 5881 | } |
| 5882 | 5882 | if (craftNativeOptionalString(style.opt("flexDirection"))?.endsWith("-reverse") == true) desired.reverse() |
| 5883 | 5883 | val desiredSet = desired.toSet() |
| 5884 | for ((index, childView) in desired.withIndex()) { | |
| 5885 | if (layout.getChildAt(index) !== childView) { | |
| 5886 | if (index < layout.childCount && layout.getChildAt(index) !in desiredSet) layout.removeViewAt(index) | |
| 5884 | for (index in layout.childCount - 1 downTo 0) { | |
| 5885 | if (layout.getChildAt(index) !in desiredSet) layout.removeViewAt(index) | |
| 5886 | } | |
| 5887 | for (childView in desired) { | |
| 5888 | if (childView.parent !== layout) { | |
| 5887 | 5889 | (childView.parent as? ViewGroup)?.removeView(childView) |
| 5888 | layout.addView(childView, index) | |
| 5890 | layout.addView(childView) | |
| 5889 | 5891 | } |
| 5890 | 5892 | val params = childView.layoutParams as? LinearLayout.LayoutParams |
| 5891 | 5893 | ?: LinearLayout.LayoutParams(childView.layoutParams?.width ?: -1, childView.layoutParams?.height ?: -2) |
| 5892 | 5894 | childView.layoutParams = params |
| 5893 | 5895 | } |
| 5894 | while (layout.childCount > desired.size) layout.removeViewAt(layout.childCount - 1) | |
| 5896 | // Reorder attached children without removing their focused inputs. | |
| 5897 | // Removing and adding an existing row clears Android's native focus. | |
| 5898 | if (desired.indices.any { layout.getChildAt(it) !== desired[it] }) { | |
| 5899 | desired.forEach(layout::bringChildToFront) | |
| 5900 | } | |
| 5895 | 5901 | layout.requestLayout() |
| 5896 | 5902 | } |
| 5897 | 5903 | |