Skip to content

Instantly share code, notes, and snippets.

@darksh3ll
Created December 27, 2019 13:16
Show Gist options
  • Save darksh3ll/b61820598de91e8addc1a4c20d14a263 to your computer and use it in GitHub Desktop.
Save darksh3ll/b61820598de91e8addc1a4c20d14a263 to your computer and use it in GitHub Desktop.
Probléme d'implémentation Drawer navigation
import React from 'react'
import { View } from 'react-native'
import { Badge } from 'react-native-elements'
import { createAppContainer, createSwitchNavigator } from 'react-navigation'
import { createStackNavigator } from 'react-navigation-stack'
import { createDrawerNavigator } from 'react-navigation-drawer'
import { createBottomTabNavigator } from 'react-navigation-tabs'
import Icon from 'react-native-vector-icons/FontAwesome'
// Screens Auth
import Welcome from './screens/Auth/Welcome'
import SignIn from './screens/Auth/SignIn'
import SignUp from './screens/Auth/SignUp'
import ResetPassword from './screens/Auth/ResetPassword'
import ConfirmResetPassword from './screens/Auth/ConfirmResetPassword'
import AuthLoadingScreen from './screens/Auth/AuthLoading'
// Screens Broker
import Broker from './screens/Broker/Broker'
import CallBack from './screens/Broker/CallBack'
import ConfirmCallBack from './screens/Broker/ConfirmCallBack'
import Home from './screens/Home'
// Screens Folder
import Insctruction from './screens/Folder/Instruction'
import Negotiation from './screens/Folder/Negotiation'
import AgreementInPrinciple from './screens/Folder/AgreementInPrinciple'
import BankAppointment from './screens/Folder/BankAppointment'
import EditedOffer from './screens/Folder/EditedOffer'
import OfferConcluded from './screens/Folder/OfferConcluded'
import YouAreAnOwner from './screens/Folder/YouAreAnOwner'
// Screens MyMessages
import MyMessages from './screens/MyMessages/MyMessages'
// Screens Sponsoring
import Sponsoring from './screens/Sponsoring /Sponsoring'
// Drawer
import Acceuil from './screens/drawer/Acceuil'
import Simulateur from './screens/drawer/Simulateur'
const BadgeNotification = () => {
return (
<Badge
value='9'
status='error'
containerStyle={{ position: 'absolute', top: -1, right: -17 }}
/>
)
}
const TabBarIcon = ({ iconFocused, iconUnfocused, displayBadge }) => ({
tabBarIcon: ({
tintColor,
focused
}) => (
<View>
<Icon
type='font-awesome'
name={focused ? iconFocused : iconUnfocused}
size={25}
style={{ color: tintColor }}
/>
{displayBadge ? <BadgeNotification /> : null}
</View>
)
})
const defaultNavigationOptions = {
tabBarOptions: {
showLabel: false
},
headerStyle: {
backgroundColor: '#e3e3e3'
},
headerTintColor: 'black'
}
const HomeStack = createStackNavigator({
Home: Home
})
// Authentification
const AuthStack = createStackNavigator({
Welcome: Welcome,
SignIn: SignIn,
SignUp: SignUp,
ResetPassword: ResetPassword,
ConfirmResetPassword: ConfirmResetPassword
})
// Broker
const BrowkerStack = createStackNavigator(
{
Broker: Broker,
CallBack: CallBack,
ConfirmCallBack: ConfirmCallBack
},
{
navigationOptions: {
...TabBarIcon({ iconFocused: 'user-circle', iconUnfocused: 'user-circle' }),
title: 'COURTIER',
initialRouteName: 'Welcome'
}
}
)
// Folder
const FolderStack = createSwitchNavigator(
{
Insctruction: Insctruction,
Negotiation: Negotiation,
AgreementInPrinciple: AgreementInPrinciple,
BankAppointment: BankAppointment,
EditedOffer: EditedOffer,
OfferConcluded: OfferConcluded,
YouAreAnOwner: YouAreAnOwner
},
{
defaultNavigationOptions,
navigationOptions: {
...TabBarIcon({ iconFocused: 'folder-open', iconUnfocused: 'folder' }),
title: 'DOSSIERS'
}
},
{ initialRouteName: 'Insctruction' }
)
const MyMessagesStack = createStackNavigator(
{
MyMessages: MyMessages
},
{
defaultNavigationOptions,
navigationOptions: {
...TabBarIcon({ iconFocused: 'envelope-open', iconUnfocused: 'envelope', displayBadge: true }),
title: 'MESSAGES'
}
}
)
const SponsoringStack = createStackNavigator(
{
Sponsoring: Sponsoring
},
{
defaultNavigationOptions,
navigationOptions: {
...TabBarIcon({ iconFocused: 'hourglass-end', iconUnfocused: 'hourglass-start' }),
title: 'PARRAINAGE'
}
}
)
// App Principal
const AppStack = createBottomTabNavigator(
{
Browker: BrowkerStack,
Folder: FolderStack,
Messages: MyMessagesStack,
Sponsoring: SponsoringStack,
Home: HomeStack
},
{
order: ['Browker', 'Folder', 'Messages', 'Sponsoring'],
tabBarOptions: {
style: {
backgroundColor: 'white'
},
activeTintColor: '#104A7A',
inactiveTintColor: 'black',
labelStyle: '#f8c303',
showLabel: true
}
}
)
// Drawer
const DrawerStack = createDrawerNavigator(
{
Acceuil: Acceuil,
Simulateur: Simulateur,
AppStack: AppStack
})
//
const SwitchNavigator = createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
AuthStack: AuthStack,
// AppStack: AppStack, // si activé plus de drawerNavigator
DrawerStack: DrawerStack
},
{ initialRouteName: 'AuthLoading' }
)
export default createAppContainer(SwitchNavigator)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment