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
12 changes: 4 additions & 8 deletions apps/automated/src/ui/image/image-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,8 @@ export const test_SettingImageSourceWhenSizedToParentDoesNotRequestLayout = ios(
let mainPage = helper.getCurrentPage();
mainPage.content = host;

const nativeHostView = host.nativeViewProtected as UIView;

// Check if native view layer is still marked as dirty before proceeding
TKUnit.waitUntilReady(() => host.isLoaded && nativeHostView?.layer && !nativeHostView.layer.needsLayout());
// Check if view is loaded and layout is valid
TKUnit.waitUntilReady(() => host.isLoaded && host.isLayoutValid);

let called = false;
image.requestLayout = () => (called = true);
Expand All @@ -290,10 +288,8 @@ export const test_SettingImageSourceWhenFixedWidthAndHeightDoesNotRequestLayout
let mainPage = helper.getCurrentPage();
mainPage.content = host;

const nativeHostView = host.nativeViewProtected as UIView;

// Check if native view layer is still marked as dirty before proceeding
TKUnit.waitUntilReady(() => host.isLoaded && nativeHostView?.layer && !nativeHostView.layer.needsLayout());
// Check if view is loaded and layout is valid
TKUnit.waitUntilReady(() => host.isLoaded && host.isLayoutValid);

let called = false;
image.requestLayout = () => (called = true);
Expand Down
6 changes: 2 additions & 4 deletions apps/automated/src/ui/label/label-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,8 @@ export class LabelTest extends testModule.UITest<Label> {
let mainPage = helper.getCurrentPage();
mainPage.content = host;

const nativeHostView = host.nativeViewProtected as UIView;

// Check if native view layer is still marked as dirty before proceeding
TKUnit.waitUntilReady(() => host.isLoaded && nativeHostView?.layer && !nativeHostView.layer.needsLayout());
// Check if view is loaded and layout is valid
TKUnit.waitUntilReady(() => host.isLoaded && host.isLayoutValid);

let called = false;
label.requestLayout = () => (called = true);
Expand Down
17 changes: 17 additions & 0 deletions apps/automated/src/ui/view/view-tests-layout-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ export function test_event_LayoutChanged_GetActualSize() {
helper.do_PageTest_WithStackLayout_AndButton(test);
}

export function test_event_LayoutChanged_IsLayoutValid() {
const test = function (views: Array<View>) {
let buttonLayoutChanged = false;
let expectedValidResult;

views[1].on(View.layoutChangedEvent, (args) => {
expectedValidResult = (args.object as View).isLayoutValid;
buttonLayoutChanged = true;
});

TKUnit.waitUntilReady(() => buttonLayoutChanged, 5);
TKUnit.assertFalse(expectedValidResult);
};

helper.do_PageTest_WithStackLayout_AndButton(test);
}

export function test_event_LayoutChanged_Listeners() {
const test = function (views: Array<View>) {
let buttonLayoutChanged = false;
Expand Down
8 changes: 3 additions & 5 deletions packages/core/ui/core/view/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ export class View extends ViewCommon {

public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {
const measureSpecsChanged = this._setCurrentMeasureSpecs(widthMeasureSpec, heightMeasureSpec);
const forceLayout = (this._privateFlags & PFLAG_FORCE_LAYOUT) === PFLAG_FORCE_LAYOUT;
if (this.nativeViewProtected && (forceLayout || measureSpecsChanged)) {
if (this.nativeViewProtected && (this.isLayoutRequested || measureSpecsChanged)) {
// first clears the measured dimension flag
this._privateFlags &= ~PFLAG_MEASURED_DIMENSION_SET;

Expand All @@ -122,7 +121,7 @@ export class View extends ViewCommon {
this.layoutNativeView(left, top, right, bottom);
}

const needsLayout = boundsChanged || (this._privateFlags & PFLAG_LAYOUT_REQUIRED) === PFLAG_LAYOUT_REQUIRED;
const needsLayout = boundsChanged || this.isLayoutRequired;
if (needsLayout) {
let position: Position;

Expand Down Expand Up @@ -259,9 +258,8 @@ export class View extends ViewCommon {

get isLayoutValid(): boolean {
if (this.nativeViewProtected) {
return this._isLayoutValid;
return !this.isLayoutRequested;
}

return false;
}

Expand Down
9 changes: 1 addition & 8 deletions packages/core/ui/core/view/view-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export abstract class ViewCommon extends ViewBase {
private _measuredWidth: number;
private _measuredHeight: number;

protected _isLayoutValid: boolean;
private _cssType: string;

private _localAnimations: Set<Animation>;
Expand Down Expand Up @@ -1009,7 +1008,7 @@ export abstract class ViewCommon extends ViewBase {
//END Style property shortcuts

get isLayoutValid(): boolean {
return this._isLayoutValid;
return false;
}

get cssType(): string {
Expand Down Expand Up @@ -1070,11 +1069,6 @@ export abstract class ViewCommon extends ViewBase {
}
}

public requestLayout(): void {
this._isLayoutValid = false;
super.requestLayout();
}

public abstract onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void;
public abstract onLayout(left: number, top: number, right: number, bottom: number): void;
public abstract layoutNativeView(left: number, top: number, right: number, bottom: number): void;
Expand Down Expand Up @@ -1111,7 +1105,6 @@ export abstract class ViewCommon extends ViewBase {
* Returns two booleans - the first if "boundsChanged" the second is "sizeChanged".
*/
_setCurrentLayoutBounds(left: number, top: number, right: number, bottom: number): { boundsChanged: boolean; sizeChanged: boolean } {
this._isLayoutValid = true;
const boundsChanged: boolean = this._oldLeft !== left || this._oldTop !== top || this._oldRight !== right || this._oldBottom !== bottom;
const sizeChanged: boolean = this._oldRight - this._oldLeft !== right - left || this._oldBottom - this._oldTop !== bottom - top;
this._oldLeft = left;
Expand Down
Loading