Skip to content
Draft
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
30 changes: 30 additions & 0 deletions apps/automated/src/ui/layouts/safe-area-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,36 @@ export class SafeAreaTests extends testModule.UITest<any> {
TKUnit.assert(gridLayoutChangedCounter === 1, `${grid} layoutChanged event count - actual:${gridLayoutChangedCounter}; expected: 1`);
}

public test_overflow_reaches_bottom_when_page_view_is_offset() {
const page = <Page>Builder.parse(`
<Page actionBarHidden="false">
<ActionBar title="Offset Page" />
<GridLayout id="grid" rows="*, 44" backgroundColor="Crimson">
<Label id="label" row="1" text="bottom" iosOverflowSafeArea="true" backgroundColor="Gold"></Label>
</GridLayout>
</Page>
`);
// Page view starts below the navigation bar instead of at y=0.
(<UIViewController>page.ios).edgesForExtendedLayout = UIRectEdge.Bottom;
const grid = page.getViewById<GridLayout>('grid');
const label = page.getViewById<Label>('label');

try {
helper.navigate(() => page);
TKUnit.waitUntilReady(() => grid.isLayoutValid && label.isLayoutValid);

const pageTop = (<UIView>page.nativeViewProtected).frame.origin.y;
TKUnit.assert(pageTop > 0, `${page} native view should be offset - actual top:${pageTop}`);

const screenBottom = platform.Screen.mainScreen.heightPixels;
closeEnough(bottom(page), screenBottom, `${page}.bottom - actual:${bottom(page)}; expected: ${screenBottom}`);
closeEnough(bottom(grid), screenBottom, `${grid}.bottom - actual:${bottom(grid)}; expected: ${screenBottom}`);
closeEnough(bottom(label), screenBottom, `${label}.bottom - actual:${bottom(label)}; expected: ${screenBottom}`);
} finally {
helper.navigate(() => new Page());
}
}

// Common
private getViews(template: string) {
let root = Builder.parse(template);
Expand Down
3 changes: 2 additions & 1 deletion packages/core/ui/core/view/view-helper/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ export class IOSHelper {

if (viewControllerView) {
safeArea = viewControllerView.safeAreaLayoutGuide.layoutFrame;
fullscreen = viewControllerView.frame;
// safeArea and inWindow are relative to the controller view, not its superview.
fullscreen = viewControllerView.bounds;
controllerInWindow = viewControllerView.convertPointToView(viewControllerView.bounds.origin, null);
} else if (scrollView) {
const insets = scrollView.safeAreaInsets;
Expand Down
5 changes: 3 additions & 2 deletions packages/core/ui/page/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,9 @@ export class Page extends PageBase {

const childLeft = 0 + insets.left;
const childTop = 0 + insets.top;
const childRight = right - insets.right;
const childBottom = bottom - insets.bottom;
// Bounds come from the native frame, which may be offset within its superview.
const childRight = right - left - insets.right;
const childBottom = bottom - top - insets.bottom;

View.layoutChild(this, this.layoutView, childLeft, childTop, childRight, childBottom);
}
Expand Down
Loading