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}`);
|
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) {
|
private scroll_view_in_full_screen_test(pageOptions?: helper.PageOptions) {
|
||||||
const snippet = sample || `
|
const snippet = `
|
||||||
<ScrollView id="scroll" backgroundColor="Crimson"></ScrollView>
|
<ScrollView id="scroll" backgroundColor="Crimson"></ScrollView>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -97,12 +97,7 @@ class ScrollLayoutSafeAreaTest extends UITest<ScrollView> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public test_scroll_view_in_full_screen_tab_bar() {
|
public test_scroll_view_in_full_screen_tab_bar() {
|
||||||
const snippet = `
|
this.scroll_view_in_full_screen_test({ tabBar: true });
|
||||||
<GridLayout>
|
|
||||||
<ScrollView id="scroll" backgroundColor="Crimson"></ScrollView>
|
|
||||||
</GridLayout>
|
|
||||||
`;
|
|
||||||
this.scroll_view_in_full_screen_test({ tabBar: true }, snippet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private scroll_view_children_components_in_safe_area(pageOptions?: helper.PageOptions) {
|
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 } {
|
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) {
|
||||||
if (view && !view.viewController) {
|
return;
|
||||||
view = view.parent as View;
|
|
||||||
while (view && !view.viewController && !(view.nativeViewProtected instanceof UIScrollView)) {
|
|
||||||
view = view.parent as View;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let fullscreen = null;
|
let fullscreen = null;
|
||||||
@@ -832,12 +828,21 @@ export namespace ios {
|
|||||||
const nativeView = view.viewController.view;
|
const nativeView = view.viewController.view;
|
||||||
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
|
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
|
||||||
fullscreen = nativeView.frame;
|
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) {
|
if (parent.nativeViewProtected instanceof UIScrollView) {
|
||||||
const nativeView = view.nativeViewProtected;
|
const nativeView = parent.nativeViewProtected;
|
||||||
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
|
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
|
||||||
fullscreen = CGRectMake(0, 0, nativeView.contentSize.width, nativeView.contentSize.height);
|
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}
|
return { safeArea: safeArea, fullscreen: fullscreen}
|
||||||
|
|||||||
Reference in New Issue
Block a user