Implement middle controls

This commit is contained in:
Zoe Roux 2025-07-26 00:47:08 +02:00
parent 9cc8ee7490
commit 15f82661c3
No known key found for this signature in database
4 changed files with 99 additions and 29 deletions

View File

@ -11,10 +11,10 @@ import {
IconButton,
Link,
type Menu,
noTouch,
Poster,
tooltip,
ts,
useIsTouch,
} from "~/primitives";
import { FullscreenButton, PlayButton, VolumeSlider } from "./misc";
import { ProgressBar, ProgressText } from "./progress";
@ -102,6 +102,7 @@ const ControlButtons = ({
}) => {
const { css } = useYoshiki();
const { t } = useTranslation();
const isTouch = useIsTouch();
const spacing = css({ marginHorizontal: ts(1) });
const menuProps = {
@ -123,7 +124,8 @@ const ControlButtons = ({
)}
>
<View {...css({ flexDirection: "row" })}>
<View {...css({ flexDirection: "row" }, noTouch)}>
{isTouch && (
<View {...css({ flexDirection: "row" })}>
{previous && (
<IconButton
icon={SkipPrevious}
@ -147,6 +149,7 @@ const ControlButtons = ({
)}
{Platform.OS === "web" && <VolumeSlider player={player} />}
</View>
)}
<ProgressText player={player} {...spacing} />
</View>
<View {...css({ flexDirection: "row" })}>

View File

@ -3,8 +3,10 @@ import type { ViewProps } from "react-native";
import type { VideoPlayer } from "react-native-video";
import { useYoshiki } from "yoshiki/native";
import type { Chapter, KImage } from "~/models";
import { useIsTouch } from "~/primitives";
import { Back } from "./back";
import { BottomControls } from "./bottom-controls";
import { MiddleControls } from "./middle-controls";
import { TouchControls } from "./touch";
export const Controls = ({
@ -25,6 +27,7 @@ export const Controls = ({
next: string | null;
}) => {
const { css } = useYoshiki();
const isTouch = useIsTouch();
const [hover, setHover] = useState(false);
const [menuOpenned, setMenu] = useState(false);
@ -56,6 +59,9 @@ export const Controls = ({
hoverControls,
)}
/>
{isTouch && (
<MiddleControls player={player} previous={previous} next={next} />
)}
<BottomControls
player={player}
name={subTitle}
@ -66,7 +72,7 @@ export const Controls = ({
setMenu={setMenu}
{...css(
{
// Fixed is used because firefox android make the hover disapear under the navigation bar in absolute
// Fixed is used because firefox android make the hover disappear under the navigation bar in absolute
// position: Platform.OS === "web" ? ("fixed" as any) : "absolute",
position: "absolute",
bottom: 0,

View File

@ -0,0 +1,61 @@
import SkipNext from "@material-symbols/svg-400/rounded/skip_next-fill.svg";
import SkipPrevious from "@material-symbols/svg-400/rounded/skip_previous-fill.svg";
import { View } from "react-native";
import type { VideoPlayer } from "react-native-video";
import { useYoshiki } from "yoshiki/native";
import { IconButton, Link, ts } from "~/primitives";
import { PlayButton } from "./misc";
export const MiddleControls = ({
player,
previous,
next,
...props
}: {
player: VideoPlayer;
previous?: string | null;
next?: string | null;
}) => {
const { css } = useYoshiki();
const common = css({
backgroundColor: (theme) => theme.darkOverlay,
marginHorizontal: ts(3),
});
return (
<View
{...css(
{
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
},
props,
)}
>
<IconButton
icon={SkipPrevious}
as={Link}
href={previous}
replace
size={ts(4)}
{...css([!previous && { opacity: 0, pointerEvents: "none" }], common)}
/>
<PlayButton player={player} size={ts(8)} {...common} />
<IconButton
icon={SkipNext}
as={Link}
href={next}
replace
size={ts(4)}
{...css([!next && { opacity: 0, pointerEvents: "none" }], common)}
/>
</View>
);
};

View File

@ -10,8 +10,8 @@ import { useAtom, useAtomValue } from "jotai";
import { useTranslation } from "react-i18next";
import { Platform, View } from "react-native";
import { px, type Stylable, useYoshiki } from "yoshiki/native";
import { HoverTouch, hoverAtom } from "../controls";
import { playAtom } from "./state";
import { HoverTouch, hoverAtom } from ".";
import { playAtom } from "../old/state";
export const TouchControls = ({
previousSlug,