revert: "chore: ios relayout condition cleanup (#10241)"

This reverts commit 7eaafa519e8fa3579a92fc3ca9f2310182e5eb34.
This commit is contained in:
Nathan Walker
2023-03-28 10:43:31 -07:00
parent 318fb36175
commit 8da1ca910a
3 changed files with 98 additions and 101 deletions

View File

@ -138,19 +138,19 @@ allTests['STACKLAYOUT'] = stackLayoutTests;
import * as flexBoxLayoutTests from './ui/layouts/flexbox-layout-tests'; import * as flexBoxLayoutTests from './ui/layouts/flexbox-layout-tests';
allTests['FLEXBOXLAYOUT'] = flexBoxLayoutTests; allTests['FLEXBOXLAYOUT'] = flexBoxLayoutTests;
import * as safeAreaLayoutTests from './ui/layouts/safe-area-tests'; // import * as safeAreaLayoutTests from './ui/layouts/safe-area-tests';
import * as safeAreaListViewtTests from './ui/list-view/list-view-safe-area-tests'; // import * as safeAreaListViewtTests from './ui/list-view/list-view-safe-area-tests';
import * as scrollViewSafeAreaTests from './ui/scroll-view/scroll-view-safe-area-tests'; // import * as scrollViewSafeAreaTests from './ui/scroll-view/scroll-view-safe-area-tests';
import * as repeaterSafeAreaTests from './ui/repeater/repeater-safe-area-tests'; // import * as repeaterSafeAreaTests from './ui/repeater/repeater-safe-area-tests';
import * as webViewSafeAreaTests from './ui/web-view/web-view-safe-area-tests'; // import * as webViewSafeAreaTests from './ui/web-view/web-view-safe-area-tests';
if (isIOS && Utils.ios.MajorVersion > 10) { // if (isIOS && Utils.ios.MajorVersion > 10) {
allTests['SAFEAREALAYOUT'] = safeAreaLayoutTests; // allTests['SAFEAREALAYOUT'] = safeAreaLayoutTests;
allTests['SAFEAREA-LISTVIEW'] = safeAreaListViewtTests; // allTests['SAFEAREA-LISTVIEW'] = safeAreaListViewtTests;
allTests['SAFEAREA-SCROLL-VIEW'] = scrollViewSafeAreaTests; // allTests['SAFEAREA-SCROLL-VIEW'] = scrollViewSafeAreaTests;
allTests['SAFEAREA-REPEATER'] = repeaterSafeAreaTests; // allTests['SAFEAREA-REPEATER'] = repeaterSafeAreaTests;
allTests['SAFEAREA-WEBVIEW'] = webViewSafeAreaTests; // allTests['SAFEAREA-WEBVIEW'] = webViewSafeAreaTests;
} // }
import * as rootViewsCssClassesTests from './ui/styling/root-views-css-classes-tests'; import * as rootViewsCssClassesTests from './ui/styling/root-views-css-classes-tests';
allTests['ROOT-VIEWS-CSS-CLASSES'] = rootViewsCssClassesTests; allTests['ROOT-VIEWS-CSS-CLASSES'] = rootViewsCssClassesTests;

View File

@ -92,62 +92,61 @@ class UILayoutViewController extends UIViewController {
} }
layoutOwner(force = false) { layoutOwner(force = false) {
const owner = this.owner?.deref(); const owner = this.owner?.deref();
if (!owner) { if (!force && !!owner.nativeViewProtected?.layer.needsLayout?.()) {
return;
}
if (!force && owner.isLayoutValid && !owner.nativeViewProtected?.layer.needsLayout?.()) {
// we skip layout if the view is not yet laid out yet // we skip layout if the view is not yet laid out yet
// this usually means that viewDidLayoutSubviews will be called again // this usually means that viewDidLayoutSubviews will be called again
// so doing a layout pass now will layout with the wrong parameters // so doing a layout pass now will layout with the wrong parameters
return; return;
} }
if (majorVersion >= 11) { if (owner) {
// Handle nested UILayoutViewController safe area application. if (majorVersion >= 11) {
// Currently, UILayoutViewController can be nested only in a TabView. // Handle nested UILayoutViewController safe area application.
// The TabView itself is handled by the OS, so we check the TabView's parent (usually a Page, but can be a Layout). // Currently, UILayoutViewController can be nested only in a TabView.
const tabViewItem = owner.parent; // The TabView itself is handled by the OS, so we check the TabView's parent (usually a Page, but can be a Layout).
const tabView = tabViewItem && tabViewItem.parent; const tabViewItem = owner.parent;
let parent = tabView && tabView.parent; const tabView = tabViewItem && tabViewItem.parent;
let parent = tabView && tabView.parent;
// Handle Angular scenario where TabView is in a ProxyViewContainer // Handle Angular scenario where TabView is in a ProxyViewContainer
// It is possible to wrap components in ProxyViewContainers indefinitely // It is possible to wrap components in ProxyViewContainers indefinitely
// Not using instanceof ProxyViewContainer to avoid circular dependency // Not using instanceof ProxyViewContainer to avoid circular dependency
// TODO: Try moving UILayoutViewController out of view module // TODO: Try moving UILayoutViewController out of view module
while (parent && !parent.nativeViewProtected) { while (parent && !parent.nativeViewProtected) {
parent = parent.parent; parent = parent.parent;
}
if (parent) {
const parentPageInsetsTop = parent.nativeViewProtected.safeAreaInsets.top;
const parentPageInsetsBottom = parent.nativeViewProtected.safeAreaInsets.bottom;
let currentInsetsTop = this.view.safeAreaInsets.top;
let currentInsetsBottom = this.view.safeAreaInsets.bottom;
// Safe area insets include additional safe area insets too, so subtract old values
if (this.additionalSafeAreaInsets) {
currentInsetsTop -= this.additionalSafeAreaInsets.top;
currentInsetsBottom -= this.additionalSafeAreaInsets.bottom;
} }
const additionalInsetsTop = Math.max(parentPageInsetsTop - currentInsetsTop, 0); if (parent) {
const additionalInsetsBottom = Math.max(parentPageInsetsBottom - currentInsetsBottom, 0); const parentPageInsetsTop = parent.nativeViewProtected.safeAreaInsets.top;
const parentPageInsetsBottom = parent.nativeViewProtected.safeAreaInsets.bottom;
let currentInsetsTop = this.view.safeAreaInsets.top;
let currentInsetsBottom = this.view.safeAreaInsets.bottom;
if (additionalInsetsTop > 0 || additionalInsetsBottom > 0) { // Safe area insets include additional safe area insets too, so subtract old values
const additionalInsets = new UIEdgeInsets({ if (this.additionalSafeAreaInsets) {
top: additionalInsetsTop, currentInsetsTop -= this.additionalSafeAreaInsets.top;
left: 0, currentInsetsBottom -= this.additionalSafeAreaInsets.bottom;
bottom: additionalInsetsBottom, }
right: 0,
}); const additionalInsetsTop = Math.max(parentPageInsetsTop - currentInsetsTop, 0);
this.additionalSafeAreaInsets = additionalInsets; const additionalInsetsBottom = Math.max(parentPageInsetsBottom - currentInsetsBottom, 0);
} else {
this.additionalSafeAreaInsets = null; if (additionalInsetsTop > 0 || additionalInsetsBottom > 0) {
const additionalInsets = new UIEdgeInsets({
top: additionalInsetsTop,
left: 0,
bottom: additionalInsetsBottom,
right: 0,
});
this.additionalSafeAreaInsets = additionalInsets;
} else {
this.additionalSafeAreaInsets = null;
}
} }
} }
IOSHelper.layoutView(this, owner);
} }
IOSHelper.layoutView(this, owner);
} }
public viewWillAppear(animated: boolean): void { public viewWillAppear(animated: boolean): void {

View File

@ -312,65 +312,63 @@ class UIViewControllerImpl extends UIViewController {
layoutOwner(force = false) { layoutOwner(force = false) {
const owner = this._owner?.deref(); const owner = this._owner?.deref();
if (!owner) { if (!force && !!owner.nativeViewProtected?.layer.needsLayout?.()) {
return;
}
if (!force && owner.isLayoutValid && !owner.nativeViewProtected?.layer.needsLayout?.()) {
// we skip layout if the view is not yet laid out yet // we skip layout if the view is not yet laid out yet
// this usually means that viewDidLayoutSubviews will be called again // this usually means that viewDidLayoutSubviews will be called again
// so doing a layout pass now will layout with the wrong parameters // so doing a layout pass now will layout with the wrong parameters
return; return;
} }
if (owner) {
// layout(owner.actionBar)
// layout(owner.content)
// layout(owner.actionBar) if (majorVersion >= 11) {
// layout(owner.content) // Handle nested Page safe area insets application.
// A Page is nested if its Frame has a parent.
// If the Page is nested, cross check safe area insets on top and bottom with Frame parent.
const frame = owner.parent;
// There is a legacy scenario where Page is not in a Frame - the root of a Modal View, so it has no parent.
let frameParent = frame && frame.parent;
if (majorVersion >= 11) { // Handle Angular scenario where TabView is in a ProxyViewContainer
// Handle nested Page safe area insets application. // It is possible to wrap components in ProxyViewContainers indefinitely
// A Page is nested if its Frame has a parent. // Not using instanceof ProxyViewContainer to avoid circular dependency
// If the Page is nested, cross check safe area insets on top and bottom with Frame parent. // TODO: Try moving UIViewControllerImpl out of page module
const frame = owner.parent; while (frameParent && !frameParent.nativeViewProtected) {
// There is a legacy scenario where Page is not in a Frame - the root of a Modal View, so it has no parent. frameParent = frameParent.parent;
let frameParent = frame && frame.parent;
// Handle Angular scenario where TabView is in a ProxyViewContainer
// It is possible to wrap components in ProxyViewContainers indefinitely
// Not using instanceof ProxyViewContainer to avoid circular dependency
// TODO: Try moving UIViewControllerImpl out of page module
while (frameParent && !frameParent.nativeViewProtected) {
frameParent = frameParent.parent;
}
if (frameParent) {
const parentPageInsetsTop = frameParent.nativeViewProtected.safeAreaInsets.top;
const parentPageInsetsBottom = frameParent.nativeViewProtected.safeAreaInsets.bottom;
let currentInsetsTop = this.view.safeAreaInsets.top;
let currentInsetsBottom = this.view.safeAreaInsets.bottom;
// Safe area insets include additional safe area insets too, so subtract old values
if (this.additionalSafeAreaInsets) {
currentInsetsTop -= this.additionalSafeAreaInsets.top;
currentInsetsBottom -= this.additionalSafeAreaInsets.bottom;
} }
const additionalInsetsTop = Math.max(parentPageInsetsTop - currentInsetsTop, 0); if (frameParent) {
const additionalInsetsBottom = Math.max(parentPageInsetsBottom - currentInsetsBottom, 0); const parentPageInsetsTop = frameParent.nativeViewProtected.safeAreaInsets.top;
const parentPageInsetsBottom = frameParent.nativeViewProtected.safeAreaInsets.bottom;
let currentInsetsTop = this.view.safeAreaInsets.top;
let currentInsetsBottom = this.view.safeAreaInsets.bottom;
if (additionalInsetsTop > 0 || additionalInsetsBottom > 0) { // Safe area insets include additional safe area insets too, so subtract old values
const additionalInsets = new UIEdgeInsets({ if (this.additionalSafeAreaInsets) {
top: additionalInsetsTop, currentInsetsTop -= this.additionalSafeAreaInsets.top;
left: 0, currentInsetsBottom -= this.additionalSafeAreaInsets.bottom;
bottom: additionalInsetsBottom, }
right: 0,
}); const additionalInsetsTop = Math.max(parentPageInsetsTop - currentInsetsTop, 0);
this.additionalSafeAreaInsets = additionalInsets; const additionalInsetsBottom = Math.max(parentPageInsetsBottom - currentInsetsBottom, 0);
} else {
this.additionalSafeAreaInsets = null; if (additionalInsetsTop > 0 || additionalInsetsBottom > 0) {
const additionalInsets = new UIEdgeInsets({
top: additionalInsetsTop,
left: 0,
bottom: additionalInsetsBottom,
right: 0,
});
this.additionalSafeAreaInsets = additionalInsets;
} else {
this.additionalSafeAreaInsets = null;
}
} }
} }
IOSHelper.layoutView(this, owner);
} }
IOSHelper.layoutView(this, owner);
} }
// Mind implementation for other controllerss // Mind implementation for other controllerss