Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/core/ui/layouts/layout-base-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
this._registerLayoutChild(child);
}

public insertChild(child: View, atIndex: number): void {
if (atIndex < 0) {
throw new Error('Cannot insert a child to a negative index.');
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;
}

this._subViews.splice(atIndex, 0, child);
this._addView(child, atIndex);
this._registerLayoutChild(child);
return false;
}

public removeChild(child: View): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/ui/layouts/layout-base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions packages/core/ui/layouts/layout-base.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
27 changes: 15 additions & 12 deletions packages/core/ui/layouts/root-layout/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down