mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-30 19:54:16 -04:00
Add rating and runtime to shows/movies pages
This commit is contained in:
parent
4bb7b4b6c4
commit
a33171ba87
@ -26,6 +26,7 @@ import { px, Theme, useYoshiki } from "yoshiki/native";
|
|||||||
import { PressableFeedback } from "./links";
|
import { PressableFeedback } from "./links";
|
||||||
import { alpha } from "./themes";
|
import { alpha } from "./themes";
|
||||||
import { Breakpoint, ts, useBreakpointValue } from "./utils";
|
import { Breakpoint, ts, useBreakpointValue } from "./utils";
|
||||||
|
import { P } from "./text";
|
||||||
|
|
||||||
declare module "react" {
|
declare module "react" {
|
||||||
function forwardRef<T, P = {}>(
|
function forwardRef<T, P = {}>(
|
||||||
@ -124,3 +125,8 @@ export const IconFab = <AsProps = PressableProps,>(
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const DottedSeparator = () => {
|
||||||
|
const { css } = useYoshiki();
|
||||||
|
return <P {...css({ mX: ts(1) })}>{String.fromCharCode(0x2022)}</P>;
|
||||||
|
};
|
||||||
|
@ -59,9 +59,6 @@ export const Skeleton = ({
|
|||||||
<View
|
<View
|
||||||
{...css(
|
{...css(
|
||||||
[
|
[
|
||||||
{
|
|
||||||
position: "relative",
|
|
||||||
},
|
|
||||||
lines === 1 && { overflow: "hidden", borderRadius: px(6) },
|
lines === 1 && { overflow: "hidden", borderRadius: px(6) },
|
||||||
(variant === "text" || variant === "header") &&
|
(variant === "text" || variant === "header") &&
|
||||||
lines === 1 && [
|
lines === 1 && [
|
||||||
|
37
front/packages/ui/src/components/rating.tsx
Normal file
37
front/packages/ui/src/components/rating.tsx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Kyoo - A portable and vast media library solution.
|
||||||
|
* Copyright (c) Kyoo.
|
||||||
|
*
|
||||||
|
* See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||||
|
*
|
||||||
|
* Kyoo is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Kyoo is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Icon, P, Skeleton, ts } from "@kyoo/primitives";
|
||||||
|
import { View } from "react-native";
|
||||||
|
import Star from "@material-symbols/svg-400/rounded/star-fill.svg";
|
||||||
|
import { rem, useYoshiki } from "yoshiki/native";
|
||||||
|
|
||||||
|
export const Rating = ({ rating }: { rating?: number }) => {
|
||||||
|
const { css } = useYoshiki();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View {...css({ flexDirection: "row", alignItems: "center" })}>
|
||||||
|
<Icon icon={Star} {...css({ marginRight: ts(0.5) })} />
|
||||||
|
<Skeleton {...css({ width: rem(2) })}>
|
||||||
|
{rating !== undefined && <P>{rating ? rating / 10 : "??"} / 10</P>}
|
||||||
|
</Skeleton>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
@ -39,6 +39,12 @@ export const episodeDisplayNumber = (
|
|||||||
return def;
|
return def;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const displayRuntime = (runtime: number) => {
|
||||||
|
if (runtime < 60)
|
||||||
|
return `${runtime}min`;
|
||||||
|
return `${Math.floor(runtime / 60)}h${runtime % 60}`;
|
||||||
|
}
|
||||||
|
|
||||||
export const EpisodeBox = ({
|
export const EpisodeBox = ({
|
||||||
name,
|
name,
|
||||||
overview,
|
overview,
|
||||||
@ -124,6 +130,7 @@ export const EpisodeLine = ({
|
|||||||
episodeNumber,
|
episodeNumber,
|
||||||
seasonNumber,
|
seasonNumber,
|
||||||
releaseDate,
|
releaseDate,
|
||||||
|
runtime,
|
||||||
...props
|
...props
|
||||||
}: WithLoading<{
|
}: WithLoading<{
|
||||||
slug: string;
|
slug: string;
|
||||||
@ -135,6 +142,7 @@ export const EpisodeLine = ({
|
|||||||
episodeNumber: number | null;
|
episodeNumber: number | null;
|
||||||
seasonNumber: number | null;
|
seasonNumber: number | null;
|
||||||
releaseDate: Date | null;
|
releaseDate: Date | null;
|
||||||
|
runtime: number | null;
|
||||||
id: number;
|
id: number;
|
||||||
}> &
|
}> &
|
||||||
Stylable) => {
|
Stylable) => {
|
||||||
@ -182,13 +190,23 @@ export const EpisodeLine = ({
|
|||||||
{...(css(["poster", { flexShrink: 0, m: ts(1) }]) as { style: ImageStyle })}
|
{...(css(["poster", { flexShrink: 0, m: ts(1) }]) as { style: ImageStyle })}
|
||||||
/>
|
/>
|
||||||
<View {...css({ flexGrow: 1, flexShrink: 1, m: ts(1) })}>
|
<View {...css({ flexGrow: 1, flexShrink: 1, m: ts(1) })}>
|
||||||
<Skeleton>
|
<View
|
||||||
{isLoading || (
|
{...css({
|
||||||
<H6 aria-level={undefined} {...css("title")}>
|
flexGrow: 1,
|
||||||
{name ?? t("show.episodeNoMetadata")}
|
flexShrink: 1,
|
||||||
</H6>
|
flexDirection: "row",
|
||||||
)}
|
justifyContent: "space-between",
|
||||||
</Skeleton>
|
})}
|
||||||
|
>
|
||||||
|
<Skeleton>
|
||||||
|
{isLoading || (
|
||||||
|
<H6 aria-level={undefined} {...css("title")}>
|
||||||
|
{name ?? t("show.episodeNoMetadata")}
|
||||||
|
</H6>
|
||||||
|
)}
|
||||||
|
</Skeleton>
|
||||||
|
{isLoading || (runtime && <Skeleton>{isLoading || <SubP>{displayRuntime(runtime)}</SubP>}</Skeleton>)}
|
||||||
|
</View>
|
||||||
<Skeleton>{isLoading || <P numberOfLines={3}>{overview}</P>}</Skeleton>
|
<Skeleton>{isLoading || <P numberOfLines={3}>{overview}</P>}</Skeleton>
|
||||||
</View>
|
</View>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -46,6 +46,7 @@ import {
|
|||||||
A,
|
A,
|
||||||
ts,
|
ts,
|
||||||
Chip,
|
Chip,
|
||||||
|
DottedSeparator,
|
||||||
} from "@kyoo/primitives";
|
} from "@kyoo/primitives";
|
||||||
import { Fragment } from "react";
|
import { Fragment } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@ -66,6 +67,8 @@ import {
|
|||||||
import { Fetch } from "../fetch";
|
import { Fetch } from "../fetch";
|
||||||
import PlayArrow from "@material-symbols/svg-400/rounded/play_arrow-fill.svg";
|
import PlayArrow from "@material-symbols/svg-400/rounded/play_arrow-fill.svg";
|
||||||
import Theaters from "@material-symbols/svg-400/rounded/theaters-fill.svg";
|
import Theaters from "@material-symbols/svg-400/rounded/theaters-fill.svg";
|
||||||
|
import { Rating } from "../components/rating";
|
||||||
|
import { displayRuntime } from "./episode";
|
||||||
|
|
||||||
const TitleLine = ({
|
const TitleLine = ({
|
||||||
isLoading,
|
isLoading,
|
||||||
@ -73,6 +76,8 @@ const TitleLine = ({
|
|||||||
name,
|
name,
|
||||||
tagline,
|
tagline,
|
||||||
date,
|
date,
|
||||||
|
rating,
|
||||||
|
runtime,
|
||||||
poster,
|
poster,
|
||||||
studio,
|
studio,
|
||||||
trailerUrl,
|
trailerUrl,
|
||||||
@ -84,6 +89,8 @@ const TitleLine = ({
|
|||||||
name?: string;
|
name?: string;
|
||||||
tagline?: string | null;
|
tagline?: string | null;
|
||||||
date?: string | null;
|
date?: string | null;
|
||||||
|
rating?: number;
|
||||||
|
runtime?: number | null;
|
||||||
poster?: KyooImage | null;
|
poster?: KyooImage | null;
|
||||||
studio?: Studio | null;
|
studio?: Studio | null;
|
||||||
trailerUrl?: string | null;
|
trailerUrl?: string | null;
|
||||||
@ -191,7 +198,7 @@ const TitleLine = ({
|
|||||||
)}
|
)}
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
)}
|
)}
|
||||||
<View {...css({ flexDirection: "row" })}>
|
<View {...css({ flexDirection: "row", alignItems: "center" })}>
|
||||||
{playHref !== null && (
|
{playHref !== null && (
|
||||||
<IconFab
|
<IconFab
|
||||||
icon={PlayArrow}
|
icon={PlayArrow}
|
||||||
@ -215,6 +222,14 @@ const TitleLine = ({
|
|||||||
{...tooltip(t("show.trailer"))}
|
{...tooltip(t("show.trailer"))}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
<DottedSeparator />
|
||||||
|
<Rating rating={rating} />
|
||||||
|
{runtime && (
|
||||||
|
<>
|
||||||
|
<DottedSeparator />
|
||||||
|
<P>{displayRuntime(runtime)}</P>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@ -372,6 +387,8 @@ export const Header = ({
|
|||||||
name={data?.name}
|
name={data?.name}
|
||||||
tagline={data?.tagline}
|
tagline={data?.tagline}
|
||||||
date={data ? getDisplayDate(data as any) : undefined}
|
date={data ? getDisplayDate(data as any) : undefined}
|
||||||
|
rating={data?.rating}
|
||||||
|
runtime={"runtime" in data ? data.runtime : null}
|
||||||
poster={data?.poster}
|
poster={data?.poster}
|
||||||
trailerUrl={data?.trailer}
|
trailerUrl={data?.trailer}
|
||||||
studio={data?.studio}
|
studio={data?.studio}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user