@craft-native/android 0.0.142 → 0.0.144

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craft-native/android",
3
- "version": "0.0.142",
3
+ "version": "0.0.144",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/android#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1928,6 +1928,7 @@ class MainActivity : AppCompatActivity() {
1928
1928
  if (!screen.controls.containsKey("id:$target")) return false
1929
1929
  makeView(screen, document, target, screen.controls)
1930
1930
  val updated = screen.controls["id:$target"] ?: return false
1931
+ screen.lastLayoutBounds.remove(updated)
1931
1932
  if (!updateParentLayoutStyle(updated, document.optJSONObject("style") ?: JSONObject())) return false
1932
1933
  }
1933
1934
  if (applied.isNotEmpty()) {
@@ -1940,14 +1941,16 @@ class MainActivity : AppCompatActivity() {
1940
1941
  if (!screen.active) return
1941
1942
  val observer = screen.view.viewTreeObserver
1942
1943
  if (observer.isAlive) {
1943
- val listener = object : ViewTreeObserver.OnGlobalLayoutListener {
1944
- override fun onGlobalLayout() {
1945
- if (observer.isAlive) observer.removeOnGlobalLayoutListener(this)
1944
+ val listener = object : ViewTreeObserver.OnPreDrawListener {
1945
+ override fun onPreDraw(): Boolean {
1946
+ if (observer.isAlive) observer.removeOnPreDrawListener(this)
1946
1947
  if (screen.active) emitLayoutEvents(screen)
1948
+ return true
1947
1949
  }
1948
1950
  }
1949
- observer.addOnGlobalLayoutListener(listener)
1951
+ observer.addOnPreDrawListener(listener)
1950
1952
  }
1953
+ screen.view.forceLayout()
1951
1954
  screen.view.requestLayout()
1952
1955
  // A tree that is already settled may not produce a global-layout
1953
1956
  // callback; keep the event path live for that case as well.
@@ -1961,15 +1964,23 @@ class MainActivity : AppCompatActivity() {
1961
1964
  */
1962
1965
  private fun updateParentLayoutStyle(view: View, style: JSONObject): Boolean {
1963
1966
  var parent = view.parent
1967
+ var found = false
1964
1968
  while (parent != null) {
1965
- if (parent is CraftNativeFlexLayout) {
1966
- parent.setChildStyle(view, style, resources.displayMetrics.density)
1967
- parent.requestLayout()
1968
- return true
1969
+ when (parent) {
1970
+ is CraftNativeFlexLayout -> {
1971
+ if (!found) parent.setChildStyle(view, style, resources.displayMetrics.density)
1972
+ parent.forceLayout()
1973
+ parent.requestLayout()
1974
+ found = true
1975
+ }
1976
+ is CraftNativeScrollView -> {
1977
+ parent.forceLayout()
1978
+ parent.requestLayout()
1979
+ }
1969
1980
  }
1970
1981
  parent = parent.parent
1971
1982
  }
1972
- return false
1983
+ return found
1973
1984
  }
1974
1985
 
1975
1986
  private fun renderCommitted(screen: Screen, document: JSONObject) {