mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix scrollview as root of tabview
This commit is contained in:
@@ -69,8 +69,8 @@ class ScrollLayoutSafeAreaTest extends UITest<ScrollView> {
|
||||
equal(b, platform.screen.mainScreen.heightPixels, `${scrollView}.bottom - actual:${b}; expected: ${platform.screen.mainScreen.heightPixels}`);
|
||||
}
|
||||
|
||||
private scroll_view_in_full_screen_test(pageOptions?: helper.PageOptions, sample?: string) {
|
||||
const snippet = sample || `
|
||||
private scroll_view_in_full_screen_test(pageOptions?: helper.PageOptions) {
|
||||
const snippet = `
|
||||
<ScrollView id="scroll" backgroundColor="Crimson"></ScrollView>
|
||||
`;
|
||||
|
||||
@@ -97,12 +97,7 @@ class ScrollLayoutSafeAreaTest extends UITest<ScrollView> {
|
||||
}
|
||||
|
||||
public test_scroll_view_in_full_screen_tab_bar() {
|
||||
const snippet = `
|
||||
<GridLayout>
|
||||
<ScrollView id="scroll" backgroundColor="Crimson"></ScrollView>
|
||||
</GridLayout>
|
||||
`;
|
||||
this.scroll_view_in_full_screen_test({ tabBar: true }, snippet);
|
||||
this.scroll_view_in_full_screen_test({ tabBar: true });
|
||||
}
|
||||
|
||||
private scroll_view_children_components_in_safe_area(pageOptions?: helper.PageOptions) {
|
||||
|
||||
@@ -817,12 +817,8 @@ export namespace ios {
|
||||
}
|
||||
|
||||
function getAvailableSpaceFromParent(view: View): { safeArea: CGRect, fullscreen: CGRect } {
|
||||
// Search for view and parents with ViewController or parents with UIScrollView parent to get their content size.
|
||||
if (view && !view.viewController) {
|
||||
view = view.parent as View;
|
||||
while (view && !view.viewController && !(view.nativeViewProtected instanceof UIScrollView)) {
|
||||
view = view.parent as View;
|
||||
}
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
let fullscreen = null;
|
||||
@@ -832,12 +828,21 @@ export namespace ios {
|
||||
const nativeView = view.viewController.view;
|
||||
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
|
||||
fullscreen = nativeView.frame;
|
||||
}
|
||||
} else {
|
||||
let parent = view.parent as View;
|
||||
while (parent && !parent.viewController && !(parent.nativeViewProtected instanceof UIScrollView)) {
|
||||
parent = parent.parent as View;
|
||||
}
|
||||
|
||||
if (view.nativeViewProtected instanceof UIScrollView) {
|
||||
const nativeView = view.nativeViewProtected;
|
||||
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
|
||||
fullscreen = CGRectMake(0, 0, nativeView.contentSize.width, nativeView.contentSize.height);
|
||||
if (parent.nativeViewProtected instanceof UIScrollView) {
|
||||
const nativeView = parent.nativeViewProtected;
|
||||
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
|
||||
fullscreen = CGRectMake(0, 0, nativeView.contentSize.width, nativeView.contentSize.height);
|
||||
} else if (parent.viewController) {
|
||||
const nativeView = parent.viewController.view;
|
||||
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
|
||||
fullscreen = nativeView.frame;
|
||||
}
|
||||
}
|
||||
|
||||
return { safeArea: safeArea, fullscreen: fullscreen}
|
||||
|
||||
Reference in New Issue
Block a user