@@ -11,7 +11,7 @@ import { Font } from "../styling/font";
1111import { Frame } from "../frame" ;
1212import { ios as iosView , View } from "../core/view" ;
1313import { Color } from "../../color" ;
14- import { /* ios as iosUtils,*/ layout , isFontIconURI } from "../../utils/utils" ;
14+ import { ios as iosUtils , layout , isFontIconURI } from "../../utils/utils" ;
1515// import { device } from "../../platform";
1616import { fromFileOrResource , fromFontIconCode , ImageSource } from "../../image-source" ;
1717
@@ -20,7 +20,7 @@ import { fromFileOrResource, fromFontIconCode, ImageSource } from "../../image-s
2020
2121export * from "./tabs-common" ;
2222
23- // const majorVersion = iosUtils.MajorVersion;
23+ const majorVersion = iosUtils . MajorVersion ;
2424// const isPhone = device.deviceType === "Phone";
2525
2626class MDCTabBarDelegateImpl extends NSObject implements MDCTabBarDelegate {
@@ -106,6 +106,8 @@ class UIPageViewControllerImpl extends UIPageViewController {
106106 return ;
107107 }
108108
109+ iosView . updateAutoAdjustScrollInsets ( this , owner ) ;
110+
109111 // Tabs can be reset as a root view. Call loaded here in this scenario.
110112 if ( ! owner . isLoaded ) {
111113 owner . callLoaded ( ) ;
@@ -119,29 +121,39 @@ class UIPageViewControllerImpl extends UIPageViewController {
119121 return ;
120122 }
121123
124+ let safeAreaInsetsBottom = 0 ;
125+ let safeAreaInsetsTop = 0 ;
126+
127+ if ( majorVersion > 10 ) {
128+ safeAreaInsetsBottom = this . view . safeAreaInsets . bottom ;
129+ safeAreaInsetsTop = this . view . safeAreaInsets . top ;
130+ } else {
131+ safeAreaInsetsTop = this . topLayoutGuide . length ;
132+ }
133+
122134 let scrollViewTop = 0 ;
123- let scrollViewHeight = this . view . bounds . size . height + this . view . safeAreaInsets . bottom ;
135+ let scrollViewHeight = this . view . bounds . size . height + safeAreaInsetsBottom ;
124136
125137 if ( owner . tabStrip ) {
126138 scrollViewTop = this . tabBar . frame . size . height ;
127- scrollViewHeight = this . view . bounds . size . height - this . tabBar . frame . size . height + this . view . safeAreaInsets . bottom ;
128- let tabBarTop = this . view . safeAreaInsets . top ;
139+ scrollViewHeight = this . view . bounds . size . height - this . tabBar . frame . size . height + safeAreaInsetsBottom ;
140+ let tabBarTop = safeAreaInsetsTop ;
129141 let tabBarHeight = this . tabBar . frame . size . height ;
130142
131143 const tabsPosition = owner . tabsPosition ;
132144 if ( tabsPosition === "bottom" ) {
133- tabBarTop = this . view . frame . size . height - this . tabBar . frame . size . height - this . view . safeAreaInsets . bottom ;
145+ tabBarTop = this . view . frame . size . height - this . tabBar . frame . size . height - safeAreaInsetsBottom ;
134146 scrollViewTop = this . view . frame . origin . y ;
135- scrollViewHeight = this . view . frame . size . height - this . view . safeAreaInsets . bottom ;
147+ scrollViewHeight = this . view . frame . size . height - safeAreaInsetsBottom ;
136148 }
137149
138150 const parent = owner . parent ;
139- if ( parent ) {
151+ if ( parent && majorVersion > 10 ) {
140152 // TODO: Figure out a better way to handle ViewController nesting/Safe Area nesting
141153 tabBarTop = Math . max ( tabBarTop , owner . parent . nativeView . safeAreaInsets . top ) ;
142154 }
143155
144- this . tabBar . frame = CGRectMake ( this . view . safeAreaInsets . left , tabBarTop , this . tabBar . frame . size . width , tabBarHeight ) ;
156+ this . tabBar . frame = CGRectMake ( 0 , tabBarTop , this . tabBar . frame . size . width , tabBarHeight ) ;
145157 }
146158
147159 const subViews : NSArray < UIView > = this . view . subviews ;
@@ -163,7 +175,7 @@ class UIPageViewControllerImpl extends UIPageViewController {
163175 scrollView . scrollEnabled = false ;
164176 }
165177
166- scrollView . frame = CGRectMake ( this . view . safeAreaInsets . left , scrollViewTop , this . view . bounds . size . width , scrollViewHeight ) ; //this.view.bounds;
178+ scrollView . frame = CGRectMake ( 0 , scrollViewTop , this . view . bounds . size . width , scrollViewHeight ) ; //this.view.bounds;
167179 }
168180 }
169181}
0 commit comments