const MyDrawerNavigator = createDrawerNavigator({
Home: MyHomeScreen,
Notifications: MyNotificationsScreen,
},{
drawerOpenRoute : "DrawerOpen",
drawerCloseRoute: "DrawerClose",
drawerToggleRoute: "DrawerToggle",
drawerBackgroundColor: "#f4511e"//if you want to change the backgroundColor of the app drawer
});
Last active
December 2, 2021 09:01
-
-
Save gajjardarshithasmukhbhai/6cc93c33b174722c21e49e8fcca87791 to your computer and use it in GitHub Desktop.
In this Gist I make some snippets of code of Navigation so you understand how to different label,Icon-name and Icon-header include in React Navigation
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
TouchableOpacity,
StatusBar,
} from 'react-native';
import { createSwitchNavigator, createAppContainer } from 'react-navigation';
import { createDrawerNavigator } from 'react-navigation-drawer';
import { createStackNavigator, HeaderTitle } from 'react-navigation-stack';
// import * as Animatable from 'react-native-animatable';
import * as Animate from 'react-native-animatable';
import Icon from 'react-native-vector-icons/Ionicons';
class Home extends React.Component {
constructor() {
super();
this.state = {
animationEffect: "",
animationEffec: ""
}
}
render() {
return (
<View>
<View style={{ marginTop: 260, flexDirection: "column", justifyContent: "center", alignItems: "center" }}>
<TouchableOpacity activeOpacity={0.6} onPress={() => {
// console.log("gajjar DArshit");
this.setState({
animationEffect: "bounceIn"
})
setTimeout(() => {
this.props.navigation.navigate("LogIn")
}, 350);
}}>
<Animate.View animation={this.state.animationEffect} style={{ borderWidth: 1, width: 120, height: 60, justifyContent: "center", alignItems: "center" }}>
<Text style={{ fontSize: 20 }}>Login</Text>
</Animate.View>
</TouchableOpacity>
<TouchableOpacity activeOpacity={0.6} onPress={() => {
this.setState({
animationEffec: "flipInY"
})
setTimeout(() => {
this.props.navigation.navigate("SignUp")
}, 620);
}}>
<Animate.View animation={this.state.animationEffec} style={{ marginTop: 10, borderWidth: 1, width: 120, height: 60, justifyContent: "center", alignItems: "center" }}>
<Text style={{ fontSize: 20 }}>Signup</Text>
</Animate.View>
</TouchableOpacity>
</View>
</View>
)
}
}
class Login extends React.Component {
render() {
return (
<View>
<Text style={{ fontSize: 23, marginTop: 290, alignSelf: "center" }} onPress={() => {
this.props.navigation.navigate("Home")
}}>I am Login</Text>
</View>
)
}
}
class SignUp extends React.Component {
render() {
return (
<View>
<Text style={{ fontSize: 23, marginTop: 290, alignSelf: "center" }} onPress={() => {
this.props.navigation.navigate("Home");
}}>I am SignUp</Text>
</View>
)
}
}
class Contact extends React.Component {
render() {
return (
<View>
<Text style={{ fontSize: 23, marginTop: 290, alignSelf: "center" }} onPress={() => {
this.props.navigation.navigate("Home");
}}>I am Contact</Text>
</View>
)
}
}
class Logout extends React.Component {
render() {
return (
<View>
<Text style={{ fontSize: 23, marginTop: 290, alignSelf: "center" }} onPress={() => {
this.props.navigation.navigate("Home");
}}>I am Logout</Text>
</View>
)
}
}
const teabNavigator = createStackNavigator({
Logout: {
screen: Logout,
navigationOptions: ({ navigation }) => ({
title: "Example",
headerLeft: <Icon name="md-menu" size={24} style={{ margin: 20, color: "#ffff" }} onPress={navigation.openDrawer} />,
headerStyle: {
backgroundColor: '#56CC',
},
headerTintColor: '#fff',
})
},
})
class Mayhello extends React.Component {
render() {
return (
<View><Text>hhahha</Text></View>
)
}
}
const treeNavigator = createStackNavigator({
Mayhello: {
screen: Mayhello,
navigationOptions: ({ navigation }) => ({
title: "Example",
headerLeft: <Icon name="md-menu" size={24} style={{ margin: 20, color: "#ffff" }} onPress={navigation.openDrawer} />,
headerStyle: {
backgroundColor: '#56CC',
},
headerTintColor: '#fff',
})
},
})
const teeNavigator = createStackNavigator({
Contact: {
screen: Contact,
navigationOptions: ({ navigation }) => ({
title: "Example",
headerLeft: <Icon name="md-menu" size={24} style={{ margin: 20, color: "#ffff" }} onPress={navigation.openDrawer} />,
headerStyle: {
backgroundColor: '#56CC',
},
headerTintColor: '#fff',
})
},
})
const tebNavigator = createStackNavigator({
LogIn: {
screen: Login,
navigationOptions: ({ navigation }) => ({
title: "Example",
headerLeft: <Icon name="md-menu" size={24} style={{ margin: 20, color: "#ffff" }} onPress={navigation.openDrawer} />,
headerStyle: {
backgroundColor: '#56CC',
},
headerTintColor: '#fff',
})
},
SignUp: {
screen: SignUp,
navigationOptions: ({ navigation }) => ({
// title: "Example",
// headerLeft: <Icon name="md-menu" size={24} style={{ margin: 20, color: "#ffff" }} onPress={navigation.openDrawer} />,
headerStyle: {
backgroundColor: '#56CC',
},
headerTintColor: '#fff',
})
},
contact: {
screen: Contact,
navigationOptions: ({ navigation }) => ({
title: "Example",
headerLeft: <Icon name="md-menu" size={24} style={{ margin: 20, color: "#ffff" }} onPress={navigation.openDrawer} />,
headerStyle: {
backgroundColor: '#56CC',
},
headerTintColor: '#fff',
})
}
})
const drawer = createDrawerNavigator({
LogIn: {
screen: tebNavigator,
},
Logout: {
screen: teabNavigator,
},
Contact: {
screen: teeNavigator,
},
Mayhello: {
screen: treeNavigator,
}
})
const switching = createSwitchNavigator({
Home: {
screen: Home
},
LogIn: {
screen: drawer
},
})
const App = createAppContainer(switching);
export default App;
const style = StyleSheet.create({
text: {
fontSize: 23,
marginTop: 270,
alignSelf: "center"
}
})
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment