import { IconSymbol } from '@/components/ui/IconSymbol'; import { Colors } from '@/constants/Colors'; import { useAppSelector } from '@/hooks/redux'; import { useColorScheme } from '@/hooks/useColorScheme'; import { selectChallengeCards, type ChallengeViewModel } from '@/store/challengesSlice'; import { LinearGradient } from 'expo-linear-gradient'; import { useRouter } from 'expo-router'; import React from 'react'; import { Image, ScrollView, StatusBar, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; const AVATAR_SIZE = 36; const CARD_IMAGE_WIDTH = 132; const CARD_IMAGE_HEIGHT = 96; export default function ChallengesScreen() { const theme = (useColorScheme() ?? 'light') as 'light' | 'dark'; const colorTokens = Colors[theme]; const router = useRouter(); const challenges = useAppSelector(selectChallengeCards); const gradientColors: [string, string] = theme === 'dark' ? ['#1f2230', '#10131e'] : [colorTokens.backgroundGradientStart, colorTokens.backgroundGradientEnd]; return ( 挑战 参与精选活动,保持每日动力 {challenges.map((challenge) => ( router.push({ pathname: '/challenges/[id]', params: { id: challenge.id } }) } /> ))} ); } type ChallengeCardProps = { challenge: ChallengeViewModel; surfaceColor: string; textColor: string; mutedColor: string; onPress: () => void; }; function ChallengeCard({ challenge, surfaceColor, textColor, mutedColor, onPress }: ChallengeCardProps) { return ( {challenge.title} {challenge.dateRange} {challenge.participantsLabel} ); } type AvatarStackProps = { avatars: string[]; borderColor: string; }; function AvatarStack({ avatars, borderColor }: AvatarStackProps) { return ( {avatars.map((avatar, index) => ( ))} ); } const styles = StyleSheet.create({ screen: { flex: 1, }, safeArea: { flex: 1, }, scrollContent: { paddingHorizontal: 20, paddingBottom: 32, }, headerRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginTop: 8, marginBottom: 26, }, title: { fontSize: 32, fontWeight: '700', letterSpacing: 1, }, subtitle: { marginTop: 6, fontSize: 14, fontWeight: '500', opacity: 0.8, }, giftShadow: { shadowColor: 'rgba(94, 62, 199, 0.45)', shadowOffset: { width: 0, height: 8 }, shadowOpacity: 0.35, shadowRadius: 12, elevation: 8, borderRadius: 26, }, giftButton: { width: 52, height: 52, borderRadius: 26, alignItems: 'center', justifyContent: 'center', }, cardsContainer: { gap: 18, }, card: { flexDirection: 'row', borderRadius: 28, padding: 18, alignItems: 'center', shadowOffset: { width: 0, height: 16 }, shadowOpacity: 0.18, shadowRadius: 24, elevation: 6, }, cardImage: { width: CARD_IMAGE_WIDTH, height: CARD_IMAGE_HEIGHT, borderRadius: 22, }, cardContent: { flex: 1, marginLeft: 16, }, cardTitle: { fontSize: 18, fontWeight: '700', marginBottom: 4, }, cardDate: { fontSize: 13, fontWeight: '500', marginBottom: 4, }, cardParticipants: { fontSize: 13, fontWeight: '500', }, avatarRow: { flexDirection: 'row', marginTop: 16, alignItems: 'center', }, avatar: { width: AVATAR_SIZE, height: AVATAR_SIZE, borderRadius: AVATAR_SIZE / 2, borderWidth: 2, }, avatarOffset: { marginLeft: -12, }, });