Commit adacfa46 by Giang Tran

edit menu drawer

parent 65a00329
...@@ -67,6 +67,8 @@ const images = { ...@@ -67,6 +67,8 @@ const images = {
iconPaper: require('./images/iconPaper.png'), iconPaper: require('./images/iconPaper.png'),
iconNote: require('./images/iconNote.png'), iconNote: require('./images/iconNote.png'),
bg_cannot_connect: require('./images/bg_cannot_connect.png'), bg_cannot_connect: require('./images/bg_cannot_connect.png'),
iconDown: require('./images/iconDown.png'),
iconUp: require('./images/iconUp.png'),
}; };
export default images; export default images;
import React from 'react'; import React, {useState} from 'react';
import {View, Text, StyleSheet, Image, TouchableOpacity} from 'react-native'; import {
View,
Text,
StyleSheet,
Image,
TouchableOpacity,
ScrollView,
} from 'react-native';
import R from '../../assets/R'; import R from '../../assets/R';
import {HEIGHTXD, getFontXD, WIDTHXD} from '../../Config/Functions'; import {HEIGHTXD, getFontXD, WIDTHXD} from '../../Config/Functions';
import Icon from 'react-native-vector-icons/MaterialIcons'; import Icon from 'react-native-vector-icons/MaterialIcons';
...@@ -15,59 +22,141 @@ import { ...@@ -15,59 +22,141 @@ import {
PROFILE, PROFILE,
CONTRACT, CONTRACT,
LEGALDOCUMENT, LEGALDOCUMENT,
MYGROUP,
PAYMENTS,
DEPOSIT,
WITHDRAW,
ROSE,
HISTORY,
CHOOSEMETHOD,
} from '../../routers/ScreenNames'; } from '../../routers/ScreenNames';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import AppText from '../AppText'; import AppText from '../AppText';
import images from '../../assets/images';
const menus = [ const menus = [
{ {
id: '1', id: '1',
title: 'AccountVerify', title: 'Profile',
icon: R.images.iconUserCheck, icon: R.images.iconUserCheck,
screen: AccountVerification, screen: AccountVerification,
active: false,
children: [
{
id: '11',
title: 'MyProfile',
icon: R.images.iconUserCheck,
screen: PROFILE,
}, },
{ {
id: '6', id: '12',
title: 'VerifyAccount',
icon: R.images.iconUserCheck,
screen: AccountVerification,
},
{
id: '15',
title: 'MyPartner',
icon: R.images.iconUserCheck,
screen: MYGROUP,
},
{
id: '13',
title: 'Payments',
icon: R.images.iconUserCheck,
screen: PAYMENTS,
},
{
id: '14',
title: 'Contract', title: 'Contract',
icon: R.images.iconUserCheck,
screen: CONTRACT,
},
],
},
{
id: '6',
title: 'Finance',
icon: R.images.iconContract, icon: R.images.iconContract,
screen: CONTRACT, screen: CONTRACT,
active: false,
children: [
{
id: '61',
title: 'Deposit',
icon: R.images.iconUserCheck,
screen: CHOOSEMETHOD,
}, },
{ {
id: '2', id: '62',
title: 'PaymentSetting', title: 'Withdraw',
icon: R.images.iconMethodPay, icon: R.images.iconUserCheck,
screen: METHODPAY, screen: WITHDRAW,
},
{
id: '63',
title: 'Rose',
icon: R.images.iconUserCheck,
screen: ROSE,
},
{
id: '64',
title: 'History',
icon: R.images.iconUserCheck,
screen: HISTORY,
}, },
],
},
{
id: '8',
title: 'Support',
icon: R.images.iconContract,
screen: CONTRACT,
active: false,
children: [
{ {
id: '3',
title: 'CustomerCare', title: 'CustomerCare',
icon: R.images.iconPhone, icon: R.images.iconPhone,
screen: SERVICECUSTOMER, screen: SERVICECUSTOMER,
id: '81',
}, },
{ {
id: '4', id: '82',
title: 'Feedback', title: 'Feedback',
icon: R.images.iconMess, icon: R.images.iconUserCheck,
screen: FEEDBACK, screen: FEEDBACK,
}, },
{ {
id: '7', id: '83',
title: 'LegalDocument', title: 'LegalDocument',
icon: R.images.iconPaper, icon: R.images.iconUserCheck,
screen: LEGALDOCUMENT, screen: LEGALDOCUMENT,
}, },
],
},
{
id: '2',
title: 'PaymentSetting',
icon: R.images.iconMethodPay,
screen: METHODPAY,
active: false,
children: null,
},
{ {
id: '5', id: '5',
title: 'Setting', title: 'Setting',
icon: R.images.iconSetting, icon: R.images.iconSetting,
screen: SETTING, screen: SETTING,
active: false,
children: null,
}, },
]; ];
const Drawer = (props) => { const Drawer = (props) => {
const navigate = useNavigation(); const navigate = useNavigation();
const [listMenu, setListMenu] = useState(menus);
return ( return (
<View style={styles.container}> <View style={styles.container}>
<View style={styles.header}> <View style={styles.header}>
...@@ -88,20 +177,64 @@ const Drawer = (props) => { ...@@ -88,20 +177,64 @@ const Drawer = (props) => {
<Image source={R.images.iconRight2} style={styles.imgIcon} /> <Image source={R.images.iconRight2} style={styles.imgIcon} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View style={styles.body}> <ScrollView showsVerticalScrollIndicator={false} style={styles.body}>
{menus.map((e) => ( {listMenu.map((e) => (
<View>
<TouchableOpacity <TouchableOpacity
onPress={() => { onPress={() => {
if (e.children) {
const newList = listMenu.map((temp) => {
if (temp.id == e.id) return {...temp, active: !temp.active};
return temp;
});
setListMenu(newList);
} else {
navigate.navigate(e.screen); navigate.navigate(e.screen);
props.toggleModal(); props.toggleModal();
}
}} }}
key={e.id} key={e.id}
style={styles.containerItem}> style={styles.containerItem}>
<View style={styles.row}>
<Image source={e.icon} style={styles.imgIcon} /> <Image source={e.icon} style={styles.imgIcon} />
<AppText i18nKey={e.title} style={styles.txtTitle}></AppText> <AppText
i18nKey={e.title}
style={[
styles.txtTitle,
e.children ? {fontWeight: 'bold'} : null,
e.active ? {color: R.colors.main} : null,
]}></AppText>
</View>
{e.children ? (
<Image
source={e.active ? images.iconUp : images.iconDown}
style={styles.imgIcon}
/>
) : null}
</TouchableOpacity>
{e.active && e.children ? (
<View style={{marginLeft: 15}}>
{e.children.map((item) => (
<TouchableOpacity
onPress={() => {
navigate.navigate(item.screen);
props.toggleModal();
}}
key={item.id}
style={styles.containerItem}>
<Image source={item.icon} style={styles.imgIcon} />
<AppText
i18nKey={item.title}
style={styles.txtTitle}></AppText>
</TouchableOpacity> </TouchableOpacity>
))} ))}
</View> </View>
) : null}
</View>
))}
</ScrollView>
<TouchableOpacity <TouchableOpacity
onPress={() => { onPress={() => {
...@@ -175,12 +308,13 @@ const styles = StyleSheet.create({ ...@@ -175,12 +308,13 @@ const styles = StyleSheet.create({
containerItem: { containerItem: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
marginVertical: 10, marginVertical: 5,
borderRadius: WIDTHXD(75), borderRadius: WIDTHXD(75),
paddingVertical: 10, paddingVertical: 10,
paddingHorizontal: 10, paddingHorizontal: 10,
}, },
row: {flexDirection: 'row', flex: 1, alignItems: 'center'},
}); });
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
......
...@@ -189,4 +189,7 @@ export default { ...@@ -189,4 +189,7 @@ export default {
OwnerAccount2: 'Owner account', OwnerAccount2: 'Owner account',
NothingChange: 'Nothing change', NothingChange: 'Nothing change',
Tradding: 'Tradding', Tradding: 'Tradding',
Finance: 'Finance',
Support: 'Hỗ trợ',
Support_Customer: 'Support_Customer',
}; };
...@@ -194,4 +194,7 @@ export default { ...@@ -194,4 +194,7 @@ export default {
OwnerAccount2: 'Chủ tài khoản', OwnerAccount2: 'Chủ tài khoản',
NothingChange: 'Không có gì thay đổi', NothingChange: 'Không có gì thay đổi',
Tradding: 'Giao dịch', Tradding: 'Giao dịch',
Finance: 'Tài chính',
Support: 'Hỗ trợ',
Support_Customer: 'Hỗ trợ khách hàng',
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment