From dd09827d08ece71386f29cfa38dd8e5222efccd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Tue, 9 Jan 2024 17:13:36 +0100 Subject: [PATCH] minor fixes --- front/Navigation.tsx | 6 +- front/components/ScoreModal.tsx | 10 +- front/components/UI/MusicList.tsx | 2 - front/views/LeaderboardView.tsx | 240 +++++++++++++++--------------- front/views/MusicView.tsx | 2 +- front/views/PlayView.tsx | 2 +- 6 files changed, 130 insertions(+), 132 deletions(-) diff --git a/front/Navigation.tsx b/front/Navigation.tsx index c3a06e4..d59a94a 100644 --- a/front/Navigation.tsx +++ b/front/Navigation.tsx @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/ban-types */ -import { NativeStackScreenProps, createNativeStackNavigator } from '@react-navigation/native-stack'; +import { NativeStackNavigationProp, NativeStackScreenProps, createNativeStackNavigator } from '@react-navigation/native-stack'; import { NavigationProp, ParamListBase, @@ -174,7 +174,7 @@ type RouteParams> = { type PrivateRoutesParams = RouteParams; type PublicRoutesParams = RouteParams; type TabsRoutesParams = RouteParams; -type AppRouteParams = PrivateRoutesParams & +type AppRouteParams = Omit & { Tabs: { screen: keyof TabsRoutesParams } } & PublicRoutesParams & TabsRoutesParams & { Oops: undefined }; @@ -324,4 +324,4 @@ export const Router = () => { ); }; -export const useNavigation = () => navigationHook>(); +export const useNavigation = () => navigationHook>(); diff --git a/front/components/ScoreModal.tsx b/front/components/ScoreModal.tsx index 7c2628c..ca79f69 100644 --- a/front/components/ScoreModal.tsx +++ b/front/components/ScoreModal.tsx @@ -97,7 +97,7 @@ const ScoreModal = (props: ScoreModalProps) => { type="outlined" title={translate('playAgain')} onPress={() => - navigation.dispatch(StackActions.replace('Play', { songId: props.songId })) + navigation.replace('Play', { songId: props.songId }) } /> { icon={Play} type="filled" title={translate('menuMusic')} - onPress={() => - navigation.canGoBack() ? navigation.goBack() : navigation.navigate('Home') - } + onPress={() => { + navigation.canGoBack() + ? navigation.goBack() + : navigation.replace('Tabs', { screen: 'Home' }); + }} /> diff --git a/front/components/UI/MusicList.tsx b/front/components/UI/MusicList.tsx index 4272ccd..c3a2bd0 100644 --- a/front/components/UI/MusicList.tsx +++ b/front/components/UI/MusicList.tsx @@ -194,7 +194,6 @@ function MusicListComponent({ // FlatList: Renders list efficiently, only rendering visible items. return ( { ] as const; return ( - - - - {translate('leaderBoardHeading')} - - - {translate('leaderBoardHeadingFull')} - - - {!isPhone ? ( - - - - - - ) : ( - - - - - - - - )} + + + {translate('leaderBoardHeading')} + + + {translate('leaderBoardHeadingFull')} + + + {!isPhone ? ( + + + + + + ) : ( - {scoresQuery.data.slice(3, 20).map((comp, index) => ( - + + - ))} + + + )} + + {scoresQuery.data.slice(3, 20).map((comp, index) => ( + + ))} - - + + ); }; diff --git a/front/views/MusicView.tsx b/front/views/MusicView.tsx index 3bfb4b4..8ad6ae2 100644 --- a/front/views/MusicView.tsx +++ b/front/views/MusicView.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { useBreakpointValue, useTheme } from 'native-base'; -import { useWindowDimensions } from 'react-native'; +import { ScrollView, useWindowDimensions } from 'react-native'; import { TabView, SceneMap, diff --git a/front/views/PlayView.tsx b/front/views/PlayView.tsx index c2bec2e..b25f518 100644 --- a/front/views/PlayView.tsx +++ b/front/views/PlayView.tsx @@ -134,7 +134,7 @@ const PlayView = ({ songId }: PlayViewProps) => { stopwatch.stop(); if (webSocket.current?.readyState != WebSocket.OPEN) { console.warn('onEnd: Websocket not open'); - navigation.dispatch(StackActions.replace('Home', {})); + navigation.replace('Tabs', { screen: 'Home' }); return; } webSocket.current?.send(