Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
fix: disable react-native-screens on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Aug 18, 2019
1 parent 354da7d commit fb9dbf9
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions packages/stack/src/views/Stack/Stack.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import {
View,
StyleSheet,
LayoutChangeEvent,
Dimensions,
Expand Down Expand Up @@ -71,6 +72,22 @@ const AnimatedScreen = Animated.createAnimatedComponent(
ViewProps & { active: number | Animated.Node<number> }
>;

const MaybeScreenContainer = Platform.OS === 'ios' ? View : ScreenContainer;

const MaybeScreen = ({
active,
...rest
}: ViewProps & {
active: number | Animated.Node<number>;
children: React.ReactNode;
}) => {
if (Platform.OS === 'ios') {
return <View {...rest} />;
}

return <AnimatedScreen active={active} {...rest} />;
};

const { cond, eq } = Animated;

const ANIMATED_ONE = new Animated.Value(1);
Expand Down Expand Up @@ -220,7 +237,10 @@ export default class Stack extends React.Component<Props, State> {

return (
<React.Fragment>
<ScreenContainer style={styles.container} onLayout={this.handleLayout}>
<MaybeScreenContainer
style={styles.container}
onLayout={this.handleLayout}
>
{routes.map((route, index, self) => {
const focused = focusedRoute.key === route.key;
const current = progress[route.key];
Expand Down Expand Up @@ -255,7 +275,7 @@ export default class Stack extends React.Component<Props, State> {
} = descriptor.options;

return (
<AnimatedScreen
<MaybeScreen
key={route.key}
style={StyleSheet.absoluteFill}
active={isScreenActive}
Expand Down Expand Up @@ -296,10 +316,10 @@ export default class Stack extends React.Component<Props, State> {
cardStyleInterpolator={cardStyleInterpolator}
headerStyleInterpolator={headerStyleInterpolator}
/>
</AnimatedScreen>
</MaybeScreen>
);
})}
</ScreenContainer>
</MaybeScreenContainer>
{headerMode === 'float'
? renderHeader({
mode: 'float',
Expand Down

0 comments on commit fb9dbf9

Please sign in to comment.