Front: Home Page Header: Use Logo

This commit is contained in:
Arthur Jamet 2024-08-07 17:07:16 +02:00
parent ddc3e8f61a
commit deaeb770eb
No known key found for this signature in database
GPG Key ID: 93FEE429ECF5FF80
2 changed files with 40 additions and 9 deletions

View File

@ -25,9 +25,9 @@ import {
H2, H2,
IconButton, IconButton,
IconFab, IconFab,
ImageBackground,
Link, Link,
P, P,
Poster,
Skeleton, Skeleton,
tooltip, tooltip,
ts, ts,
@ -35,7 +35,7 @@ import {
import Info from "@material-symbols/svg-400/rounded/info.svg"; import Info from "@material-symbols/svg-400/rounded/info.svg";
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 { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { View } from "react-native"; import { Image, ImageProps, View } from "react-native";
import { percent, rem, useYoshiki } from "yoshiki/native"; import { percent, rem, useYoshiki } from "yoshiki/native";
import { Header as DetailsHeader } from "../details/header"; import { Header as DetailsHeader } from "../details/header";
import type { WithLoading } from "../fetch"; import type { WithLoading } from "../fetch";
@ -44,6 +44,7 @@ export const Header = ({
isLoading, isLoading,
name, name,
thumbnail, thumbnail,
logo,
overview, overview,
tagline, tagline,
link, link,
@ -52,6 +53,7 @@ export const Header = ({
}: WithLoading<{ }: WithLoading<{
name: string; name: string;
thumbnail: KyooImage | null; thumbnail: KyooImage | null;
logo: KyooImage | null;
overview: string | null; overview: string | null;
tagline: string | null; tagline: string | null;
link: string | null; link: string | null;
@ -59,6 +61,7 @@ export const Header = ({
}>) => { }>) => {
const { css } = useYoshiki(); const { css } = useYoshiki();
const { t } = useTranslation(); const { t } = useTranslation();
console.log(logo);
return ( return (
<GradientImageBackground <GradientImageBackground
@ -68,14 +71,37 @@ export const Header = ({
{...css(DetailsHeader.containerStyle, props)} {...css(DetailsHeader.containerStyle, props)}
> >
<View <View
{...css({ width: { md: percent(70) }, position: "absolute", bottom: 0, margin: ts(2) })} {...css({
width: { xs: percent(70), md: percent(70) },
position: "absolute",
bottom: 0,
margin: ts(2),
})}
> >
<Skeleton {...css({ width: rem(8), height: rem(2.5) })}> <Skeleton {...css({ width: rem(8), height: rem(2.5) })}>
{isLoading || ( {isLoading ||
(logo != null ? (
<View
{...css({
width: { xs: percent(100), md: percent(50), lg: percent(40) },
aspectRatio: 3,
})}
>
<Image
resizeMode="contain"
defaultSource={{ uri: logo.medium }}
source={{ uri: logo.medium }}
alt={name}
{...(css({
flex: 1,
}) as ImageProps)}
/>
</View>
) : (
<H1 numberOfLines={4} {...css({ fontSize: { xs: rem(2), sm: rem(3) } })}> <H1 numberOfLines={4} {...css({ fontSize: { xs: rem(2), sm: rem(3) } })}>
{name} {name}
</H1> </H1>
)} ))}
</Skeleton> </Skeleton>
<View {...css({ flexDirection: "row", alignItems: "center" })}> <View {...css({ flexDirection: "row", alignItems: "center" })}>
{link !== null && ( {link !== null && (
@ -97,7 +123,11 @@ export const Header = ({
{...css({ marginRight: ts(2) })} {...css({ marginRight: ts(2) })}
/> />
<Skeleton <Skeleton
{...css({ width: rem(25), height: rem(2), display: { xs: "none", sm: "flex" } })} {...css({
width: rem(25),
height: rem(2),
display: { xs: "none", sm: "flex" },
})}
> >
{isLoading || <H2 {...css({ display: { xs: "none", sm: "flex" } })}>{tagline}</H2>} {isLoading || <H2 {...css({ display: { xs: "none", sm: "flex" } })}>{tagline}</H2>}
</Skeleton> </Skeleton>

View File

@ -64,6 +64,7 @@ export const HomePage: QueryPage<{}, Genre> = ({ randomItems }) => {
tagline={"tagline" in x ? x.tagline : null} tagline={"tagline" in x ? x.tagline : null}
overview={x.overview} overview={x.overview}
thumbnail={x.thumbnail} thumbnail={x.thumbnail}
logo={x.logo}
link={x.kind !== "collection" && !x.isLoading ? x.playHref : undefined} link={x.kind !== "collection" && !x.isLoading ? x.playHref : undefined}
infoLink={x.href} infoLink={x.href}
/> />