mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-13 22:30:41 +08:00
Export native screen components so that they can be wrapped in reanimated view wrapper
This commit is contained in:
5
src/screens.d.ts
vendored
5
src/screens.d.ts
vendored
@@ -7,7 +7,7 @@ declare module 'react-native-screens' {
|
||||
|
||||
export function useScreens(shouldUseScreens?: boolean): void;
|
||||
export function screensEnabled(): boolean;
|
||||
|
||||
|
||||
export interface ScreenProps extends ViewProps {
|
||||
active?: boolean;
|
||||
onComponentRef?: (view: any) => void;
|
||||
@@ -16,4 +16,7 @@ declare module 'react-native-screens' {
|
||||
|
||||
export type ScreenContainerProps = ViewProps;
|
||||
export const ScreenContainer: ComponentClass<ScreenContainerProps>;
|
||||
|
||||
export const NativeScreen: ComponentClass<ScreenProps>;
|
||||
export const NativeScreenContainer: ComponentClass<ScreenContainerProps>;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ export function screensEnabled() {
|
||||
return USE_SCREENS;
|
||||
}
|
||||
|
||||
const NativeScreen = Animated.createAnimatedComponent(
|
||||
requireNativeComponent('RNSScreen', null)
|
||||
);
|
||||
export const NativeScreen = requireNativeComponent('RNSScreen', null);
|
||||
|
||||
const NativeScreenContainer = requireNativeComponent(
|
||||
const AnimatedNativeScreen = Animated.createAnimatedComponent(NativeScreen);
|
||||
|
||||
export const NativeScreenContainer = requireNativeComponent(
|
||||
'RNSScreenContainer',
|
||||
null
|
||||
);
|
||||
@@ -59,7 +59,7 @@ export class Screen extends React.Component {
|
||||
} else {
|
||||
const { style, children, ...rest } = this.props;
|
||||
return (
|
||||
<NativeScreen
|
||||
<AnimatedNativeScreen
|
||||
{...rest}
|
||||
ref={this.setRef}
|
||||
style={StyleSheet.absoluteFill}>
|
||||
@@ -71,7 +71,7 @@ export class Screen extends React.Component {
|
||||
and avoid wrapping with `Animated.View`.
|
||||
*/}
|
||||
<Animated.View style={style}>{children}</Animated.View>
|
||||
</NativeScreen>
|
||||
</AnimatedNativeScreen>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,3 +13,7 @@ export function screensEnabled() {
|
||||
export const Screen = Animated.View;
|
||||
|
||||
export const ScreenContainer = View;
|
||||
|
||||
export const NativeScreen = View;
|
||||
|
||||
export const NativeScreenContainer = View;
|
||||
|
||||
Reference in New Issue
Block a user