99import type { GestureDetail } from '../../../utils/gesture' ;
1010import { createGesture } from '../../../utils/gesture' ;
1111import { clamp , getElementRoot } from '../../../utils/helpers' ;
12+ import type { Style as StatusBarStyle } from '../../../utils/native/status-bar' ;
1213import { setCardStatusBarDark , setCardStatusBarDefault } from '../utils' ;
1314
1415import { calculateSpringStep , handleCanDismiss } from './utils' ;
@@ -18,7 +19,12 @@ export const SwipeToCloseDefaults = {
1819 MIN_PRESENTING_SCALE : 0.93 ,
1920} ;
2021
21- export const createSwipeToCloseGesture = ( el : HTMLIonModalElement , animation : Animation , onDismiss : ( ) => void ) => {
22+ export const createSwipeToCloseGesture = (
23+ el : HTMLIonModalElement ,
24+ animation : Animation ,
25+ statusBarStyle : StatusBarStyle ,
26+ onDismiss : ( ) => void
27+ ) => {
2228 /**
2329 * The step value at which a card modal
2430 * is eligible for dismissing via gesture.
@@ -173,14 +179,14 @@ export const createSwipeToCloseGesture = (el: HTMLIonModalElement, animation: An
173179 * should block the gesture from
174180 * proceeding,
175181 */
176- const isAttempingDismissWithCanDismiss = step >= 0 && canDismissBlocksGesture ;
182+ const isAttemptingDismissWithCanDismiss = step >= 0 && canDismissBlocksGesture ;
177183
178184 /**
179185 * If we are blocking the gesture from dismissing,
180186 * set the max step value so that the sheet cannot be
181187 * completely hidden.
182188 */
183- const maxStep = isAttempingDismissWithCanDismiss ? canDismissMaxStep : 0.9999 ;
189+ const maxStep = isAttemptingDismissWithCanDismiss ? canDismissMaxStep : 0.9999 ;
184190
185191 /**
186192 * If we are blocking the gesture from
@@ -190,7 +196,7 @@ export const createSwipeToCloseGesture = (el: HTMLIonModalElement, animation: An
190196 * Note that the starting breakpoint is always 0,
191197 * so we omit adding 0 to the result.
192198 */
193- const processedStep = isAttempingDismissWithCanDismiss ? calculateSpringStep ( step / maxStep ) : step ;
199+ const processedStep = isAttemptingDismissWithCanDismiss ? calculateSpringStep ( step / maxStep ) : step ;
194200
195201 const clampedStep = clamp ( 0.0001 , processedStep , maxStep ) ;
196202
@@ -205,7 +211,7 @@ export const createSwipeToCloseGesture = (el: HTMLIonModalElement, animation: An
205211 * crossed a certain threshold.
206212 */
207213 if ( clampedStep >= DISMISS_THRESHOLD && lastStep < DISMISS_THRESHOLD ) {
208- setCardStatusBarDefault ( ) ;
214+ setCardStatusBarDefault ( statusBarStyle ) ;
209215
210216 /**
211217 * However, if we swipe back up, then the
@@ -223,10 +229,10 @@ export const createSwipeToCloseGesture = (el: HTMLIonModalElement, animation: An
223229 const velocity = detail . velocityY ;
224230 const step = detail . deltaY / height ;
225231
226- const isAttempingDismissWithCanDismiss = step >= 0 && canDismissBlocksGesture ;
227- const maxStep = isAttempingDismissWithCanDismiss ? canDismissMaxStep : 0.9999 ;
232+ const isAttemptingDismissWithCanDismiss = step >= 0 && canDismissBlocksGesture ;
233+ const maxStep = isAttemptingDismissWithCanDismiss ? canDismissMaxStep : 0.9999 ;
228234
229- const processedStep = isAttempingDismissWithCanDismiss ? calculateSpringStep ( step / maxStep ) : step ;
235+ const processedStep = isAttemptingDismissWithCanDismiss ? calculateSpringStep ( step / maxStep ) : step ;
230236
231237 const clampedStep = clamp ( 0.0001 , processedStep , maxStep ) ;
232238
@@ -238,7 +244,7 @@ export const createSwipeToCloseGesture = (el: HTMLIonModalElement, animation: An
238244 * animation can never complete until
239245 * canDismiss is checked.
240246 */
241- const shouldComplete = ! isAttempingDismissWithCanDismiss && threshold >= DISMISS_THRESHOLD ;
247+ const shouldComplete = ! isAttemptingDismissWithCanDismiss && threshold >= DISMISS_THRESHOLD ;
242248 let newStepValue = shouldComplete ? - 0.001 : 0.001 ;
243249
244250 if ( ! shouldComplete ) {
@@ -280,7 +286,7 @@ export const createSwipeToCloseGesture = (el: HTMLIonModalElement, animation: An
280286 * check canDismiss. 25% was chosen
281287 * to avoid accidental swipes.
282288 */
283- if ( isAttempingDismissWithCanDismiss && clampedStep > maxStep / 4 ) {
289+ if ( isAttemptingDismissWithCanDismiss && clampedStep > maxStep / 4 ) {
284290 handleCanDismiss ( el , animation ) ;
285291 } else if ( shouldComplete ) {
286292 onDismiss ( ) ;
0 commit comments