fix: player controls touch events on iOS

This commit is contained in:
Adrian Castro
2024-02-13 12:10:56 +01:00
parent 6e33e0efea
commit e5dc36cd6d
2 changed files with 23 additions and 19 deletions

View File

@@ -9,15 +9,9 @@ interface ControlsProps extends React.ComponentProps<typeof TouchableOpacity> {
export const Controls = ({ children, className }: ControlsProps) => {
const idle = usePlayerStore((state) => state.interface.isIdle);
const setIsIdle = usePlayerStore((state) => state.setIsIdle);
return (
<TouchableOpacity
onPress={() => {
setIsIdle(false);
}}
className={className}
>
<TouchableOpacity className={className}>
{!idle && children}
</TouchableOpacity>
);

View File

@@ -1,11 +1,20 @@
import { View } from "react-native";
import { TouchableWithoutFeedback, View } from "react-native";
import { usePlayerStore } from "~/stores/player/store";
import { Controls } from "./Controls";
import { PlayButton } from "./PlayButton";
import { SeekButton } from "./SeekButton";
export const MiddleControls = () => {
const idle = usePlayerStore((state) => state.interface.isIdle);
const setIsIdle = usePlayerStore((state) => state.setIsIdle);
const handleTouch = () => {
setIsIdle(!idle);
};
return (
<TouchableWithoutFeedback onPress={handleTouch}>
<View className="absolute flex h-full w-full flex-1 flex-row items-center justify-center gap-24">
<Controls>
<SeekButton type="backward" />
@@ -17,5 +26,6 @@ export const MiddleControls = () => {
<SeekButton type="forward" />
</Controls>
</View>
</TouchableWithoutFeedback>
);
};