@@ -219,12 +219,12 @@ class Presenter: NSObject {
219
219
220
220
private func safeZoneConflicts( ) -> SafeZoneConflicts {
221
221
guard let window = maskingView. window else { return [ ] }
222
- let inNormalWindowLevel : Bool = {
222
+ let windowLevel : UIWindowLevel = {
223
223
if let vc = presentationContext. viewControllerValue ( ) as? WindowViewController {
224
- return vc. windowLevel == UIWindowLevelNormal
224
+ return vc. windowLevel
225
225
}
226
- return true
227
- } ( )
226
+ return UIWindowLevelNormal
227
+ } ( )
228
228
// TODO `underNavigationBar` and `underTabBar` should look up the presentation context's hierarchy
229
229
// TODO for cases where both should be true (probably not an issue for typical height messages, though).
230
230
let underNavigationBar : Bool = {
@@ -236,15 +236,24 @@ class Presenter: NSObject {
236
236
return false
237
237
} ( )
238
238
if #available( iOS 11 , * ) {
239
- if !inNormalWindowLevel {
239
+ if windowLevel > UIWindowLevelNormal {
240
240
// TODO seeing `maskingView.safeAreaInsets.top` value of 20 on
241
- // iPhone 8 with status bar window level, which doesn't seem right
242
- // since the status bar is covered by the window . Applying a special rule
241
+ // iPhone 8 with status bar window level. This seems like an iOS bug since
242
+ // the message view's window is above the status bar . Applying a special rule
243
243
// to allow the animator to revove this amount from the layout margins if needed.
244
- if maskingView. safeAreaInsets. top <= 20 {
245
- return [ . coveredStatusBar]
244
+ // This may need to be reworked if any future device has a legitimate 20pt top safe area,
245
+ // such as with a potentially smaller notch.
246
+ if maskingView. safeAreaInsets. top == 20 {
247
+ return [ . overStatusBar]
246
248
} else {
247
- return [ . sensorNotch, . homeIndicator]
249
+ var conflicts : SafeZoneConflicts = [ ]
250
+ if maskingView. safeAreaInsets. top > 0 {
251
+ conflicts. formUnion ( . sensorNotch)
252
+ }
253
+ if maskingView. safeAreaInsets. bottom > 0 {
254
+ conflicts. formUnion ( . homeIndicator)
255
+ }
256
+ return conflicts
248
257
}
249
258
}
250
259
var conflicts : SafeZoneConflicts = [ ]
@@ -257,7 +266,7 @@ class Presenter: NSObject {
257
266
return conflicts
258
267
} else {
259
268
if UIApplication . shared. isStatusBarHidden { return [ ] }
260
- if !inNormalWindowLevel || underNavigationBar { return [ ] }
269
+ if ( windowLevel > UIWindowLevelNormal ) || underNavigationBar { return [ ] }
261
270
let statusBarFrame = UIApplication . shared. statusBarFrame
262
271
let statusBarWindowFrame = window. convert ( statusBarFrame, from: nil )
263
272
let statusBarViewFrame = maskingView. convert ( statusBarWindowFrame, from: nil )
0 commit comments