@@ -312,65 +312,63 @@ class UIViewControllerImpl extends UIViewController {
312312
313313 layoutOwner ( force = false ) {
314314 const owner = this . _owner ?. deref ( ) ;
315- if ( ! owner ) {
316- return ;
317- }
318- if ( ! force && owner . isLayoutValid && ! owner . nativeViewProtected ?. layer . needsLayout ?.( ) ) {
315+ if ( ! force && ! ! owner . nativeViewProtected ?. layer . needsLayout ?.( ) ) {
319316 // we skip layout if the view is not yet laid out yet
320317 // this usually means that viewDidLayoutSubviews will be called again
321318 // so doing a layout pass now will layout with the wrong parameters
322319 return ;
323320 }
321+ if ( owner ) {
322+ // layout(owner.actionBar)
323+ // layout(owner.content)
324+
325+ if ( majorVersion >= 11 ) {
326+ // Handle nested Page safe area insets application.
327+ // A Page is nested if its Frame has a parent.
328+ // If the Page is nested, cross check safe area insets on top and bottom with Frame parent.
329+ const frame = owner . parent ;
330+ // There is a legacy scenario where Page is not in a Frame - the root of a Modal View, so it has no parent.
331+ let frameParent = frame && frame . parent ;
332+
333+ // Handle Angular scenario where TabView is in a ProxyViewContainer
334+ // It is possible to wrap components in ProxyViewContainers indefinitely
335+ // Not using instanceof ProxyViewContainer to avoid circular dependency
336+ // TODO: Try moving UIViewControllerImpl out of page module
337+ while ( frameParent && ! frameParent . nativeViewProtected ) {
338+ frameParent = frameParent . parent ;
339+ }
324340
325- // layout(owner.actionBar)
326- // layout(owner.content)
327-
328- if ( majorVersion >= 11 ) {
329- // Handle nested Page safe area insets application.
330- // A Page is nested if its Frame has a parent.
331- // If the Page is nested, cross check safe area insets on top and bottom with Frame parent.
332- const frame = owner . parent ;
333- // There is a legacy scenario where Page is not in a Frame - the root of a Modal View, so it has no parent.
334- let frameParent = frame && frame . parent ;
335-
336- // Handle Angular scenario where TabView is in a ProxyViewContainer
337- // It is possible to wrap components in ProxyViewContainers indefinitely
338- // Not using instanceof ProxyViewContainer to avoid circular dependency
339- // TODO: Try moving UIViewControllerImpl out of page module
340- while ( frameParent && ! frameParent . nativeViewProtected ) {
341- frameParent = frameParent . parent ;
342- }
343-
344- if ( frameParent ) {
345- const parentPageInsetsTop = frameParent . nativeViewProtected . safeAreaInsets . top ;
346- const parentPageInsetsBottom = frameParent . nativeViewProtected . safeAreaInsets . bottom ;
347- let currentInsetsTop = this . view . safeAreaInsets . top ;
348- let currentInsetsBottom = this . view . safeAreaInsets . bottom ;
341+ if ( frameParent ) {
342+ const parentPageInsetsTop = frameParent . nativeViewProtected . safeAreaInsets . top ;
343+ const parentPageInsetsBottom = frameParent . nativeViewProtected . safeAreaInsets . bottom ;
344+ let currentInsetsTop = this . view . safeAreaInsets . top ;
345+ let currentInsetsBottom = this . view . safeAreaInsets . bottom ;
349346
350- // Safe area insets include additional safe area insets too, so subtract old values
351- if ( this . additionalSafeAreaInsets ) {
352- currentInsetsTop -= this . additionalSafeAreaInsets . top ;
353- currentInsetsBottom -= this . additionalSafeAreaInsets . bottom ;
354- }
347+ // Safe area insets include additional safe area insets too, so subtract old values
348+ if ( this . additionalSafeAreaInsets ) {
349+ currentInsetsTop -= this . additionalSafeAreaInsets . top ;
350+ currentInsetsBottom -= this . additionalSafeAreaInsets . bottom ;
351+ }
355352
356- const additionalInsetsTop = Math . max ( parentPageInsetsTop - currentInsetsTop , 0 ) ;
357- const additionalInsetsBottom = Math . max ( parentPageInsetsBottom - currentInsetsBottom , 0 ) ;
358-
359- if ( additionalInsetsTop > 0 || additionalInsetsBottom > 0 ) {
360- const additionalInsets = new UIEdgeInsets ( {
361- top : additionalInsetsTop ,
362- left : 0 ,
363- bottom : additionalInsetsBottom ,
364- right : 0 ,
365- } ) ;
366- this . additionalSafeAreaInsets = additionalInsets ;
367- } else {
368- this . additionalSafeAreaInsets = null ;
353+ const additionalInsetsTop = Math . max ( parentPageInsetsTop - currentInsetsTop , 0 ) ;
354+ const additionalInsetsBottom = Math . max ( parentPageInsetsBottom - currentInsetsBottom , 0 ) ;
355+
356+ if ( additionalInsetsTop > 0 || additionalInsetsBottom > 0 ) {
357+ const additionalInsets = new UIEdgeInsets ( {
358+ top : additionalInsetsTop ,
359+ left : 0 ,
360+ bottom : additionalInsetsBottom ,
361+ right : 0 ,
362+ } ) ;
363+ this . additionalSafeAreaInsets = additionalInsets ;
364+ } else {
365+ this . additionalSafeAreaInsets = null ;
366+ }
369367 }
370368 }
371- }
372369
373- IOSHelper . layoutView ( this , owner ) ;
370+ IOSHelper . layoutView ( this , owner ) ;
371+ }
374372 }
375373
376374 // Mind implementation for other controllerss
0 commit comments