diff --git a/front/packages/primitives/src/image/index.tsx b/front/packages/primitives/src/image/index.tsx index 686645b9..40e9a3c3 100644 --- a/front/packages/primitives/src/image/index.tsx +++ b/front/packages/primitives/src/image/index.tsx @@ -27,7 +27,7 @@ import { ContrastArea } from "../themes"; import { percent } from "yoshiki/native"; import { imageBorderRadius } from "../constants"; -export { FastImage } from "./fast-image"; +export { Sprite } from "./sprite"; export { BlurhashContainer } from "./blurhash"; export { type Props as ImageProps, Image }; diff --git a/front/packages/primitives/src/image/fast-image.tsx b/front/packages/primitives/src/image/sprite.tsx similarity index 73% rename from front/packages/primitives/src/image/fast-image.tsx rename to front/packages/primitives/src/image/sprite.tsx index fa3b800a..047cd06e 100644 --- a/front/packages/primitives/src/image/fast-image.tsx +++ b/front/packages/primitives/src/image/sprite.tsx @@ -18,10 +18,9 @@ * along with Kyoo. If not, see . */ -import { View } from "react-native"; -import FImage from "react-native-fast-image"; +import { Image, View } from "react-native"; -export const FastImage = ({ +export const Sprite = ({ src, alt, width, @@ -45,21 +44,12 @@ export const FastImage = ({ }) => { return ( - diff --git a/front/packages/primitives/src/image/fast-image.web.tsx b/front/packages/primitives/src/image/sprite.web.tsx similarity index 85% rename from front/packages/primitives/src/image/fast-image.web.tsx rename to front/packages/primitives/src/image/sprite.web.tsx index 2c664a8b..2dfbd4e0 100644 --- a/front/packages/primitives/src/image/fast-image.web.tsx +++ b/front/packages/primitives/src/image/sprite.web.tsx @@ -20,7 +20,7 @@ import NextImage from "next/image"; -export const FastImage = ({ +export const Sprite = ({ src, alt, style, @@ -31,8 +31,8 @@ export const FastImage = ({ src: string; alt: string; style?: object; - width: number | string; - height: number | string; + width: number; + height: number; x: number; y: number; }) => { @@ -43,7 +43,13 @@ export const FastImage = ({ alt={alt!} // Don't use next's server to reprocess images, they are already optimized by kyoo. unoptimized={true} - style={{ objectFit: "none", objectPosition: `${-x}px ${-y}px`, ...style }} + style={{ + objectFit: "none", + objectPosition: `${-x}px ${-y}px`, + flexGrow: 0, + flexShrink: 0, + ...style, + }} {...props} /> ); diff --git a/front/packages/ui/src/player/components/scrubber.tsx b/front/packages/ui/src/player/components/scrubber.tsx index 3ed30d51..e2aee12c 100644 --- a/front/packages/ui/src/player/components/scrubber.tsx +++ b/front/packages/ui/src/player/components/scrubber.tsx @@ -19,11 +19,11 @@ */ import { useFetch, QueryIdentifier, imageFn, Chapter } from "@kyoo/models"; -import { FastImage, P, imageBorderRadius, ts } from "@kyoo/primitives"; -import { View } from "react-native"; -import { percent, useYoshiki, px, Theme } from "yoshiki/native"; +import { Sprite, P, imageBorderRadius, ts } from "@kyoo/primitives"; +import { View, Platform } from "react-native"; +import { percent, useYoshiki, px, Theme, useForceRerender } from "yoshiki/native"; import { ErrorView } from "../../fetch"; -import { useMemo } from "react"; +import { useMemo, useState } from "react"; import { useAtomValue } from "jotai"; import { durationAtom, progressAtom } from "../state"; import { toTimerString } from "./left-buttons"; @@ -128,7 +128,7 @@ export const ScrubberTooltip = ({ })} > {current && ( - ); }; +let scrubberWidth = 0; export const BottomScrubber = ({ url }: { url: string }) => { const { css } = useYoshiki(); const { info, error, stats } = useScrubber(url); + const rerender = useForceRerender(); const progress = useAtomValue(progressAtom); const duration = useAtomValue(durationAtom) ?? 1; @@ -159,30 +161,44 @@ export const BottomScrubber = ({ url }: { url: string }) => { return ( { + if (!e.nativeEvent.layout.width) return; + scrubberWidth = e.nativeEvent.layout.width; + rerender(); + }, + })} > - {info.map((thumb) => ( - - ))} + + {info.map((thumb) => ( + + ))} +