import * as React from 'react'; import { View, Text, StyleSheet, ViewStyle, TextStyle, TouchableOpacity } from 'react-native'; // Export all components interface GameHeaderProps { title: string; score?: number; timeLeft?: number; progress?: number; subtitle?: string; backgroundColor?: string; textColor?: string; style?: ViewStyle; } export const GameHeader: React.FC = ({ title, score, timeLeft, progress, subtitle, backgroundColor = '#007AFF', textColor = 'white', style }) => { return ( {title} {subtitle && ( {subtitle} )} {progress !== undefined && ( )} {score !== undefined && ( ניקוד: {score} )} {timeLeft !== undefined && ( זמן: {timeLeft}s )} ); }; interface GameButtonProps { title: string; onPress: () => void; variant?: 'primary' | 'secondary' | 'success' | 'warning' | 'danger'; size?: 'small' | 'medium' | 'large'; disabled?: boolean; style?: ViewStyle; textStyle?: TextStyle; } export const GameButton: React.FC = ({ title, onPress, variant = 'primary', size = 'medium', disabled = false, style, textStyle }) => { const buttonStyle = [ styles.button, styles[`button${variant.charAt(0).toUpperCase() + variant.slice(1)}` as keyof typeof styles], styles[`button${size.charAt(0).toUpperCase() + size.slice(1)}` as keyof typeof styles], disabled && styles.buttonDisabled, style ].filter(Boolean); const textStyleCombined = [ styles.buttonText, styles[`buttonText${size.charAt(0).toUpperCase() + size.slice(1)}` as keyof typeof styles], disabled && styles.buttonTextDisabled, textStyle ].filter(Boolean); return ( {title} ); }; interface ScoreDisplayProps { currentScore: number; maxScore?: number; label?: string; showProgress?: boolean; size?: 'small' | 'medium' | 'large'; color?: string; style?: ViewStyle; } export const ScoreDisplay: React.FC = ({ currentScore, maxScore, label = 'ניקוד', showProgress = false, size = 'medium', color = '#007AFF', style }) => { const progressPercentage = maxScore ? (currentScore / maxScore) * 100 : 0; return ( {label} {currentScore.toLocaleString()} {maxScore && ` / ${maxScore.toLocaleString()}`} {showProgress && maxScore && ( {Math.round(progressPercentage)}% )} ); }; interface TimerProps { timeLeft: number; totalTime?: number; format?: 'seconds' | 'minutes' | 'auto'; showProgress?: boolean; color?: string; warningThreshold?: number; dangerThreshold?: number; style?: ViewStyle; } export const Timer: React.FC = ({ timeLeft, totalTime, format = 'auto', showProgress = false, color = '#333', warningThreshold = 10, dangerThreshold = 5, style }) => { const formatTime = (seconds: number): string => { if (format === 'seconds' || (format === 'auto' && seconds < 60)) { return `${Math.ceil(seconds)}s`; } const minutes = Math.floor(seconds / 60); const remainingSeconds = Math.ceil(seconds % 60); return `${minutes}:${remainingSeconds.toString().padStart(2, '0')}`; }; const getTimerColor = (): string => { if (timeLeft <= dangerThreshold) return '#F44336'; if (timeLeft <= warningThreshold) return '#FF9500'; return color; }; const progressPercentage = totalTime ? (timeLeft / totalTime) * 100 : 0; return ( {formatTime(timeLeft)} {showProgress && totalTime && ( )} ); }; interface LoadingSpinnerProps { size?: 'small' | 'medium' | 'large'; color?: string; text?: string; style?: ViewStyle; } export const LoadingSpinner: React.FC = ({ size = 'medium', color = '#007AFF', text, style }) => { return ( {text && ( {text} )} ); }; const styles = StyleSheet.create({ // GameHeader styles container: { padding: 20, paddingTop: 40, }, title: { fontSize: 24, fontWeight: 'bold', textAlign: 'center', marginBottom: 8, }, subtitle: { fontSize: 16, textAlign: 'center', marginBottom: 15, opacity: 0.9, }, progressContainer: { marginBottom: 15, }, progressBar: { height: 8, backgroundColor: 'rgba(255,255,255,0.3)', borderRadius: 4, }, progressFill: { height: '100%', backgroundColor: '#4CAF50', borderRadius: 4, }, statsContainer: { flexDirection: 'row', justifyContent: 'space-around', }, statText: { fontSize: 16, fontWeight: '600', }, // GameButton styles button: { borderRadius: 8, alignItems: 'center', justifyContent: 'center', shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 4, elevation: 3, }, buttonPrimary: { backgroundColor: '#007AFF', }, buttonSecondary: { backgroundColor: '#5856D6', }, buttonSuccess: { backgroundColor: '#34C759', }, buttonWarning: { backgroundColor: '#FF9500', }, buttonDanger: { backgroundColor: '#FF3B30', }, buttonDisabled: { backgroundColor: '#E0E0E0', shadowOpacity: 0, elevation: 0, }, buttonSmall: { paddingHorizontal: 12, paddingVertical: 8, }, buttonMedium: { paddingHorizontal: 16, paddingVertical: 12, }, buttonLarge: { paddingHorizontal: 24, paddingVertical: 16, }, buttonText: { color: 'white', fontWeight: 'bold', }, buttonTextSmall: { fontSize: 14, }, buttonTextMedium: { fontSize: 16, }, buttonTextLarge: { fontSize: 18, }, buttonTextDisabled: { color: '#999', }, // ScoreDisplay styles scoreContainer: { alignItems: 'center', }, scoreLabel: { color: '#666', marginBottom: 4, }, scoreLabelSmall: { fontSize: 12, }, scoreLabelMedium: { fontSize: 14, }, scoreLabelLarge: { fontSize: 16, }, scoreValue: { fontWeight: 'bold', }, scoreValueSmall: { fontSize: 18, }, scoreValueMedium: { fontSize: 24, }, scoreValueLarge: { fontSize: 32, }, scoreProgressContainer: { alignItems: 'center', marginTop: 8, width: 120, }, scoreProgressBar: { height: 6, backgroundColor: '#E0E0E0', borderRadius: 3, width: '100%', marginBottom: 4, }, scoreProgressFill: { height: '100%', borderRadius: 3, }, scoreProgressText: { fontSize: 12, color: '#666', }, // Timer styles timerContainer: { alignItems: 'center', }, timerText: { fontSize: 20, fontWeight: 'bold', fontFamily: 'monospace', }, timerProgressContainer: { marginTop: 8, width: 60, }, timerProgressBar: { height: 4, backgroundColor: '#E0E0E0', borderRadius: 2, }, timerProgressFill: { height: '100%', borderRadius: 2, }, // LoadingSpinner styles loadingContainer: { alignItems: 'center', justifyContent: 'center', }, spinner: { borderWidth: 3, borderTopColor: 'transparent', borderRadius: 50, }, spinnerSmall: { width: 20, height: 20, }, spinnerMedium: { width: 40, height: 40, }, spinnerLarge: { width: 60, height: 60, }, loadingText: { marginTop: 12, fontSize: 16, }, });