Merge pull request #197 from Chroma-Case/front/fix-game-end-flow

This commit is contained in:
Arthur Jamet
2023-05-04 06:49:47 +01:00
committed by GitHub
5 changed files with 14 additions and 34 deletions
-15
View File
@@ -1,15 +0,0 @@
> Why do I have a folder named ".expo" in my project?
The ".expo" folder is created when an Expo project is started using "expo start" command.
> What do the files contain?
- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds.
- "packager-info.json": contains port numbers and process PIDs that are used to serve the application to the mobile device/simulator.
- "settings.json": contains the server configuration that is used to serve the application manifest.
> Should I commit the ".expo" folder?
No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine.
Upon project creation, the ".expo" folder is already added to your ".gitignore" file.
-8
View File
@@ -1,8 +0,0 @@
{
"hostType": "lan",
"lanType": "ip",
"dev": true,
"minify": false,
"urlRandomness": null,
"https": false
}
+2 -2
View File
@@ -21,11 +21,11 @@ import { Button, Center, VStack } from 'native-base';
const protectedRoutes = () => ({ const protectedRoutes = () => ({
Home: { component: HomeView, options: { title: translate('welcome') } }, Home: { component: HomeView, options: { title: translate('welcome'), headerLeft: null } },
Settings: { component: SetttingsNavigator, options: { title: 'Settings' } }, Settings: { component: SetttingsNavigator, options: { title: 'Settings' } },
Song: { component: SongLobbyView, options: { title: translate('play') } }, Song: { component: SongLobbyView, options: { title: translate('play') } },
Play: { component: PlayView, options: { title: translate('play') } }, Play: { component: PlayView, options: { title: translate('play') } },
Score: { component: ScoreView, options: { title: translate('score') } }, Score: { component: ScoreView, options: { title: translate('score'), headerLeft: null } },
Search: { component: SearchView, options: { title: translate('search') } }, Search: { component: SearchView, options: { title: translate('search') } },
User: { component: ProfileView, options: { title: translate('user') } }, User: { component: ProfileView, options: { title: translate('user') } },
}) as const; }) as const;
+5 -5
View File
@@ -50,6 +50,7 @@ const PlayView = ({ songId, type, route }: RouteProps<PlayViewProps>) => {
const [isVirtualPianoVisible, setVirtualPianoVisible] = useState<boolean>(false); const [isVirtualPianoVisible, setVirtualPianoVisible] = useState<boolean>(false);
const [time, setTime] = useState(0); const [time, setTime] = useState(0);
const [score, setScore] = useState(0); // Between 0 and 100 const [score, setScore] = useState(0); // Between 0 and 100
const [midiKeyboardFound, setMidiKeyboardFound] = useState<boolean>();
const partitionRessources = useQuery(["partition", songId], () => const partitionRessources = useQuery(["partition", songId], () =>
API.getPartitionRessources(songId) API.getPartitionRessources(songId)
); );
@@ -94,7 +95,7 @@ const PlayView = ({ songId, type, route }: RouteProps<PlayViewProps>) => {
toast.show({ description: 'No MIDI Keyboard found' }); toast.show({ description: 'No MIDI Keyboard found' });
return; return;
} }
toast.show({ description: `MIDI ready!`, placement: 'top' }); setMidiKeyboardFound(true);
let inputIndex = 0; let inputIndex = 0;
webSocket.current = new WebSocket(scoroBaseApiUrl); webSocket.current = new WebSocket(scoroBaseApiUrl);
webSocket.current.onopen = () => { webSocket.current.onopen = () => {
@@ -254,9 +255,7 @@ const PlayView = ({ songId, type, route }: RouteProps<PlayViewProps>) => {
<Text style={{ fontWeight: '700' }}>Rolling in the Deep</Text> <Text style={{ fontWeight: '700' }}>Rolling in the Deep</Text>
</Center> </Center>
<Row style={{ flex: 1, height: '100%', justifyContent: 'space-evenly', alignItems: 'center' }}> <Row style={{ flex: 1, height: '100%', justifyContent: 'space-evenly', alignItems: 'center' }}>
<IconButton size='sm' colorScheme='secondary' variant='solid' icon={ {midiKeyboardFound && <>
<Icon as={Ionicons} name={"play-back"}/>
}/>
<IconButton size='sm' variant='solid' icon={ <IconButton size='sm' variant='solid' icon={
<Icon as={Ionicons} name={paused ? "play" : "pause"}/> <Icon as={Ionicons} name={paused ? "play" : "pause"}/>
} onPress={() => { } onPress={() => {
@@ -273,12 +272,13 @@ const PlayView = ({ songId, type, route }: RouteProps<PlayViewProps>) => {
setVirtualPianoVisible(!isVirtualPianoVisible); setVirtualPianoVisible(!isVirtualPianoVisible);
}}/> }}/>
<Text>{Math.floor(time / 60000)}:{Math.floor((time % 60000) / 1000).toFixed(0).toString().padStart(2, '0')}</Text> <Text>{Math.floor(time / 60000)}:{Math.floor((time % 60000) / 1000).toFixed(0).toString().padStart(2, '0')}</Text>
<IconButton size='sm' colorScheme='coolGray' variant='solid' icon={ <IconButton size='sm' colorScheme='coolGray' variant='solid' opacity={time ?? 1} disabled={time == 0} icon={
<Icon as={Ionicons} name="stop"/> <Icon as={Ionicons} name="stop"/>
} onPress={() => { } onPress={() => {
onEnd(); onEnd();
navigation.navigate('Score', { songId: song.data.id }); navigation.navigate('Score', { songId: song.data.id });
}}/> }}/>
</>}
</Row> </Row>
</Row> </Row>
</Box> </Box>
+7 -4
View File
@@ -18,14 +18,17 @@ const ScoreView = ({ songId, route }: RouteProps<ScoreViewProps>) => {
() => API.getArtist(songQuery.data!.artistId!), () => API.getArtist(songQuery.data!.artistId!),
{ enabled: songQuery.data != undefined } { enabled: songQuery.data != undefined }
); );
const songScoreQuery = useQuery(["score", songId], () => API.getUserPlayHistory() const songHistoryQuery = useQuery(["song", "history"], () => API.getUserPlayHistory());
.then((history) => history.find((h) => h.songID == songId )!));
// const perfoamnceRecommandationsQuery = useQuery(['song', props.songId, 'score', 'latest', 'recommendations'], () => API.getLastSongPerformanceScore(props.songId)); // const perfoamnceRecommandationsQuery = useQuery(['song', props.songId, 'score', 'latest', 'recommendations'], () => API.getLastSongPerformanceScore(props.songId));
const recommendations = useQuery(['song', 'recommendations'], () => API.getUserRecommendations()); const recommendations = useQuery(['song', 'recommendations'], () => API.getUserRecommendations());
if (!recommendations.data || !songScoreQuery.data || !songQuery.data || (songQuery.data.artistId && !artistQuery.data)) { if (!recommendations.data || !songHistoryQuery.data || !songQuery.data || (songQuery.data.artistId && !artistQuery.data)) {
return <LoadingView/>; return <LoadingView/>;
} }
const songScore = songHistoryQuery.data.find((history) => history.songID == songId);
if (!songScore) {
return <Center><Translate translationKey="unknownError"/></Center>;
}
return <ScrollView p={8} contentContainerStyle={{ alignItems: 'center' }}> return <ScrollView p={8} contentContainerStyle={{ alignItems: 'center' }}>
<VStack width={{ base: '100%', lg: '50%' }} textAlign='center'> <VStack width={{ base: '100%', lg: '50%' }} textAlign='center'>
<Text bold fontSize='lg'>{songQuery.data.name}</Text> <Text bold fontSize='lg'>{songQuery.data.name}</Text>
@@ -54,7 +57,7 @@ const ScoreView = ({ songId, route }: RouteProps<ScoreViewProps>) => {
<Row style={{ alignItems: 'center' }}> <Row style={{ alignItems: 'center' }}>
<Translate translationKey='score' format={(t) => t + ' : '}/> <Translate translationKey='score' format={(t) => t + ' : '}/>
<Text bold fontSize='xl'> <Text bold fontSize='xl'>
{songScoreQuery.data.score + "pts"} {songScore.score + "pts"}
</Text> </Text>
</Row> </Row>
</Column> </Column>