@@ -14,7 +14,7 @@ import {
1414 PanGestureHandler ,
1515 State as GestureState ,
1616} from 'react-native-gesture-handler' ;
17- import { SafeAreaContext , EdgeInsets } from 'react-native-safe-area-context' ;
17+ import { EdgeInsets } from 'react-native-safe-area-context' ;
1818import {
1919 TransitionSpec ,
2020 CardStyleInterpolator ,
@@ -34,6 +34,7 @@ type Props = ViewProps & {
3434 next ?: Animated . Node < number > ;
3535 current : Animated . Value < number > ;
3636 layout : Layout ;
37+ insets : EdgeInsets ;
3738 gestureDirection : 'horizontal' | 'vertical' | 'vertical-inverted' ;
3839 onOpen : ( isFinished : boolean ) => void ;
3940 onClose : ( isFinished : boolean ) => void ;
@@ -229,13 +230,6 @@ function transformTimingConfigToAnimatedValues(
229230 } ;
230231}
231232
232- const DEFAULT_INSETS : EdgeInsets = {
233- top : 0 ,
234- left : 0 ,
235- right : 0 ,
236- bottom : 0 ,
237- } ;
238-
239233export default class Card extends React . Component < Props > {
240234 static defaultProps = {
241235 overlayEnabled : Platform . OS !== 'ios' ,
@@ -244,10 +238,6 @@ export default class Card extends React.Component<Props> {
244238 gestureVelocityImpact : GESTURE_VELOCITY_IMPACT ,
245239 } ;
246240
247- static contextType = SafeAreaContext ;
248-
249- context ! : EdgeInsets | null ;
250-
251241 componentDidUpdate ( prevProps : Props ) {
252242 const {
253243 layout,
@@ -407,7 +397,10 @@ export default class Card extends React.Component<Props> {
407397 this . props . current ,
408398 this . props . next ,
409399 this . props . layout ,
410- this . context || DEFAULT_INSETS
400+ this . props . insets . top ,
401+ this . props . insets . right ,
402+ this . props . insets . bottom ,
403+ this . props . insets . left
411404 ) ;
412405 } ;
413406
@@ -716,7 +709,10 @@ export default class Card extends React.Component<Props> {
716709 current : Animated . Node < number > ,
717710 next : Animated . Node < number > | undefined ,
718711 layout : Layout ,
719- insets : EdgeInsets
712+ insetTop : number ,
713+ insetRight : number ,
714+ insetBottom : number ,
715+ insetLeft : number
720716 ) =>
721717 styleInterpolator ( {
722718 index,
@@ -726,7 +722,12 @@ export default class Card extends React.Component<Props> {
726722 layouts : {
727723 screen : layout ,
728724 } ,
729- insets,
725+ insets : {
726+ top : insetTop ,
727+ right : insetRight ,
728+ bottom : insetBottom ,
729+ left : insetLeft ,
730+ } ,
730731 } )
731732 ) ;
732733
@@ -740,7 +741,10 @@ export default class Card extends React.Component<Props> {
740741 this . props . current ,
741742 this . props . next ,
742743 this . props . layout ,
743- this . context || DEFAULT_INSETS
744+ this . props . insets . top ,
745+ this . props . insets . right ,
746+ this . props . insets . bottom ,
747+ this . props . insets . left
744748 ) ;
745749
746750 private gestureActivationCriteria ( ) {
@@ -797,6 +801,7 @@ export default class Card extends React.Component<Props> {
797801 current,
798802 next,
799803 layout,
804+ insets,
800805 overlayEnabled,
801806 shadowEnabled,
802807 gestureEnabled,
@@ -814,7 +819,10 @@ export default class Card extends React.Component<Props> {
814819 current ,
815820 next ,
816821 layout ,
817- this . context || DEFAULT_INSETS
822+ insets . top ,
823+ insets . right ,
824+ insets . bottom ,
825+ insets . left
818826 ) ;
819827 }
820828
0 commit comments