import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; import type { Quest } from '../types'; // ───────────────────────────────────────────────────────────────────────────── // Props // ───────────────────────────────────────────────────────────────────────────── interface QuestProgressProps { quest: Quest; primaryColor?: string; backgroundColor?: string; style?: object; } // ───────────────────────────────────────────────────────────────────────────── // Component // ───────────────────────────────────────────────────────────────────────────── export function QuestProgress({ quest, primaryColor = '#6366F1', backgroundColor = '#E5E7EB', style, }: QuestProgressProps) { const progressPercent = quest.target > 0 ? (quest.progress / quest.target) * 100 : 0; const isCompleted = quest.status === 'completed'; return ( {quest.name} {isCompleted && } {quest.description} {quest.progress} / {quest.target} {Math.round(progressPercent)}% {quest.rewards && quest.rewards.length > 0 && ( Rewards: {quest.rewards.map((reward, idx) => ( {reward.type === 'points' && `${reward.amount} ${reward.currency}`} {reward.type === 'badge' && `🏅 Badge`} {reward.type === 'reward' && `🎁 Reward`} ))} )} ); } // ───────────────────────────────────────────────────────────────────────────── // Styles // ───────────────────────────────────────────────────────────────────────────── const styles = StyleSheet.create({ container: { backgroundColor: '#FFFFFF', borderRadius: 12, padding: 16, marginVertical: 8, shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 4, elevation: 3, }, header: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 4, }, name: { fontSize: 16, fontWeight: '600', color: '#1F2937', }, completedBadge: { fontSize: 18, color: '#10B981', }, description: { fontSize: 14, color: '#6B7280', marginBottom: 12, }, progressBar: { height: 8, borderRadius: 4, overflow: 'hidden', }, progressFill: { height: '100%', borderRadius: 4, }, footer: { flexDirection: 'row', justifyContent: 'space-between', marginTop: 8, }, progressText: { fontSize: 12, color: '#6B7280', }, percentText: { fontSize: 12, fontWeight: '600', color: '#1F2937', }, rewards: { flexDirection: 'row', alignItems: 'center', marginTop: 12, paddingTop: 12, borderTopWidth: 1, borderTopColor: '#E5E7EB', }, rewardLabel: { fontSize: 12, color: '#6B7280', marginRight: 8, }, rewardText: { fontSize: 12, color: '#1F2937', marginRight: 8, }, }); export default QuestProgress;