This commit is contained in:
GitBluub
2024-01-18 01:07:23 +01:00
committed by Clément Le Bihan
parent 88cb7b2b65
commit 0bd12bbf34
2 changed files with 20 additions and 13 deletions

View File

@@ -2,7 +2,12 @@ import * as React from 'react';
import { Platform, View } from 'react-native'; import { Platform, View } from 'react-native';
import API from '../../API'; import API from '../../API';
import { useQuery } from '../../Queries'; import { useQuery } from '../../Queries';
import Animated, { useSharedValue, withTiming, Easing, useAnimatedStyle } from 'react-native-reanimated'; import Animated, {
useSharedValue,
withTiming,
Easing,
useAnimatedStyle,
} from 'react-native-reanimated';
import { CursorInfoItem } from '../../models/SongCursorInfos'; import { CursorInfoItem } from '../../models/SongCursorInfos';
import { Audio } from 'expo-av'; import { Audio } from 'expo-av';
import { SvgContainer } from './SvgContainer'; import { SvgContainer } from './SvgContainer';
@@ -214,7 +219,7 @@ const PartitionMagic = ({
const animatedStyle = useAnimatedStyle(() => ({ const animatedStyle = useAnimatedStyle(() => ({
left: `${partitionOffset.value * 100}%`, left: `${partitionOffset.value * 100}%`,
})) }));
return ( return (
<View <View
style={{ style={{
@@ -248,14 +253,17 @@ const PartitionMagic = ({
}} }}
> >
<Animated.View <Animated.View
style={[animatedStyle, { style={[
position: 'absolute', animatedStyle,
height: '100%', {
aspectRatio: partitionDims[0] / partitionDims[1], position: 'absolute',
display: 'flex', height: '100%',
alignItems: 'stretch', aspectRatio: partitionDims[0] / partitionDims[1],
justifyContent: 'flex-start', display: 'flex',
}]} alignItems: 'stretch',
justifyContent: 'flex-start',
},
]}
> >
<SvgContainer <SvgContainer
url={getSVGURL(songID)} url={getSVGURL(songID)}

View File

@@ -72,7 +72,7 @@ const PlayView = ({ songId }: PlayViewProps) => {
const [endResult, setEndResult] = useState<unknown>(); const [endResult, setEndResult] = useState<unknown>();
const [shouldPlay, setShouldPlay] = useState(false); const [shouldPlay, setShouldPlay] = useState(false);
const songHistory = useQuery(API.getSongHistory(songId)); const songHistory = useQuery(API.getSongHistory(songId));
const endCalled = useRef(false) const endCalled = useRef(false);
const [score, setScore] = useState(0); // Between 0 and 100 const [score, setScore] = useState(0); // Between 0 and 100
const getElapsedTime = () => stopwatch.getElapsedRunningTime() - 3000; const getElapsedTime = () => stopwatch.getElapsedRunningTime() - 3000;
const [readyToPlay, setReadyToPlay] = useState(false); const [readyToPlay, setReadyToPlay] = useState(false);
@@ -114,8 +114,7 @@ const PlayView = ({ songId }: PlayViewProps) => {
}; };
const onEnd = () => { const onEnd = () => {
if (endCalled.current == true) if (endCalled.current == true) return;
return;
endCalled.current = true; endCalled.current = true;
stopwatch.stop(); stopwatch.stop();
if (webSocket.current?.readyState != WebSocket.OPEN) { if (webSocket.current?.readyState != WebSocket.OPEN) {