From 66048ca7935e7f4fce0427d4307a8e3313e4b595 Mon Sep 17 00:00:00 2001 From: Arthur Jamet Date: Sun, 19 Nov 2023 16:27:40 +0100 Subject: [PATCH] Front: Prettier --- front/i18n/Translations.ts | 9 +++-- front/views/PlayView.tsx | 71 ++++++++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/front/i18n/Translations.ts b/front/i18n/Translations.ts index fca7ca0..85c8cc6 100644 --- a/front/i18n/Translations.ts +++ b/front/i18n/Translations.ts @@ -298,7 +298,8 @@ export const en = { changeIt: 'Change It', verified: 'Verified', selectPlayMode: 'Select a play mode', - selectPlayModeExplaination: "'Practice' only considers the notes you play, while 'Play' mode also takes rhythm into account." + selectPlayModeExplaination: + "'Practice' only considers the notes you play, while 'Play' mode also takes rhythm into account.", }; export const fr: typeof en = { @@ -602,7 +603,8 @@ export const fr: typeof en = { changeIt: 'Modifier', verified: 'Verifié', selectPlayMode: 'Sélectionnez un mode de jeu', - selectPlayModeExplaination: "Le mode 'S'entrainer' ne compte que les notes, tandis que le mode 'Jouer' prend en compte à la fois les notes et le rythme." + selectPlayModeExplaination: + "Le mode 'S'entrainer' ne compte que les notes, tandis que le mode 'Jouer' prend en compte à la fois les notes et le rythme.", }; export const sp: typeof en = { @@ -912,5 +914,6 @@ export const sp: typeof en = { changeIt: 'Cambialo', verified: 'Verified', selectPlayMode: 'Selecciona un modo de juego', - selectPlayModeExplaination: "El modo 'práctica' solo cuenta notas, mientras que el modo 'reproducir' tiene en cuenta tanto las notas como el ritmo." + selectPlayModeExplaination: + "El modo 'práctica' solo cuenta notas, mientras que el modo 'reproducir' tiene en cuenta tanto las notas como el ritmo.", }; diff --git a/front/views/PlayView.tsx b/front/views/PlayView.tsx index 86596bf..aeb72e9 100644 --- a/front/views/PlayView.tsx +++ b/front/views/PlayView.tsx @@ -90,7 +90,7 @@ const PlayView = ({ songId, route }: RouteProps) => { const [paused, setPause] = useState(true); const stopwatch = useStopwatch(); const [time, setTime] = useState(0); - const songHistory = useQuery(API.getSongHistory(songId), { refetchOnWindowFocus: true }); + const songHistory = useQuery(API.getSongHistory(songId)); const [partitionRendered, setPartitionRendered] = useState(false); // Used to know when partitionview can render const [score, setScore] = useState(0); // Between 0 and 100 // const fadeAnim = useRef(new Animated.Value(0)).current; @@ -109,7 +109,8 @@ const PlayView = ({ songId, route }: RouteProps) => { }); const colorScheme = useColorScheme(); const { colors } = useTheme(); - const textColor = colorScheme == 'dark' ? colors.lightText : colors.coolGray[800]; + const textColor = colors.text; + const statColor = colors.lightText; const onPause = () => { stopwatch.pause(); @@ -303,7 +304,7 @@ const PlayView = ({ songId, route }: RouteProps) => { } }, [song.data, partitionRendered]); - if (!song.data || !songHistory.data) { + if (!song.data) { return ; } return ( @@ -335,12 +336,16 @@ const PlayView = ({ songId, route }: RouteProps) => { title={translate('selectPlayMode')} description={translate('selectPlayModeExplaination')} isVisible={type === undefined} - setIsVisible={navigation.canGoBack() ? (isVisible) => { - if (!isVisible) { - // If we dismiss the popup, Go to previous page - navigation.goBack(); - } - } : undefined} + setIsVisible={ + navigation.canGoBack() + ? (isVisible) => { + if (!isVisible) { + // If we dismiss the popup, Go to previous page + navigation.goBack(); + } + } + : undefined + } > ) => { /> setType('normal')} /> - - {/* eslint-disable-next-line react/jsx-key*/} - {([['lastScore', songHistory.data.best ?? 0, ], ['bestScore', songHistory.data.history.at(0)?.score ?? 0, ]] as const) - .map(([label, value, icon]) => ( + {( + [ + [ + 'lastScore', + songHistory.data?.best ?? 0, + () => , + ] as const, + [ + 'bestScore', + songHistory.data?.history.at(0)?.score ?? 0, + () => , + ], + ] as const + ).map(([label, value, icon]) => ( ) => { alignItems: 'center', }} > - - + + ) => { gap: 5, }} > - {icon} - + {icon()} + {value} @@ -410,7 +425,7 @@ const PlayView = ({ songId, route }: RouteProps) => { borderRadius: 12, }} > - + {score} @@ -428,10 +443,10 @@ const PlayView = ({ songId, route }: RouteProps) => { borderRadius: 12, }} > - + {lastScoreMessage?.content} - + {streak > 0 && `x${streak}`} @@ -516,7 +531,7 @@ const PlayView = ({ songId, route }: RouteProps) => { }} > ) => { {song.data.name} ) => { } + icon={ + + } onPress={() => { if (paused) { onResume(); @@ -570,7 +591,7 @@ const PlayView = ({ songId, route }: RouteProps) => { /> )} - + {time < 0 ? paused ? '0:00'