|
1 | 1 | // Types. |
2 | | -import { Point, View as ViewDefinition } from '.'; |
| 2 | +import { Point, Position, View as ViewDefinition } from '.'; |
3 | 3 |
|
4 | 4 | // Requires |
5 | 5 | import { ViewCommon, isEnabledProperty, originXProperty, originYProperty, isUserInteractionEnabledProperty, testIDProperty } from './view-common'; |
@@ -108,19 +108,31 @@ export class View extends ViewCommon implements ViewDefinition { |
108 | 108 |
|
109 | 109 | @profile |
110 | 110 | public layout(left: number, top: number, right: number, bottom: number, setFrame = true): void { |
111 | | - const { boundsChanged, sizeChanged } = this._setCurrentLayoutBounds(left, top, right, bottom); |
| 111 | + const result = this._setCurrentLayoutBounds(left, top, right, bottom); |
| 112 | + let { sizeChanged } = result; |
| 113 | + |
112 | 114 | if (setFrame) { |
113 | 115 | this.layoutNativeView(left, top, right, bottom); |
114 | 116 | } |
115 | 117 |
|
116 | | - const needsLayout = boundsChanged || (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED; |
| 118 | + const needsLayout = result.boundsChanged || (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED; |
117 | 119 | if (needsLayout) { |
118 | | - let position = { left, top, right, bottom }; |
| 120 | + let position: Position; |
| 121 | + |
119 | 122 | if (this.nativeViewProtected && SDK_VERSION > 10) { |
120 | 123 | // on iOS 11+ it is possible to have a changed layout frame due to safe area insets |
121 | 124 | // get the frame and adjust the position, so that onLayout works correctly |
122 | | - const frame = this.nativeViewProtected.frame; |
123 | | - position = IOSHelper.getPositionFromFrame(frame); |
| 125 | + position = IOSHelper.getPositionFromFrame(this.nativeViewProtected.frame); |
| 126 | + |
| 127 | + if (!sizeChanged) { |
| 128 | + // If frame has actually changed, there is the need to update view background and border styles as they depend on native view bounds |
| 129 | + // To trigger the needed visual update, mark size as changed |
| 130 | + if (position.left !== left || position.top !== top || position.right !== right || position.bottom !== bottom) { |
| 131 | + sizeChanged = true; |
| 132 | + } |
| 133 | + } |
| 134 | + } else { |
| 135 | + position = { left, top, right, bottom }; |
124 | 136 | } |
125 | 137 |
|
126 | 138 | this.onLayout(position.left, position.top, position.right, position.bottom); |
@@ -316,7 +328,7 @@ export class View extends ViewCommon implements ViewDefinition { |
316 | 328 | return null; |
317 | 329 | } |
318 | 330 |
|
319 | | - public getSafeAreaInsets(): { left; top; right; bottom } { |
| 331 | + public getSafeAreaInsets(): Position { |
320 | 332 | const safeAreaInsets = this.nativeViewProtected && this.nativeViewProtected.safeAreaInsets; |
321 | 333 | const insets = { left: 0, top: 0, right: 0, bottom: 0 }; |
322 | 334 | if (this.iosIgnoreSafeArea) { |
@@ -938,12 +950,7 @@ export class View extends ViewCommon implements ViewDefinition { |
938 | 950 | }); |
939 | 951 | } |
940 | 952 |
|
941 | | - _getCurrentLayoutBounds(): { |
942 | | - left: number; |
943 | | - top: number; |
944 | | - right: number; |
945 | | - bottom: number; |
946 | | - } { |
| 953 | + _getCurrentLayoutBounds(): Position { |
947 | 954 | const nativeView = this.nativeViewProtected; |
948 | 955 | if (nativeView && !this.isCollapsed) { |
949 | 956 | const frame = nativeView.frame; |
|
0 commit comments