Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add appContainer to modal screens #614

Merged
merged 4 commits into from
Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/native-stack/views/NativeStackView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
useTheme,
} from '@react-navigation/native';
import * as React from 'react';
import { Platform, StyleSheet, View } from 'react-native';
import { Platform, StyleSheet, View, ViewProps } from 'react-native';
// @ts-ignore Getting private component
import AppContainer from 'react-native/Libraries/ReactNative/AppContainer';
import {
Screen as ScreenComponent,
ScreenProps,
Expand All @@ -19,6 +21,24 @@ import HeaderConfig from './HeaderConfig';
const Screen = (ScreenComponent as unknown) as React.ComponentType<ScreenProps>;
const isAndroid = Platform.OS === 'android';

let Container = View;

if (__DEV__) {
const DebugContainer = (props: ViewProps & { stackAnimation: string }) => {
const { stackAnimation, ...rest } = props;
if (Platform.OS === 'ios' && stackAnimation !== 'push') {
return (
<AppContainer>
<View {...rest} />
</AppContainer>
);
}
return <View {...rest} />;
};
// @ts-ignore Wrong props
Container = DebugContainer;
}

type Props = {
state: StackNavigationState;
navigation: NativeStackNavigationHelpers;
Expand Down Expand Up @@ -106,7 +126,12 @@ export default function NativeStackView({
});
}}>
<HeaderConfig {...options} route={route} />
<View style={viewStyles}>{renderScene()}</View>
<Container
style={viewStyles}
// @ts-ignore Wrong props passed to View
stackPresentation={stackPresentation}>
{renderScene()}
</Container>
</Screen>
);
})}
Expand Down