@@ -13,12 +13,12 @@ private let fullScreenStyles: [UIModalPresentationStyle] = [.fullScreen, .overFu
13
13
extension UIViewController {
14
14
15
15
func sm_selectPresentationContextTopDown( _ config: SwiftMessages . Config ) -> UIViewController {
16
- let presentationStyle = config. presentationStyle
16
+ let topBottomStyle = config. presentationStyle. topBottomStyle
17
17
if let presented = sm_presentedFullScreenViewController ( ) {
18
18
return presented. sm_selectPresentationContextTopDown ( config)
19
- } else if case . top = presentationStyle , let navigationController = sm_selectNavigationControllerTopDown ( ) {
19
+ } else if case . top? = topBottomStyle , let navigationController = sm_selectNavigationControllerTopDown ( ) {
20
20
return navigationController
21
- } else if case . bottom = presentationStyle , let tabBarController = sm_selectTabBarControllerTopDown ( ) {
21
+ } else if case . bottom? = topBottomStyle , let tabBarController = sm_selectTabBarControllerTopDown ( ) {
22
22
return tabBarController
23
23
}
24
24
return WindowViewController ( windowLevel: self . view. window? . windowLevel ?? UIWindowLevelNormal, config: config)
@@ -60,15 +60,15 @@ extension UIViewController {
60
60
}
61
61
62
62
func sm_selectPresentationContextBottomUp( _ config: SwiftMessages . Config ) -> UIViewController {
63
- let presentationStyle = config. presentationStyle
63
+ let topBottomStyle = config. presentationStyle. topBottomStyle
64
64
if let parent = parent {
65
65
if let navigationController = parent as? UINavigationController {
66
- if case . top = presentationStyle , navigationController. sm_isVisible ( view: navigationController. navigationBar) {
66
+ if case . top? = topBottomStyle , navigationController. sm_isVisible ( view: navigationController. navigationBar) {
67
67
return navigationController
68
68
}
69
69
return navigationController. sm_selectPresentationContextBottomUp ( config)
70
70
} else if let tabBarController = parent as? UITabBarController {
71
- if case . bottom = presentationStyle , tabBarController. sm_isVisible ( view: tabBarController. tabBar) {
71
+ if case . bottom? = topBottomStyle , tabBarController. sm_isVisible ( view: tabBarController. tabBar) {
72
72
return tabBarController
73
73
}
74
74
return tabBarController. sm_selectPresentationContextBottomUp ( config)
@@ -94,3 +94,17 @@ extension UIViewController {
94
94
return true
95
95
}
96
96
}
97
+
98
+ extension SwiftMessages . PresentationStyle {
99
+ /// A temporary workaround to allow custom presentation contexts using `TopBottomAnimation`
100
+ /// to display properly behind bars. THe long term solution is to refactor all of the
101
+ /// presentation context logic to work with safe area insets.
102
+ var topBottomStyle : TopBottomAnimation . Style ? {
103
+ switch self {
104
+ case . top: return . top
105
+ case . bottom: return . bottom
106
+ case . custom( let animator) : return ( animator as? TopBottomAnimation ) ? . style
107
+ case . center: return nil
108
+ }
109
+ }
110
+ }
0 commit comments