@artsy/palette-mobile 17.31.0 → 17.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,29 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import FastImage from "@d11/react-native-fast-image";
3
- import { memo, useCallback } from "react";
4
- import { PixelRatio, View } from "react-native";
3
+ import { memo, useRef } from "react";
4
+ import { PixelRatio, View, Animated } from "react-native";
5
5
  import { Blurhash } from "react-native-blurhash";
6
- import Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming, } from "react-native-reanimated";
7
6
  import { createGeminiUrl } from "../../utils/createGeminiUrl";
8
7
  import { useColor } from "../../utils/hooks";
9
8
  import { useScreenDimensions } from "../../utils/hooks/useScreenDimensions";
10
9
  import { Flex } from "../Flex";
11
10
  import { Skeleton, SkeletonBox } from "../Skeleton";
12
11
  export const Image = memo(({ aspectRatio, width, height, performResize = true, src, style, resizeMode, geminiResizeMode, showLoadingState = false, blurhash, ...flexProps }) => {
13
- const loading = useSharedValue(true);
14
12
  const dimensions = useImageDimensions({ aspectRatio, width, height });
15
13
  const color = useColor();
16
- const animatedStyles = useAnimatedStyle(() => {
17
- return {
18
- opacity: withTiming(loading.get() ? 0 : 1, { duration: 200, easing: Easing.sin }),
19
- };
20
- }, []);
21
- const onAnimationEnd = useCallback(() => {
22
- "worklet";
23
- loading.set(() => false);
24
- // No need to get the js thread involved here
25
- // eslint-disable-next-line react-hooks/exhaustive-deps
26
- }, []);
14
+ const opacity = useRef(new Animated.Value(0)).current;
15
+ const onLoadEnd = () => {
16
+ Animated.timing(opacity, {
17
+ toValue: 1,
18
+ duration: 200,
19
+ useNativeDriver: true,
20
+ }).start();
21
+ };
27
22
  if (showLoadingState) {
28
23
  return (_jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }));
29
24
  }
@@ -36,16 +31,16 @@ export const Image = memo(({ aspectRatio, width, height, performResize = true, s
36
31
  resizeMode: geminiResizeMode,
37
32
  });
38
33
  }
39
- return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [_jsx(View, { style: [dimensions, { position: "absolute" }], children: _jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) }), _jsx(Animated.View, { style: animatedStyles, children: _jsx(FastImage, { style: [
40
- dimensions,
41
- style,
42
- // If we have a blurhash, we don't want to show a background color
43
- // That might flash before the image loads
44
- { backgroundColor: blurhash ? "transparent" : color("mono30") },
45
- ], resizeMode: resizeMode, onLoadEnd: onAnimationEnd, source: {
46
- priority: FastImage.priority.normal,
47
- uri,
48
- } }) })] }));
34
+ return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [_jsx(View, { style: [dimensions, { position: "absolute" }], children: _jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) }), _jsx(FastImage, { style: [
35
+ dimensions,
36
+ style,
37
+ // If we have a blurhash, we don't want to show a background color
38
+ // That might flash before the image loads
39
+ { backgroundColor: blurhash ? "transparent" : color("mono30") },
40
+ ], resizeMode: resizeMode, onLoadEnd: onLoadEnd, source: {
41
+ priority: FastImage.priority.normal,
42
+ uri,
43
+ } })] }));
49
44
  });
50
45
  const useImageDimensions = (props) => {
51
46
  const screenDimensions = useScreenDimensions();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "17.31.0",
3
+ "version": "17.32.0",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "RCT_METRO_PORT=8082 react-native run-android --port 8082 --terminal terminal",