From b378f0533a4944ee693ce0d581c7b508157db5d1 Mon Sep 17 00:00:00 2001 From: TPN Date: Fri, 5 Jul 2024 11:04:20 +0000 Subject: [PATCH] Add a shortcut to subtitle settings in the bottomControls of player --- src/components/player/atoms/Captions.tsx | 28 ++++++++ src/components/player/atoms/Settings.tsx | 17 +++++ src/components/player/atoms/index.ts | 1 + .../player/atoms/settings/CaptionsView.tsx | 68 ++++++++++++++----- .../player/atoms/settings/Opensubtitles.tsx | 14 +++- src/pages/parts/player/PlayerPart.tsx | 12 +++- 6 files changed, 119 insertions(+), 21 deletions(-) create mode 100644 src/components/player/atoms/Captions.tsx diff --git a/src/components/player/atoms/Captions.tsx b/src/components/player/atoms/Captions.tsx new file mode 100644 index 00000000..89e419e0 --- /dev/null +++ b/src/components/player/atoms/Captions.tsx @@ -0,0 +1,28 @@ +import { useEffect } from "react"; + +import { Icons } from "@/components/Icon"; +import { OverlayAnchor } from "@/components/overlays/OverlayAnchor"; +import { VideoPlayerButton } from "@/components/player/internals/Button"; +import { useOverlayRouter } from "@/hooks/useOverlayRouter"; +import { usePlayerStore } from "@/stores/player/store"; + +export function Captions() { + const router = useOverlayRouter("settings"); + const setHasOpenOverlay = usePlayerStore((s) => s.setHasOpenOverlay); + + useEffect(() => { + setHasOpenOverlay(router.isRouterActive); + }, [setHasOpenOverlay, router.isRouterActive]); + + return ( + + { + router.open(); + router.navigate("/captionsOverlay"); + }} + icon={Icons.CAPTIONS} + /> + + ); +} diff --git a/src/components/player/atoms/Settings.tsx b/src/components/player/atoms/Settings.tsx index b3eb2a59..a4059f1e 100644 --- a/src/components/player/atoms/Settings.tsx +++ b/src/components/player/atoms/Settings.tsx @@ -54,6 +54,12 @@ function SettingsOverlay({ id }: { id: string }) { + + + + + {/* This is used by the captions shortcut in bottomControls of player */} + @@ -68,6 +74,17 @@ function SettingsOverlay({ id }: { id: string }) { + {/* This is used by the captions shortcut in bottomControls of player */} + + + + + diff --git a/src/components/player/atoms/index.ts b/src/components/player/atoms/index.ts index 3caf8154..6be88fd6 100644 --- a/src/components/player/atoms/index.ts +++ b/src/components/player/atoms/index.ts @@ -16,3 +16,4 @@ export * from "./VolumeChangedPopout"; export * from "./NextEpisodeButton"; export * from "./Chromecast"; export * from "./CastingNotification"; +export * from "./Captions"; diff --git a/src/components/player/atoms/settings/CaptionsView.tsx b/src/components/player/atoms/settings/CaptionsView.tsx index 709ad067..fd8b3ce8 100644 --- a/src/components/player/atoms/settings/CaptionsView.tsx +++ b/src/components/player/atoms/settings/CaptionsView.tsx @@ -120,7 +120,13 @@ function useSubtitleList(subs: CaptionListItem[], searchQuery: string) { }, [subs, searchQuery, unknownChoice]); } -export function CaptionsView({ id }: { id: string }) { +export function CaptionsView({ + id, + backLink, +}: { + id: string; + backLink?: true; +}) { const { t } = useTranslation(); const router = useOverlayRouter(id); const selectedCaptionId = usePlayerStore((s) => s.caption.selected?.id); @@ -213,20 +219,36 @@ export function CaptionsView({ id }: { id: string }) { - router.navigate("/")} - rightSide={ - - } - > - {t("player.menus.subtitles.title")} - + {backLink ? ( + router.navigate("/")} + rightSide={ + + } + > + {t("player.menus.subtitles.title")} + + ) : ( + router.navigate("/captions/settings")} + className="-mr-2 -my-1 px-2 p-[0.4em] rounded tabbable hover:bg-video-context-light hover:bg-opacity-10" + > + {t("player.menus.subtitles.customizeLabel")} + + } + > + {t("player.menus.subtitles.title")} + + )}