fix tabview safe areas

This commit is contained in:
Martin Yankov
2018-09-04 10:22:53 +03:00
parent f82b649217
commit 351d78e80c
7 changed files with 48 additions and 22 deletions

View File

@@ -7,10 +7,14 @@
<TabView>
<TabViewItem title="Home" iconSource="res://home">
<fragments:hscroll-hstack-fragment></fragments:hscroll-hstack-fragment>
<GridLayout>
<fragments:hscroll-hstack-fragment></fragments:hscroll-hstack-fragment>
</GridLayout>
</TabViewItem>
<TabViewItem title="Search" iconSource="res://search">
<fragments:hscroll-hstack-fragment></fragments:hscroll-hstack-fragment>
<GridLayout>
<fragments:hscroll-hstack-fragment></fragments:hscroll-hstack-fragment>
</GridLayout>
</TabViewItem>
</TabView>

View File

@@ -7,10 +7,14 @@
<TabView>
<TabViewItem title="Home" iconSource="res://home">
<fragments:listview-fragment></fragments:listview-fragment>
<GridLayout>
<fragments:listview-fragment></fragments:listview-fragment>
</GridLayout>
</TabViewItem>
<TabViewItem title="Search" iconSource="res://search">
<fragments:listview-fragment></fragments:listview-fragment>
<GridLayout>
<fragments:listview-fragment></fragments:listview-fragment>
</GridLayout>
</TabViewItem>
</TabView>

View File

@@ -7,10 +7,14 @@
<TabView>
<TabViewItem title="Home" iconSource="res://home">
<fragments:vscroll-vstack-fragment></fragments:vscroll-vstack-fragment>
<GridLayout>
<fragments:vscroll-vstack-fragment></fragments:vscroll-vstack-fragment>
</GridLayout>
</TabViewItem>
<TabViewItem title="Search" iconSource="res://search">
<fragments:vscroll-vstack-fragment></fragments:vscroll-vstack-fragment>
<GridLayout>
<fragments:vscroll-vstack-fragment></fragments:vscroll-vstack-fragment>
</GridLayout>
</TabViewItem>
</TabView>

View File

@@ -1,13 +1,17 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:fragments="stacklayout/fragments"
xmlns:fragments="scrollview/fragments"
actionBarHidden="true">
<TabView>
<TabViewItem title="Home" iconSource="res://home">
<fragments:hscroll-hstack-fragment></fragments:hscroll-hstack-fragment>
<GridLayout>
<fragments:hscroll-hstack-fragment></fragments:hscroll-hstack-fragment>
</GridLayout>
</TabViewItem>
<TabViewItem title="Search" iconSource="res://search">
<fragments:hscroll-hstack-fragment></fragments:hscroll-hstack-fragment>
<GridLayout>
<fragments:hscroll-hstack-fragment></fragments:hscroll-hstack-fragment>
</GridLayout>
</TabViewItem>
</TabView>

View File

@@ -4,10 +4,14 @@
<TabView>
<TabViewItem title="Home" iconSource="res://home">
<fragments:listview-fragment></fragments:listview-fragment>
<GridLayout>
<fragments:listview-fragment></fragments:listview-fragment>
</GridLayout>
</TabViewItem>
<TabViewItem title="Search" iconSource="res://search">
<fragments:listview-fragment></fragments:listview-fragment>
<GridLayout>
<fragments:listview-fragment></fragments:listview-fragment>
</GridLayout>
</TabViewItem>
</TabView>

View File

@@ -1,13 +1,17 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:fragments="stacklayout/fragments"
xmlns:fragments="scrollview/fragments"
actionBarHidden="true">
<TabView>
<TabViewItem title="Home" iconSource="res://home">
<fragments:vscroll-vstack-fragment></fragments:vscroll-vstack-fragment>
<GridLayout>
<fragments:vscroll-vstack-fragment></fragments:vscroll-vstack-fragment>
</GridLayout>
</TabViewItem>
<TabViewItem title="Search" iconSource="res://search">
<fragments:vscroll-vstack-fragment></fragments:vscroll-vstack-fragment>
<GridLayout>
<fragments:vscroll-vstack-fragment></fragments:vscroll-vstack-fragment>
</GridLayout>
</TabViewItem>
</TabView>

View File

@@ -831,23 +831,25 @@ export namespace ios {
}
function getAvailableSpaceFromParent(view: View): { safeArea: CGRect, fullscreen: CGRect } {
// Search for ViewController or UIScrollView parent to get their content size.
let parent = view.parent;
while (parent && !parent.viewController && !(parent.nativeViewProtected instanceof UIScrollView)) {
parent = parent.parent as View;
// 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;
}
}
let fullscreen = null;
let safeArea = null;
if (parent.viewController) {
const nativeView = parent.viewController.view;
if (view.viewController) {
const nativeView = view.viewController.view;
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
fullscreen = nativeView.frame;
}
if (parent.nativeViewProtected instanceof UIScrollView) {
const nativeView = parent.nativeViewProtected;
if (view.nativeViewProtected instanceof UIScrollView) {
const nativeView = view.nativeViewProtected;
safeArea = nativeView.safeAreaLayoutGuide.layoutFrame;
fullscreen = CGRectMake(0, 0, nativeView.contentSize.width, nativeView.contentSize.height);
}