@@ -312,63 +312,65 @@ class UIViewControllerImpl extends UIViewController {
312312
313313 layoutOwner ( force = false ) {
314314 const owner = this . _owner ?. deref ( ) ;
315- if ( ! force && ! ! owner . nativeViewProtected ?. layer . needsLayout ?.( ) ) {
315+ if ( ! owner ) {
316+ return ;
317+ }
318+ if ( ! force && owner . isLayoutValid && ! owner . nativeViewProtected ?. layer . needsLayout ?.( ) ) {
316319 // we skip layout if the view is not yet laid out yet
317320 // this usually means that viewDidLayoutSubviews will be called again
318321 // so doing a layout pass now will layout with the wrong parameters
319322 return ;
320323 }
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- }
340324
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 ;
325+ // layout(owner.actionBar)
326+ // layout(owner.content)
346327
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- }
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 ;
352335
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- }
367- }
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 ;
368342 }
369343
370- IOSHelper . layoutView ( this , owner ) ;
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 ;
349+
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+ }
355+
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 ;
369+ }
370+ }
371371 }
372+
373+ IOSHelper . layoutView ( this , owner ) ;
372374 }
373375
374376 // Mind implementation for other controllerss
0 commit comments