import React from "react"; import { ScrollView, StyleSheet, Dimensions, Image, TouchableOpacity, Linking, } from "react-native"; import { Block, Text, theme } from "galio-framework"; import { useSafeArea } from "react-native-safe-area-context"; import { Box, HStack, VStack, Icon, Pressable, Spinner } from "native-base"; import { Ionicons } from "@expo/vector-icons"; import { LinearGradient } from "expo-linear-gradient"; import Images from "../constants/Images"; import { DrawerItem as DrawerCustomItem } from "../components/index"; import { useAuth } from "../src/contexts/AuthContext"; const { width } = Dimensions.get("screen"); // 金色主题色 const GOLD_PRIMARY = '#D4AF37'; // 用户卡片组件 const UserCard = ({ navigation }) => { const { user, isLoggedIn, isLoading, subscription, logout } = useAuth(); const handleLoginPress = () => { navigation.closeDrawer(); // 使用 getParent 获取根导航器来导航到 Login navigation.getParent()?.navigate("Login"); }; const handleLogoutPress = async () => { await logout(); }; // 获取订阅显示文本 const getSubscriptionText = () => { if (!subscription || !subscription.is_active) { return "免费用户"; } const typeMap = { pro: "Pro 会员", max: "Max 会员" }; return typeMap[subscription.type] || "免费用户"; }; if (isLoading) { return ( 加载中... ); } if (!isLoggedIn) { return ( 登录/注册 登录解锁更多功能 ); } // 已登录状态 return ( {(user?.username || user?.nickname || "U").charAt(0).toUpperCase()} {user?.nickname || user?.username || "用户"} {getSubscriptionText()} ); }; function CustomDrawerContent({ drawerPosition, navigation, profile, focused, state, ...rest }) { const insets = useSafeArea(); // 菜单项配置 const screens = [ { title: "事件中心", navigateTo: "EventsDrawer", icon: "flash", gradient: ["#7C3AED", "#A78BFA"] }, { title: "市场热点", navigateTo: "MarketDrawer", icon: "flame", gradient: ["#F59E0B", "#FBBF24"] }, { title: "概念中心", navigateTo: "ConceptsDrawer", icon: "bulb", gradient: ["#06B6D4", "#22D3EE"] }, { title: "我的自选", navigateTo: "WatchlistDrawer", icon: "star", gradient: ["#EC4899", "#F472B6"] }, { title: "个人中心", navigateTo: "ProfileDrawerNew", icon: "person", gradient: ["#8B5CF6", "#A78BFA"] }, ]; return ( {/* 品牌头部 - 黑金主题 */} 价值前沿 VALUE FRONTIER {/* 用户卡片 - 深色版本 */} {/* 导航菜单 */} {screens.map((item, index) => { const isFocused = state.index === index; return ( navigation.navigate(item.navigateTo)} mb={2} > {isFocused ? ( {item.title} ) : ( {item.title} )} ); })} {/* 底部版本信息 */} 价值前沿 v1.0.0 ); } // 深色主题用户卡片 const UserCardDark = ({ navigation }) => { const { user, isLoggedIn, isLoading, subscription, logout } = useAuth(); const handleLoginPress = () => { navigation.closeDrawer(); navigation.getParent()?.navigate("Login"); }; const handleLogoutPress = async () => { await logout(); }; const getSubscriptionText = () => { if (!subscription || !subscription.is_active) return "免费用户"; const typeMap = { pro: "Pro 会员", max: "Max 会员" }; return typeMap[subscription.type] || "免费用户"; }; if (isLoading) { return ( 加载中... ); } if (!isLoggedIn) { return ( 登录/注册 登录解锁更多功能 ); } return ( {(user?.username || user?.nickname || "U").charAt(0).toUpperCase()} {user?.nickname || user?.username || "用户"} {getSubscriptionText()} ); }; const styles = StyleSheet.create({ container: { flex: 1, }, header: { paddingHorizontal: 28, paddingBottom: theme.SIZES.BASE, paddingTop: theme.SIZES.BASE * 3, justifyContent: "center", }, }); export default CustomDrawerContent;