@@ -84,9 +84,12 @@ class UIViewControllerImpl extends UIViewController {
84
84
return ;
85
85
}
86
86
87
- if ( owner . _modalParent ) {
88
- let isTablet = device . deviceType === "Tablet" ;
89
- let isFullScreen = ! owner . _UIModalPresentationFormSheet || ! isTablet ;
87
+ const modalParent = owner . _modalParent ;
88
+ if ( modalParent ) {
89
+ // if inside horizontally compact environment - fullScreen will be forced
90
+ let isFullScreen = ! owner . _UIModalPresentationFormSheet ||
91
+ ( modalParent . nativeView . traitCollection . horizontalSizeClass === UIUserInterfaceSizeClass . Compact ) ;
92
+
90
93
let frame = isFullScreen ? getter ( UIScreen , UIScreen . mainScreen ) . bounds : this . view . frame ;
91
94
let size = frame . size ;
92
95
let width = size . width ;
@@ -99,12 +102,6 @@ class UIViewControllerImpl extends UIViewController {
99
102
superViewRotationRadians = atan2f ( transform . b , transform . a ) ;
100
103
}
101
104
102
- if ( ios . MajorVersion < 8 && ios . isLandscape ( ) && ! superViewRotationRadians ) {
103
- // in iOS 7 when in landscape we switch width with height because on device they don't change even when rotated.
104
- width = size . height ;
105
- height = size . width ;
106
- }
107
-
108
105
let bottom = height ;
109
106
let statusBarHeight = uiUtils . ios . getStatusBarHeight ( ) ;
110
107
let statusBarVisible = ! getter ( UIApplication , UIApplication . sharedApplication ) . statusBarHidden ;
@@ -116,20 +113,9 @@ class UIViewControllerImpl extends UIViewController {
116
113
let widthSpec = layout . makeMeasureSpec ( width , mode ) ;
117
114
let heightSpec = layout . makeMeasureSpec ( height , mode ) ;
118
115
119
- View . measureChild ( owner . _modalParent , owner , widthSpec , heightSpec ) ;
120
- let top = ( ( backgroundSpanUnderStatusBar && isFullScreen ) || ios . MajorVersion < 8 || ! isFullScreen ) ? 0 : statusBarHeight ;
121
- View . layoutChild ( owner . _modalParent , owner , 0 , top , width , bottom ) ;
122
-
123
- if ( ios . MajorVersion < 8 ) {
124
- if ( ! backgroundSpanUnderStatusBar && ( ! isTablet || isFullScreen ) ) {
125
- if ( ios . isLandscape ( ) && ! superViewRotationRadians ) {
126
- this . view . center = CGPointMake ( this . view . center . x - statusBarHeight , this . view . center . y ) ;
127
- }
128
- else {
129
- this . view . center = CGPointMake ( this . view . center . x , this . view . center . y + statusBarHeight ) ;
130
- }
131
- }
132
- }
116
+ View . measureChild ( modalParent , owner , widthSpec , heightSpec ) ;
117
+ let top = ( ( backgroundSpanUnderStatusBar && isFullScreen ) || ! isFullScreen ) ? 0 : statusBarHeight ;
118
+ View . layoutChild ( modalParent , owner , 0 , top , width , bottom ) ;
133
119
134
120
if ( traceEnabled ( ) ) {
135
121
traceWrite ( owner + ", native frame = " + NSStringFromCGRect ( this . view . frame ) , traceCategories . Layout ) ;
@@ -156,8 +142,9 @@ class UIViewControllerImpl extends UIViewController {
156
142
return ;
157
143
}
158
144
159
- let frame = this . navigationController ? ( < any > this . navigationController ) . owner : null ;
160
- let newEntry = this [ ENTRY ] ;
145
+ const frame = this . navigationController ? ( < any > this . navigationController ) . owner : null ;
146
+ const newEntry = this [ ENTRY ] ;
147
+ const modalParent = page . _modalParent ;
161
148
162
149
// Don't raise event if currentPage was showing modal page.
163
150
if ( ! page. _presentedViewController && newEntry && ( ! frame || frame . currentPage !== page ) ) {
@@ -167,6 +154,11 @@ class UIViewControllerImpl extends UIViewController {
167
154
168
155
page . _enableLoadedEvents = true ;
169
156
157
+ // Add page to frame if showing modal page.
158
+ if ( modalParent ) {
159
+ modalParent . frame . _addView ( page ) ;
160
+ }
161
+
170
162
if ( frame ) {
171
163
if ( ! page . parent ) {
172
164
if ( ! frame . _currentEntry ) {
@@ -279,7 +271,7 @@ class UIViewControllerImpl extends UIViewController {
279
271
public viewDidDisappear ( animated : boolean ) : void {
280
272
super . viewDidDisappear ( animated ) ;
281
273
282
- let page = this . _owner . get ( ) ;
274
+ const page = this . _owner . get ( ) ;
283
275
if ( traceEnabled ( ) ) {
284
276
traceWrite ( page + " viewDidDisappear" , traceCategories . Navigation ) ;
285
277
}
@@ -288,12 +280,13 @@ class UIViewControllerImpl extends UIViewController {
288
280
return ;
289
281
}
290
282
291
- let modalParent = page . _modalParent ;
283
+ const modalParent = page . _modalParent ;
292
284
page . _modalParent = undefined ;
293
285
page . _UIModalPresentationFormSheet = false ;
294
286
295
- // Clear modal flag on parent page.
287
+ // Clear up after modal page has closed .
296
288
if ( modalParent ) {
289
+ modalParent . frame . _removeView ( page ) ;
297
290
modalParent . _modal = undefined ;
298
291
}
299
292
@@ -430,7 +423,7 @@ export class Page extends PageBase {
430
423
431
424
super . _raiseShowingModallyEvent ( ) ;
432
425
433
- parent . ios . presentViewControllerAnimatedCompletion ( this . _ios , ios . MajorVersion >= 7 , null ) ;
426
+ parent . ios . presentViewControllerAnimatedCompletion ( this . _ios , true , null ) ;
434
427
let transitionCoordinator = getter ( parent . ios , parent . ios . transitionCoordinator ) ;
435
428
if ( transitionCoordinator ) {
436
429
UIViewControllerTransitionCoordinator . prototype . animateAlongsideTransitionCompletion . call ( transitionCoordinator , null , ( ) => this . _raiseShownModallyEvent ( ) ) ;
@@ -445,7 +438,7 @@ export class Page extends PageBase {
445
438
446
439
protected _hideNativeModalView ( parent : Page ) {
447
440
parent . requestLayout ( ) ;
448
- parent . _ios . dismissModalViewControllerAnimated ( ios . MajorVersion >= 7 ) ;
441
+ parent . _ios . dismissModalViewControllerAnimated ( true ) ;
449
442
450
443
super . _hideNativeModalView ( parent ) ;
451
444
}
@@ -520,7 +513,7 @@ export class Page extends PageBase {
520
513
statusBarHeight = 0 ;
521
514
}
522
515
523
- if ( this . frame && this . frame . _getNavBarVisible ( this ) ) {
516
+ if ( ! this . _modalParent && this . frame && this . frame . _getNavBarVisible ( this ) ) {
524
517
// Measure ActionBar with the full height.
525
518
let actionBarSize = View . measureChild ( this , this . actionBar , widthMeasureSpec , heightMeasureSpec ) ;
526
519
actionBarWidth = actionBarSize . measuredWidth ;
0 commit comments