Content-Length: 5423 | pFad | http://github.com/NativeScript/NativeScript/pull/10690.patch

thub.com From 3de07350761aa08d99d64f103c6ee7b93bf53560 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Tue, 4 Feb 2025 19:33:47 -0800 Subject: [PATCH 1/3] fix(core): ignore inserting child if < 0 --- packages/core/ui/layouts/layout-base-common.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/core/ui/layouts/layout-base-common.ts b/packages/core/ui/layouts/layout-base-common.ts index 5e760d2d9e..074a23b68b 100644 --- a/packages/core/ui/layouts/layout-base-common.ts +++ b/packages/core/ui/layouts/layout-base-common.ts @@ -50,13 +50,11 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi } public insertChild(child: View, atIndex: number): void { - if (atIndex < 0) { - throw new Error('Cannot insert a child to a negative index.'); + if (atIndex > -1) { + this._subViews.splice(atIndex, 0, child); + this._addView(child, atIndex); + this._registerLayoutChild(child); } - - this._subViews.splice(atIndex, 0, child); - this._addView(child, atIndex); - this._registerLayoutChild(child); } public removeChild(child: View): void { From e547686bfdbc097fa5d554a2bdcafc262e04bb2d Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Wed, 5 Feb 2025 09:33:14 -0800 Subject: [PATCH 2/3] fix(core): return boolean on insertChild for when handled --- packages/core/ui/layouts/layout-base-common.ts | 4 +++- packages/core/ui/layouts/layout-base.ios.ts | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/core/ui/layouts/layout-base-common.ts b/packages/core/ui/layouts/layout-base-common.ts index 074a23b68b..0a240601ed 100644 --- a/packages/core/ui/layouts/layout-base-common.ts +++ b/packages/core/ui/layouts/layout-base-common.ts @@ -49,12 +49,14 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi this._registerLayoutChild(child); } - public insertChild(child: View, atIndex: number): void { + public insertChild(child: View, atIndex: number): boolean { if (atIndex > -1) { this._subViews.splice(atIndex, 0, child); this._addView(child, atIndex); this._registerLayoutChild(child); + return true; } + return false; } public removeChild(child: View): void { diff --git a/packages/core/ui/layouts/layout-base.ios.ts b/packages/core/ui/layouts/layout-base.ios.ts index 13f8fa3200..7c70039639 100644 --- a/packages/core/ui/layouts/layout-base.ios.ts +++ b/packages/core/ui/layouts/layout-base.ios.ts @@ -11,9 +11,12 @@ export class LayoutBase extends LayoutBaseCommon { this.requestLayout(); } - public insertChild(child: View, atIndex: number): void { - super.insertChild(child, atIndex); - this.requestLayout(); + public insertChild(child: View, atIndex: number): boolean { + if (super.insertChild(child, atIndex)) { + this.requestLayout(); + return true; + } + return false; } public removeChild(child: View): void { From d4f9c80f01c0cff6adc31060a03e3631990789b9 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Wed, 5 Feb 2025 09:42:24 -0800 Subject: [PATCH 3/3] chore: cleanup --- packages/core/ui/layouts/layout-base.d.ts | 2 +- .../ui/layouts/root-layout/index.android.ts | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/core/ui/layouts/layout-base.d.ts b/packages/core/ui/layouts/layout-base.d.ts index f94eb7b835..a9ffd9e078 100644 --- a/packages/core/ui/layouts/layout-base.d.ts +++ b/packages/core/ui/layouts/layout-base.d.ts @@ -34,7 +34,7 @@ export class LayoutBase extends CustomLayoutView { * @param view The view to be added to the end of the children array. * @param atIndex The insertion index. */ - insertChild(child: View, atIndex: number): void; + insertChild(child: View, atIndex: number): boolean; /** * Removes the specified view from the children array. diff --git a/packages/core/ui/layouts/root-layout/index.android.ts b/packages/core/ui/layouts/root-layout/index.android.ts index d85e292c25..6ad9bcfe98 100644 --- a/packages/core/ui/layouts/root-layout/index.android.ts +++ b/packages/core/ui/layouts/root-layout/index.android.ts @@ -8,20 +8,23 @@ import { LinearGradient } from '../../styling/linear-gradient'; export * from './root-layout-common'; export class RootLayout extends RootLayoutBase { - insertChild(view: View, atIndex: number): void { - super.insertChild(view, atIndex); - if (!view.hasGestureObservers()) { - // block tap events from going through to layers behind the view - if (view.nativeViewProtected) { - view.nativeViewProtected.setOnTouchListener( - new android.view.View.OnTouchListener({ - onTouch: function (view, event) { - return true; - }, - }), - ); + insertChild(view: View, atIndex: number): boolean { + if (super.insertChild(view, atIndex)) { + if (!view.hasGestureObservers()) { + // block tap events from going through to layers behind the view + if (view.nativeViewProtected) { + view.nativeViewProtected.setOnTouchListener( + new android.view.View.OnTouchListener({ + onTouch: function (view, event) { + return true; + }, + }), + ); + } } + return true; } + return false; } removeChild(view: View): void { if (view.hasGestureObservers() && view.nativeViewProtected) {








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/NativeScript/pull/10690.patch

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy