fix(ios): resilience to nativeView access under edge cases (#10276)

This commit is contained in:
Nathan Walker
2023-04-24 13:45:31 -07:00
committed by GitHub
parent c63a50a196
commit 4551da075b
3 changed files with 19 additions and 11 deletions

View File

@ -898,6 +898,7 @@ export class View extends ViewCommon implements ViewDefinition {
CATransaction.begin();
}
if (this.nativeViewProtected) {
if (value instanceof UIColor) {
this.nativeViewProtected.backgroundColor = value;
} else {
@ -906,6 +907,7 @@ export class View extends ViewCommon implements ViewDefinition {
});
this._setNativeClipToBounds();
}
}
if (!updateSuspended) {
CATransaction.commit();
@ -915,9 +917,11 @@ export class View extends ViewCommon implements ViewDefinition {
}
_setNativeClipToBounds() {
if (this.nativeViewProtected) {
const backgroundInternal = this.style.backgroundInternal;
this.nativeViewProtected.clipsToBounds = (this.nativeViewProtected instanceof UIScrollView || backgroundInternal.hasBorderWidth() || backgroundInternal.hasBorderRadius()) && !backgroundInternal.hasBoxShadow();
}
}
private _setupPopoverControllerDelegate(controller: UIViewController, parent: View) {
const popoverPresentationController = controller.popoverPresentationController;

View File

@ -23,7 +23,9 @@ export class LayoutBase extends LayoutBaseCommon {
_setNativeClipToBounds() {
if (this.clipToBounds) {
if (this.nativeViewProtected) {
this.nativeViewProtected.clipsToBounds = true;
}
} else {
super._setNativeClipToBounds();
}

View File

@ -275,8 +275,10 @@ export class ListView extends ListViewBase {
_setNativeClipToBounds() {
// Always set clipsToBounds for list-view
if (this.ios) {
this.ios.clipsToBounds = true;
}
}
@profile
public onLoaded() {