import { Column, Row, Text, useTheme } from 'native-base'; import ButtonBase from './UI/ButtonBase'; import { Translate, TranslationKey, translate } from '../i18n/i18n'; import { Play, Star1 } from 'iconsax-react-native'; import { useNavigation } from '../Navigation'; type ScoreModalProps = { songId: number; overallScore: number; precision: number; score: { missed: number; good: number; great: number; perfect: number; wrong: number; max_score: number; current_streak: number; max_streak: number; }; }; const ScoreModal = (props: ScoreModalProps) => { const navigation = useNavigation(); const theme = useTheme(); const score = (props.overallScore * 100) / props.score.max_score; const column1 = { perfect: [props.score.perfect, 'primary'], great: [props.score.great, 'secondary'], good: [props.score.good, 'success'], } as const; const column2 = { bestStreak: [props.score.max_streak, 'notification'], missed: [props.score.missed, 'alert'], wrong: [props.score.wrong, 'error'], } as const; return ( {[1, 2, 3].map((index) => ( = (index * 100) / 4 ? 'Bold' : 'Outline'} /> ))} {Math.max(score, 0).toFixed(2)}% {props.precision}% {([column1, column2] as const).map((column, columnIndex) => ( {Object.entries(column).map(([key, [value, color]]) => { const translationKey = key as TranslationKey; return ( x{value} ); })} ))} navigation.replace('Play', { songId: props.songId })} /> { navigation.canGoBack() ? navigation.goBack() : navigation.replace('Tabs', { screen: 'Home' }); }} /> ); }; export default ScoreModal;