Как добавить динамическую навигацию по выдвижным ящикам, которая изменяется с RTL на ltr и наоборот.
после входа переходит на главную страницу, где можно открыть ящик, но его положение зависит от языка, который пользователь выбрал при входе в систему
app.js
import React from 'react';
import TeaApp from './Pages/navigation';
export default class App extends React.Component {
constructor(){
super();
this.state = {
name : '',
};
}
render() {
return (
<TeaApp/>
);
}
}
навигация
import React,{ Component } from 'react';
import { AsyncStorage, View, Text, Image, StyleSheet, Button, SafeAreaView} from 'react-native';
import { StackNavigator , SwitchNavigator, DrawerNavigator, DrawerItems,TouchableOpacity} from 'react-navigation';
import Login from './login';
import Mainpage from './mainPage';
import Menu from './menu';
import CustomizeOrder from './customizeOrder';
import Intro from './intro';
import PreviewOrder from './previewOrder';
import ViewOrder from './viewOrder';
const INTRO = StackNavigator({ Intro:{screen: Intro} });
const LOGIN = StackNavigator({ Login:{screen: Login} });
const REST = StackNavigator({
UserHome:{screen: Mainpage,navigationOptions:({navigation})=>({drawerLockMode:"locked-closed"})},
Menu:{screen: Menu,navigationOptions:({navigation})=>({drawerLockMode:"locked-closed"})},
customizeOrder:{screen: CustomizeOrder,navigationOptions:({navigation})=>({drawerLockMode:"locked-closed"})},
previewOrder:{screen: PreviewOrder,navigationOptions:({navigation})=>({drawerLockMode:"locked-closed"})},
viewOrder:{screen: ViewOrder,navigationOptions:({navigation})=>({drawerLockMode:"locked-closed"})},
});
const DrawerUserAR = DrawerNavigator(
{
الصفحة_الرئيسية :{screen: REST,navigationOptions:({navigation})=>({drawerLockMode:"locked-closed"})},
المطبخ :{screen: KitchenPage},
الطلبات:{screen: VIEWORDER},
تغيير_كلمة_المرور:{screen: ChangePassword},
تغيير_اللغة: {screen: ChangeLanguage}
//logout:{}
},
{
initialRouteName: 'الصفحة_الرئيسية',
drawerPosition: 'right',
contentComponent:(props) => (
<View style={{flex:1}}>
<Image
style={styles.drawerImage}
source={{uri:props.descriptors.الصفحة_الرئيسية.navigation.state.routes[0].params.content.company_logo_small}} />
<Text/>
<Text style={{textAlign:'center',fontSize:15,marginVertical:15}}>{props.descriptors.الصفحة_الرئيسية.navigation.state.routes[0].params.content.name}</Text>
<Text/>
<DrawerItems {...props} />
<Text/><Text/>
<Text/><Text/>
<Text/><Text/>
<Text/><Text/>
<Text/><Text/>
</View>),
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle'
}
);
const DrawerUserEN = DrawerNavigator(
{
Mainpage :{screen: REST,navigationOptions:({navigation})=>({drawerLockMode:"locked-closed"})},
Kitchen :{screen: KitchenPage},
viewOrder:{screen: VIEWORDER},
changePassword:{screen: ChangePassword},
changeLanguage: {screen: ChangeLanguage}
//logout:{}
},
{
initialRouteName: 'Mainpage',
drawerPosition: 'left',
contentComponent:(props) =>
(
<View style={{flex:1}}>
<Image
style={styles.drawerImage}
source={{uri:props.descriptors.Mainpage.navigation.state.routes[0].params.content.company_logo_small}} />
<Text/>
<Text style={{textAlign:'center',fontSize:15,marginVertical:15}}>{props.descriptors.Mainpage.navigation.state.routes[0].params.content.name}</Text>
<Text/>
<DrawerItems {...props} />
<Text/><Text/>
<Text/><Text/>
<Text/><Text/>
</View>),
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle'
}
);
export default SwitchNavigator(
{
intro:{screen: INTRO},
login:{screen: LOGIN},
rest:{screen: REST},
rest:{screen: /*drawer depending on the language that will get it from login*/},
},
{
initialRouteName: 'intro'
}
);
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
drawerHeader: {
height: 200,
backgroundColor: 'white'
},
drawerImage: {
marginTop: 20,
height: 150,
width: 150,
borderRadius: 75,
alignSelf:'center'
}
})
________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ________________________________________________________________________________________________________________________________________________________________