mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 15:30:34 -04:00
Fix show header colors and poster
This commit is contained in:
parent
1faf234255
commit
a9d4fb769d
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { View, ViewStyle } from "react-native";
|
import { View, ViewStyle } from "react-native";
|
||||||
import { Image } from "./image";
|
import { Image, ImageProps } from "./image";
|
||||||
import { useYoshiki, px, Stylable } from "yoshiki/native";
|
import { useYoshiki, px, Stylable } from "yoshiki/native";
|
||||||
import { Icon } from "./icons";
|
import { Icon } from "./icons";
|
||||||
import { P } from "./text";
|
import { P } from "./text";
|
||||||
@ -46,7 +46,8 @@ const stringToColor = (string: string) => {
|
|||||||
export const Avatar = forwardRef<
|
export const Avatar = forwardRef<
|
||||||
View,
|
View,
|
||||||
{
|
{
|
||||||
src?: string | null;
|
src?: ImageProps["src"];
|
||||||
|
quality?: ImageProps["quality"];
|
||||||
alt?: string;
|
alt?: string;
|
||||||
size?: YoshikiStyle<number>;
|
size?: YoshikiStyle<number>;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
@ -56,7 +57,18 @@ export const Avatar = forwardRef<
|
|||||||
as?: ComponentType<{ style?: ViewStyle } & RefAttributes<View>>;
|
as?: ComponentType<{ style?: ViewStyle } & RefAttributes<View>>;
|
||||||
} & Stylable
|
} & Stylable
|
||||||
>(function Avatar(
|
>(function Avatar(
|
||||||
{ src, alt, size = px(24), color, placeholder, isLoading = false, fill = false, as, ...props },
|
{
|
||||||
|
src,
|
||||||
|
quality = "low",
|
||||||
|
alt,
|
||||||
|
size = px(24),
|
||||||
|
color,
|
||||||
|
placeholder,
|
||||||
|
isLoading = false,
|
||||||
|
fill = false,
|
||||||
|
as,
|
||||||
|
...props
|
||||||
|
},
|
||||||
ref,
|
ref,
|
||||||
) {
|
) {
|
||||||
const { css, theme } = useYoshiki();
|
const { css, theme } = useYoshiki();
|
||||||
@ -87,7 +99,13 @@ export const Avatar = forwardRef<
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{src || isLoading ? (
|
{src || isLoading ? (
|
||||||
<Image src={src} alt={alt} layout={{ width: size, height: size }} />
|
<Image
|
||||||
|
src={src}
|
||||||
|
quality={quality}
|
||||||
|
isLoading={isLoading as any}
|
||||||
|
alt={alt}
|
||||||
|
layout={{ width: size, height: size }}
|
||||||
|
/>
|
||||||
) : placeholder ? (
|
) : placeholder ? (
|
||||||
<P
|
<P
|
||||||
{...css({
|
{...css({
|
||||||
|
@ -29,7 +29,7 @@ export type YoshikiEnhanced<Style> = Style extends any
|
|||||||
}
|
}
|
||||||
: never;
|
: never;
|
||||||
|
|
||||||
type WithLoading<T> = (T & { isLoading?: false }) | (Partial<T> & { isLoading: true });
|
type WithLoading<T> = (T & { isLoading?: boolean }) | (Partial<T> & { isLoading: true });
|
||||||
|
|
||||||
export type Props = WithLoading<{
|
export type Props = WithLoading<{
|
||||||
src?: KyooImage | null;
|
src?: KyooImage | null;
|
||||||
|
@ -59,6 +59,7 @@ export const Image = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quality ??= "high";
|
||||||
return (
|
return (
|
||||||
<View {...css([layout, border], props)}>
|
<View {...css([layout, border], props)}>
|
||||||
{state !== "finished" && (
|
{state !== "finished" && (
|
||||||
@ -69,7 +70,10 @@ export const Image = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<FastImage
|
<FastImage
|
||||||
source={{ uri: src[quality ?? "high"] }}
|
source={{
|
||||||
|
uri: src[quality],
|
||||||
|
priority: FastImage.priority[quality === "medium" ? "normal" : quality],
|
||||||
|
}}
|
||||||
accessibilityLabel={alt}
|
accessibilityLabel={alt}
|
||||||
onLoad={() => setState("finished")}
|
onLoad={() => setState("finished")}
|
||||||
onError={() => setState("errored")}
|
onError={() => setState("errored")}
|
||||||
|
@ -73,7 +73,6 @@ export const Image = ({
|
|||||||
// To reproduce view's behavior
|
// To reproduce view's behavior
|
||||||
position: "relative",
|
position: "relative",
|
||||||
boxSizing: "border-box",
|
boxSizing: "border-box",
|
||||||
borderStyle: "solid",
|
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
|
|
||||||
// Use a blurhash here to nicely fade the NextImage when it is loaded completly
|
// Use a blurhash here to nicely fade the NextImage when it is loaded completly
|
||||||
@ -82,17 +81,15 @@ export const Image = ({
|
|||||||
backgroundSize: "cover",
|
backgroundSize: "cover",
|
||||||
backgroundRepeat: "no-repeat",
|
backgroundRepeat: "no-repeat",
|
||||||
backgroundPosition: "50% 50%",
|
backgroundPosition: "50% 50%",
|
||||||
|
|
||||||
// Use the layout's size and display the rounded border
|
|
||||||
width: (layout as any).width,
|
|
||||||
height: (layout as any).height,
|
|
||||||
aspectRatio: (layout as any).aspectRatio,
|
|
||||||
}}
|
}}
|
||||||
|
{...wCss([layout as any, { ...border, borderRadius: "6px" }], {
|
||||||
// Gather classnames from props (to support parent's hover for example).
|
// Gather classnames from props (to support parent's hover for example).
|
||||||
{...wCss({ ...border, borderRadius: "6px" }, { className: extractClassNames(props) })}
|
className: extractClassNames(props),
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
<NextImage
|
<NextImage
|
||||||
src={src[quality ?? "high"]}
|
src={src[quality ?? "high"]}
|
||||||
|
priority={quality === "high"}
|
||||||
alt={alt!}
|
alt={alt!}
|
||||||
fill={true}
|
fill={true}
|
||||||
style={{
|
style={{
|
||||||
|
@ -26,7 +26,7 @@ import { LinearGradient, LinearGradientProps } from "expo-linear-gradient";
|
|||||||
import { ContrastArea, alpha } from "../themes";
|
import { ContrastArea, alpha } from "../themes";
|
||||||
import { percent } from "yoshiki/native";
|
import { percent } from "yoshiki/native";
|
||||||
|
|
||||||
export { Image };
|
export { type Props as ImageProps, Image };
|
||||||
|
|
||||||
export const Poster = ({
|
export const Poster = ({
|
||||||
alt,
|
alt,
|
||||||
|
@ -53,6 +53,7 @@ export const ItemGrid = ({
|
|||||||
poster: {
|
poster: {
|
||||||
borderColor: theme => theme.background,
|
borderColor: theme => theme.background,
|
||||||
borderWidth: px(4),
|
borderWidth: px(4),
|
||||||
|
borderStyle: "solid",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
fover: {
|
fover: {
|
||||||
|
@ -18,7 +18,15 @@
|
|||||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Movie, QueryIdentifier, Show, getDisplayDate, Genre, Studio, KyooImage } from "@kyoo/models";
|
import {
|
||||||
|
Movie,
|
||||||
|
QueryIdentifier,
|
||||||
|
Show,
|
||||||
|
getDisplayDate,
|
||||||
|
Genre,
|
||||||
|
Studio,
|
||||||
|
KyooImage,
|
||||||
|
} from "@kyoo/models";
|
||||||
import {
|
import {
|
||||||
Container,
|
Container,
|
||||||
H1,
|
H1,
|
||||||
@ -108,7 +116,7 @@ const TitleLine = ({
|
|||||||
width: { xs: percent(50), md: percent(25) },
|
width: { xs: percent(50), md: percent(25) },
|
||||||
}}
|
}}
|
||||||
{...css({
|
{...css({
|
||||||
maxWidth: { xs: px(175), sm: Platform.OS === "web" ? "unset" as any : 99999999 },
|
maxWidth: { xs: px(175), sm: Platform.OS === "web" ? ("unset" as any) : 99999999 },
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
@ -121,18 +129,38 @@ const TitleLine = ({
|
|||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<P {...css({
|
<P
|
||||||
|
{...css({
|
||||||
textAlign: { xs: "center", sm: "left" },
|
textAlign: { xs: "center", sm: "left" },
|
||||||
color: (theme: Theme) => ({ xs: theme.user.heading, md: theme.heading }),
|
})}
|
||||||
})}>
|
>
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="header"
|
variant="header"
|
||||||
{...css({ width: rem(15), height: rem(2.5), marginBottom: rem(1) })}
|
{...css({ width: rem(15), height: rem(2.5), marginBottom: rem(1) })}
|
||||||
>
|
>
|
||||||
{isLoading || (
|
{isLoading || (
|
||||||
<>
|
<>
|
||||||
<H1>{name}</H1>
|
<H1
|
||||||
{date && <P {...css({ fontSize: rem(2.5) })}> ({date})</P>}
|
{...css({
|
||||||
|
color: (theme: Theme) => ({ xs: theme.user.heading, md: theme.heading }),
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{name}
|
||||||
|
</H1>
|
||||||
|
{date && (
|
||||||
|
<P
|
||||||
|
{...css({
|
||||||
|
fontSize: rem(2.5),
|
||||||
|
color: (theme: Theme) => ({
|
||||||
|
xs: theme.user.paragraph,
|
||||||
|
md: theme.paragraph,
|
||||||
|
}),
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
({date})
|
||||||
|
</P>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
@ -267,25 +295,23 @@ const Description = ({
|
|||||||
))}
|
))}
|
||||||
</P>
|
</P>
|
||||||
|
|
||||||
<View {...css({
|
<View
|
||||||
|
{...css({
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
flexBasis: { sm: 0 },
|
flexBasis: { sm: 0 },
|
||||||
paddingTop: ts(4),
|
paddingTop: ts(4),
|
||||||
})}>
|
})}
|
||||||
<Skeleton lines={4} >
|
|
||||||
{isLoading || (
|
|
||||||
<P
|
|
||||||
{...css({ textAlign: "justify", })}
|
|
||||||
>
|
>
|
||||||
{overview ?? t("show.noOverview")}
|
<Skeleton lines={4}>
|
||||||
</P>
|
{isLoading || (
|
||||||
|
<P {...css({ textAlign: "justify" })}>{overview ?? t("show.noOverview")}</P>
|
||||||
)}
|
)}
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
<View {...css({ flexWrap: "wrap", flexDirection: "row", marginTop: ts(.5) })}>
|
<View {...css({ flexWrap: "wrap", flexDirection: "row", marginTop: ts(0.5) })}>
|
||||||
<P {...css({ marginRight: ts(.5) })}>{t("show.tags")}:</P>
|
<P {...css({ marginRight: ts(0.5) })}>{t("show.tags")}:</P>
|
||||||
{(isLoading ? [...Array<string>(3)] : tags!).map((tag, i) => (
|
{(isLoading ? [...Array<string>(3)] : tags!).map((tag, i) => (
|
||||||
<Chip key={tag ?? i} label={tag} size="small" {...css({ m: ts(.5) })} />
|
<Chip key={tag ?? i} label={tag} size="small" {...css({ m: ts(0.5) })} />
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user