Skip to content

Commit 94d7b28

Browse files
committed
fix: disable screens when mode is modal on older expo versions
1 parent b19b3b2 commit 94d7b28

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

example/src/Screens/StackTransparent.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default function SimpleStackScreen({ navigation, ...rest }: Props) {
8686
});
8787

8888
return (
89-
<SimpleStack.Navigator headerMode="screen" {...rest}>
89+
<SimpleStack.Navigator mode="modal" {...rest}>
9090
<SimpleStack.Screen
9191
name="Article"
9292
component={ArticleScreen}
@@ -99,8 +99,6 @@ export default function SimpleStackScreen({ navigation, ...rest }: Props) {
9999
headerShown: false,
100100
cardStyle: { backgroundColor: 'transparent' },
101101
cardOverlayEnabled: true,
102-
gestureEnabled: true,
103-
gestureDirection: 'vertical-inverted',
104102
cardStyleInterpolator: ({ current: { progress } }) => ({
105103
cardStyle: {
106104
opacity: progress.interpolate({
@@ -147,12 +145,8 @@ const styles = StyleSheet.create({
147145
dialog: {
148146
padding: 16,
149147
width: '90%',
148+
maxWidth: 400,
150149
borderRadius: 3,
151-
elevation: 6,
152-
shadowColor: 'black',
153-
shadowOpacity: 0.15,
154-
shadowOffset: { width: 0, height: 2 },
155-
shadowRadius: 10,
156150
},
157151
close: {
158152
alignSelf: 'flex-end',

packages/stack/src/views/Stack/CardStack.tsx

+13-11
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,18 @@ const MaybeScreen = ({
135135
// https://facebook.github.io/react-native/docs/view#removeclippedsubviews
136136
// This can be useful if screens is not enabled
137137
// It's buggy on iOS, so we don't enable it there
138+
top:
139+
enabled && typeof active === 'number' && !active ? FAR_FAR_AWAY : 0,
138140
transform: [
139141
{
142+
// If the `active` prop is animated node, we can't use the `left` property due to native driver
143+
// So we use `translateY` instead
140144
translateY:
141-
Platform.OS !== 'ios' && enabled
142-
? typeof active === 'number'
143-
? active
144-
? 0
145-
: FAR_FAR_AWAY
146-
: active.interpolate({
147-
inputRange: [0, 1],
148-
outputRange: [FAR_FAR_AWAY, 0],
149-
})
145+
enabled && typeof active !== 'number'
146+
? active.interpolate({
147+
inputRange: [0, 1],
148+
outputRange: [FAR_FAR_AWAY, 0],
149+
})
150150
: 0,
151151
},
152152
],
@@ -445,7 +445,9 @@ export default class CardStack extends React.Component<Props, State> {
445445

446446
// Screens is buggy on iOS, so we don't enable it there
447447
// For modals, usually we want the screen underneath to be visible, so also disable it there
448-
const isScreensEnabled = Platform.OS !== 'ios';
448+
const isScreensEnabled =
449+
Platform.OS !== 'ios' &&
450+
(isInsufficientExpoVersion ? mode !== 'modal' : true);
449451

450452
return (
451453
<React.Fragment>
@@ -460,9 +462,9 @@ export default class CardStack extends React.Component<Props, State> {
460462
const scene = scenes[index];
461463

462464
// Display current screen and a screen beneath.
463-
464465
let isScreenActive: Animated.AnimatedInterpolation | 0 | 1 =
465466
index >= self.length - 2 ? 1 : 0;
467+
466468
if (isInsufficientExpoVersion) {
467469
isScreenActive =
468470
index === self.length - 1

0 commit comments

Comments
 (0)