From ac55a56e4afb58dceb8846f6493e3645165b71af Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 11 Dec 2023 01:46:06 +0100 Subject: [PATCH] Fix show next episode css on android --- front/packages/ui/src/details/episode.tsx | 6 +-- front/packages/ui/src/details/header.tsx | 33 +------------- front/packages/ui/src/details/show.tsx | 52 +++++++++++++++++++++-- 3 files changed, 54 insertions(+), 37 deletions(-) diff --git a/front/packages/ui/src/details/episode.tsx b/front/packages/ui/src/details/episode.tsx index b26c5b09..3c4b55f0 100644 --- a/front/packages/ui/src/details/episode.tsx +++ b/front/packages/ui/src/details/episode.tsx @@ -30,7 +30,7 @@ import { ts, } from "@kyoo/primitives"; import { useTranslation } from "react-i18next"; -import { ImageStyle, View } from "react-native"; +import { ImageStyle, PressableProps, View } from "react-native"; import { Layout, WithLoading } from "../fetch"; import { percent, rem, Stylable, Theme, useYoshiki } from "yoshiki/native"; import { KyooImage, WatchStatusV } from "@kyoo/models"; @@ -171,7 +171,7 @@ export const EpisodeLine = ({ watchedPercent: number | null; watchedStatus: WatchStatusV | null; }> & - Stylable) => { + Partial) => { const { css } = useYoshiki("episode-line"); const { t } = useTranslation(); @@ -189,7 +189,7 @@ export const EpisodeLine = ({ }, }, }, - props, + props as any, )} >

diff --git a/front/packages/ui/src/details/header.tsx b/front/packages/ui/src/details/header.tsx index 866dcd87..920fda21 100644 --- a/front/packages/ui/src/details/header.tsx +++ b/front/packages/ui/src/details/header.tsx @@ -74,6 +74,7 @@ import { EpisodeLine, displayRuntime, episodeDisplayNumber } from "./episode"; import { WatchListInfo } from "../components/watchlist-info"; import { ShowWatchStatus, WatchStatusV } from "@kyoo/models/src/resources/watch-status"; import { capitalize } from "@kyoo/primitives"; +import { ShowWatchStatusCard } from "./show"; export const TitleLine = ({ isLoading, @@ -472,37 +473,7 @@ export const Header = ({ /> ))} - {type === "show" && (data.watchStatus as ShowWatchStatus)?.nextEpisode && ( - - {({ css }) => ( - theme.background, - backgroundColor: (theme) => theme.background, - fover: { - self: { ...focusReset, borderColor: (theme: Theme) => theme.accent }, - }, - })} - > -

{t("show.nextUp")}

- - - )} - - )} + {type === "show" && } )} diff --git a/front/packages/ui/src/details/show.tsx b/front/packages/ui/src/details/show.tsx index dcc84ff3..55146fda 100644 --- a/front/packages/ui/src/details/show.tsx +++ b/front/packages/ui/src/details/show.tsx @@ -18,16 +18,18 @@ * along with Kyoo. If not, see . */ -import { QueryIdentifier, QueryPage, Show, ShowP } from "@kyoo/models"; +import { QueryIdentifier, QueryPage, Show, ShowP, ShowWatchStatus } from "@kyoo/models"; import { Platform, View, ViewProps } from "react-native"; import { percent, useYoshiki } from "yoshiki/native"; import { DefaultLayout } from "../layout"; import { EpisodeList, SeasonHeader } from "./season"; import { Header } from "./header"; import Svg, { Path, SvgProps } from "react-native-svg"; -import { Container } from "@kyoo/primitives"; -import { forwardRef } from "react"; +import { Container, H2, SwitchVariant, focusReset, ts } from "@kyoo/primitives"; +import { forwardRef, useState } from "react"; import { DetailsCollections } from "./collection"; +import { EpisodeLine, episodeDisplayNumber } from "./episode"; +import { useTranslation } from "react-i18next"; export const SvgWave = (props: SvgProps) => { const { css } = useYoshiki(); @@ -43,6 +45,50 @@ export const SvgWave = (props: SvgProps) => { ); }; +export const ShowWatchStatusCard = ({ watchedPercent, status, nextEpisode }: ShowWatchStatus) => { + const { t } = useTranslation(); + const [focused, setFocus] = useState(false); + + if (!nextEpisode) return null; + + return ( + + {({ css }) => ( + theme.background, + backgroundColor: (theme) => theme.background, + }, + focused && { + ...focusReset, + borderColor: (theme) => theme.accent, + }, + ])} + > +

{t("show.nextUp")}

+ setFocus(true)} + onHoverOut={() => setFocus(false)} + onFocus={() => setFocus(true)} + onBlur={() => setFocus(false)} + /> +
+ )} +
+ ); +}; + const ShowHeader = forwardRef(function ShowHeader( { children, slug, ...props }, ref,