ReviewOS

also looking at this

craft-native/craft

fix(native): retain keyed controls and correct map and tab chrome

#368
Merged chris wants to merge codex/native-repeated-selector-identity into main
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.

packages/android/templates/MainActivityNative.kt.templatemodified+11-5
Changes to packages/android/templates/MainActivityNative.kt.template
@@ -5881,17 +5881,23 @@ class MainActivity : AppCompatActivity() {
58815881 }
58825882 if (craftNativeOptionalString(style.opt("flexDirection"))?.endsWith("-reverse") == true) desired.reverse()
58835883 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) {
58875889 (childView.parent as? ViewGroup)?.removeView(childView)
5888 layout.addView(childView, index)
5890 layout.addView(childView)
58895891 }
58905892 val params = childView.layoutParams as? LinearLayout.LayoutParams
58915893 ?: LinearLayout.LayoutParams(childView.layoutParams?.width ?: -1, childView.layoutParams?.height ?: -2)
58925894 childView.layoutParams = params
58935895 }
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 }
58955901 layout.requestLayout()
58965902 }
58975903