我有一个 react-native 应用程序,类似于react-navigation 中描述的身份验证流程。我想为AppStack中的所有屏幕添加一个通用背景图像。
我尝试过的事情,
- 我尝试将AppStack导航器包装在里面
<ImageBackground/>
,不知何故屏幕卡总是在顶部。
我需要帮助!
代码片段
const AppStack = createStackNavigator({ Home: HomeScreen, Other: OtherScreen });
const AuthStack = createStackNavigator({ SignIn: SignInScreen, SignUp: SignUpScreen });
class SignInScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, backgroundColor: 'transparent' }}>
<View style={{ width: '50%', backgroundColor: 'white' }}>
<Text>Sign in</Text>
</View>
</View>
)
}
}
class SignUpScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, backgroundColor: 'transparent' }}>
<View style={{ width: '50%', backgroundColor: 'white' }}>
<Text>Sign up</Text>
</View>
</View>
)
}
}
class Authentication extends React.Component {
render() {
return (
<ImageBackground source={source} style={{ flex: 1 }} >
<AuthStack />
</ImageBackground>
)
}
}
export default createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
App: AppStack,
Auth: Authentication,
},
{
initialRouteName: 'Auth',
}
);