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" },
{ title: "市场热点", navigateTo: "MarketDrawer" },
{ title: "Home", navigateTo: "HomeDrawer" },
{ title: "Profile", navigateTo: "ProfileDrawer" },
{ title: "Account", navigateTo: "AccountDrawer" },
{ title: "Elements", navigateTo: "ElementsDrawer" },
{ title: "Articles", navigateTo: "ArticlesDrawer" },
{ title: "Settings", navigateTo: "SettingsDrawer" },
];
return (
{/* 品牌头部 - 黑金主题 */}
价值前沿
VALUE FRONTIER
{/* 用户卡片 */}
{screens.map((item, index) => {
return (
);
})}
DOCUMENTATION
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
header: {
paddingHorizontal: 28,
paddingBottom: theme.SIZES.BASE,
paddingTop: theme.SIZES.BASE * 3,
justifyContent: "center",
},
});
export default CustomDrawerContent;