/** * 新版首页抽屉菜单 * @邠心vbe on 2024/02/01 */ import React from 'react'; import {View, Text, StyleSheet, Image} from 'react-native'; import app from '../../../app.json'; import { PageList } from '../Router'; import Button from '../../components/Button'; import { BackButton, Styles } from '../../components/Toolbar'; import TextView from '../../components/TextView'; import apiCharge from '../../api/apiCharge'; import { TouchableWithoutFeedback } from 'react-native-gesture-handler'; import { toTopupPage } from '../payment/PaymentConfig'; import utils from '../../utils/utils'; import Dialog from '../../components/Dialog'; import { Path, Svg } from 'react-native-svg'; const DEBUG = app.debug && !app.product; export default DrawerV2 = ({isLogin=false, userInfo, onLogout, sideCountInfo={}, navigation}) => { const getCharging = () => { Dialog.showProgressDialog(); apiCharge.getUserCharging().then(res => { Dialog.dismissLoading(); if (res.data.sitePk) { utils.toChargeDetailPage(res.data.sitePk, 'view', PageList.home); //startPage(PageList.chargeDetailPage, {stationInfo: {id: res.data.sitePk}, action: 'view', from: PageList.home}); //startPage(PageList.chargeDetail, { stationInfo: {id: res.data.sitePk}, action: 'view'}); } else if (res.msg) { toastShort(res.msg); } else { toastShort($t("drawer.noChargingSession")); } }).catch((err) => { if (app.debug) console.log(err); Dialog.dismissLoading(); toastShort($t("drawer.noChargingSession")); }) } const logout = () => { Dialog.showDialog({ title: $t('profile.signOut'), message: $t('profile.tipSignOut'), callback: btn => { if (btn == Dialog.BUTTON_OK) { Dialog.showProgressDialog(); setTimeout(() => { if (onLogout) onLogout(); }, 500); } } }) } return ( { (isLogin && userInfo.photoUrl) ? : } navigation?.toggleDrawer()}> { isLogin ? { userInfo.nickName ? userInfo.nickName : $t('drawer.logging') } {userInfo.email} : } { isLogin && <> } { (app.v3.vouchers && isLogin) && } { (app.notifications.enable && isLogin) && } { (app.modules.bookmarks && isLogin) && } {/*附加功能-结束*/} { (app.modules.membership && isLogin) && } {/* */} {/* */} { app.modules.support && } { DEBUG && <> } ); } const styles = StyleSheet.create({ drawerView: { paddingTop: 8, paddingBottom: 8, }, loginView: { paddingTop: 16, paddingBottom: 0 }, avatar: { width: 66, height: 66, marginLeft: 24, borderWidth: 2, borderRadius: 80, borderColor: colorLight, }, closeMenu: { width: 46, height: 46, marginRight: 16, borderRadius: 46, alignItems: 'center', justifyContent: 'center', backgroundColor: colorPrimary }, nickView: { borderRadius: 0, backgroundColor: colorLight }, nickViewStyle: { flex: 1, alignItems: 'center', flexDirection: 'row', ...$padding(12, 16) }, nickname: { flex: 1, color: textPrimary, fontSize: 20, fontWeight: 'bold', paddingLeft: 16, }, emailText: { color: textPrimary, fontSize: 11, marginTop: -5, paddingLeft: 16, paddingBottom: 4 }, loginText: { flex: 1, color: textPrimary, fontSize: 20, fontWeight: 'bold', marginTop: 4, paddingTop: 4, paddingLeft: 16, paddingBottom: 4 }, divideLogin: { height: 4, marginTop: 2, marginRight: 0, marginBottom: 8, backgroundColor: colorPrimary }, itemButton: { borderRadius: 0, backgroundColor: colorLight }, itemView: { flex: 1, height: 48, paddingLeft: 16, marginBottom: 0, alignItems: 'center', flexDirection: 'row' }, icon: { width: 24, height: 24, marginRight: 16 }, label: { flex: 1, color: textPrimary, fontSize: 14, }, divided: { height: 1, marginTop: 24, marginLeft: 16, backgroundColor: colorAccent }, balanceText: { color: textPrimary, fontSize: 14, marginRight: 20 }, balanceText2: { color: colorPrimary, fontSize: 14, marginRight: 20 }, bridgeText: { width: 20, height: 20, color: textLight, fontSize: 12, marginRight: 16, borderRadius: 30, fontWeight: 'bold', alignItems: 'center', flexDirection: 'row', justifyContent: 'center', backgroundColor: "#FF3B30" }, bridgeText2: { width: 22, height: 22, color: textLight, fontSize: 10, marginRight: 16, borderRadius: 30, fontWeight: 'bold', alignItems: 'center', flexDirection: 'row', justifyContent: 'center', backgroundColor: "#FF3B30" } });