Skip to content

Instantly share code, notes, and snippets.

@phrozenra
Created February 17, 2017 17:04
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save phrozenra/f38df22a04c2b86dcea2b6091e7dc9d2 to your computer and use it in GitHub Desktop.
Save phrozenra/f38df22a04c2b86dcea2b6091e7dc9d2 to your computer and use it in GitHub Desktop.
react-navigation: full screen background with transparent status bar and nav bar
import React from 'react'
import { StackNavigator } from 'react-navigation'
import { Image, StatusBar, Platform } from 'react-native'
import SignInScreen from './signin'
import LoginScreen from './login'
import RegisterScreen from './register'
import ForgotPasswordScreen from './forgot-password'
import Styles from '../../styles/login'
const LoginNavigator = StackNavigator({
SignIn: { screen: SignInScreen },
Login: { screen: LoginScreen },
Register: { screen: RegisterScreen },
ForgotPassword: { screen: ForgotPasswordScreen },
}, {
mode: 'card',
cardStyle: { backgroundColor: 'transparent' },
tintColor: '#ffffff',
headerMode: 'screen'
});
class LoginScreenWrapper extends React.Component {
static navigationOptions = {
header: {
visible: false,
}
}
render() {
return (
<Image source={require('../../../img/login_bg.png')} style={Styles.backgroundImage}>
<StatusBar barStyle="light-content" backgroundColor="transparent" translucent={true}/>
<LoginNavigator screenProps={{rootNavigation: this.props.navigation}} style={{marginTop: StatusBar.currentHeight}}/>
</Image>
)
}
}
export default LoginScreenWrapper
import React, { PropTypes } from 'react'
import { Text, View } from 'react-native'
import BarButton, { BarButtonGroup } from '../../components/common/bar-button'
import Styles from '../../styles/login'
class SignIn extends React.Component {
static navigationOptions = {
header: (navigation) => ({
visible: true,
style: Styles.navBar,
tintColor: 'white',
}),
}
render () {
return (
<View style={Styles.container}>
<Text style={Styles.text}>All login / signup options are here</Text>
</View>
)
}
}
export default SignIn;
import { StyleSheet } from 'react-native'
import CommonStyles from './common'
export default StyleSheet.create({
navBar: {
backgroundColor: 'transparent',
},
backgroundImage: {
resizeMode: 'cover',
width: null,
height: null,
backgroundColor: 'transparent',
flex: 1,
flexDirection: 'column',
},
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
text: {
color: 'white'
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment