@@ -8,42 +8,41 @@ struct POSRootModalViewModifier: ViewModifier {
88 private let scaleTransitionAmount = Constants . scaleTransitionAmount
99
1010 func body( content: Content ) -> some View {
11- ZStack {
12- content
13- . blur ( radius: modalManager. isPresented ? 8 : 0 )
14- . disabled ( modalManager. isPresented)
15- . accessibilityElement ( children: modalManager. isPresented ? . ignore : . contain)
16-
17- if modalManager. isPresented {
18- Color . posSurfaceDim. opacity ( 0.8 )
19- . edgesIgnoringSafeArea ( . all)
20- . onTapGesture {
21- if modalManager. allowsInteractiveDismissal {
22- modalManager. dismiss ( )
11+ content
12+ . blur ( radius: modalManager. isPresented ? 8 : 0 )
13+ . disabled ( modalManager. isPresented)
14+ . accessibilityElement ( children: modalManager. isPresented ? . ignore : . contain)
15+ . measureFrame { frame in
16+ updateModalParentSize ( with: frame. size)
17+ }
18+ . overlay {
19+ if modalManager. isPresented {
20+ Color . posSurfaceDim. opacity ( 0.8 )
21+ . edgesIgnoringSafeArea ( . all)
22+ . onTapGesture {
23+ if modalManager. allowsInteractiveDismissal {
24+ modalManager. dismiss ( )
25+ }
2326 }
27+ // Don't scale/fade in the backdrop
28+ . animation ( nil , value: modalManager. isPresented)
29+ ZStack {
30+ modalManager. getContent ( )
31+ . environment ( \. posModalParentSize, modalParentSize)
32+ . background ( Color . posSurfaceBright)
33+ . cornerRadius ( POSCornerRadiusStyle . extraLarge. value)
34+ . posShadow ( . large, cornerRadius: POSCornerRadiusStyle . extraLarge. value)
35+ . padding ( )
2436 }
25- // Don't scale/fade in the backdrop
26- . animation ( nil , value: modalManager. isPresented)
27- ZStack {
28- modalManager. getContent ( )
29- . environment ( \. posModalParentSize, modalParentSize)
30- . background ( Color . posSurfaceBright)
31- . cornerRadius ( POSCornerRadiusStyle . extraLarge. value)
32- . posShadow ( . large, cornerRadius: POSCornerRadiusStyle . extraLarge. value)
33- . padding ( )
37+ . zIndex ( 1 )
38+ // Unfortunately combined doesn't work on removal.
39+ // The extra ZStack prevents changing modalContent from scaling and fading, but the ZIndex needs to be
40+ // consistent even when animating out, which it wouldn't be if unspecified.
41+ . transition ( . scale( scale: scaleTransitionAmount) . combined ( with: . opacity) )
3442 }
35- . zIndex ( 1 )
36- // Scale the modal container in and out, fading appropriately.
37- // Unfortunately combined doesn't work on removal.
38- // The extra ZStack prevents changing modalContent from scaling and fading, but the ZIndex needs to be
39- // consistent even when animating out, which it wouldn't be if unspecified.
40- . transition ( . scale( scale: scaleTransitionAmount) . combined ( with: . opacity) )
4143 }
42- }
43- . measureFrame { frame in
44- updateModalParentSize ( with: frame. size)
45- }
46- . animation ( . easeInOut( duration: animationDuration) , value: modalManager. isPresented)
44+ . animation ( . easeInOut( duration: animationDuration) , value: modalManager. isPresented)
45+ . ignoresSafeArea ( )
4746 }
4847
4948 private func updateModalParentSize( with size: CGSize ) {
0 commit comments