@artsy/palette-mobile 20.6.0 → 20.8.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.
package/dist/constants.d.ts
CHANGED
|
@@ -13,5 +13,3 @@ export declare const DEFAULT_ICON_SIZE: number;
|
|
|
13
13
|
*/
|
|
14
14
|
export declare let DEFAULT_ACTIVE_OPACITY: number;
|
|
15
15
|
export declare const setGlobalActiveOpacity: (opacity: number) => void;
|
|
16
|
-
export declare const isNewArchitectureEnabled: boolean;
|
|
17
|
-
export declare const DEFAULT_ANIMATION_DURATION = 200;
|
package/dist/constants.js
CHANGED
|
@@ -12,8 +12,3 @@ export let DEFAULT_ACTIVE_OPACITY = 0.8;
|
|
|
12
12
|
export const setGlobalActiveOpacity = (opacity) => {
|
|
13
13
|
DEFAULT_ACTIVE_OPACITY = opacity;
|
|
14
14
|
};
|
|
15
|
-
// Check if the global `nativeFabric` object exists.
|
|
16
|
-
// Its presence indicates that Fabric is running.
|
|
17
|
-
// nativeFabricUIManager is only available in the new architecture and isn't typed yet
|
|
18
|
-
export const isNewArchitectureEnabled = !!global?.nativeFabricUIManager;
|
|
19
|
-
export const DEFAULT_ANIMATION_DURATION = 200;
|
|
@@ -70,11 +70,14 @@ const styles = (fontScale) => StyleSheet.create({
|
|
|
70
70
|
});
|
|
71
71
|
// This component represents the √ mark in CSS. We are not using styled-system since it's easier to specify raw CSS
|
|
72
72
|
// properties with styled-component.
|
|
73
|
-
export const CheckMark = ({ size }) =>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
export const CheckMark = ({ size }) => {
|
|
74
|
+
const { color } = useTheme();
|
|
75
|
+
return (_jsx(Box, { style: {
|
|
76
|
+
transform: [{ rotate: "-45deg" }],
|
|
77
|
+
borderBottomWidth: 2,
|
|
78
|
+
borderLeftWidth: 2,
|
|
79
|
+
}, top: "-12%", width: size * 0.625, height: size * 0.3125, borderBottomColor: color("mono0"), borderLeftColor: color("mono0") }));
|
|
80
|
+
};
|
|
78
81
|
export const DisabledMark = styled(CheckMark) `
|
|
79
82
|
border-bottom-color: ${themeGet("colors.mono30")};
|
|
80
83
|
border-left-color: ${themeGet("colors.mono30")};
|
|
@@ -1,32 +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
3
|
import { memo, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { View } from "react-native";
|
|
5
5
|
import { Blurhash } from "react-native-blurhash";
|
|
6
6
|
import { getImageURL } from "./helpers/getImageURL";
|
|
7
|
-
import { DEFAULT_ANIMATION_DURATION, isNewArchitectureEnabled } from "../../constants";
|
|
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 [isLoading, setIsLoading] = useState(
|
|
12
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
14
13
|
const dimensions = useImageDimensions({ aspectRatio, width, height });
|
|
15
|
-
const opacity = useAnimatedValue(1);
|
|
16
14
|
const color = useColor();
|
|
17
15
|
const onLoadEnd = () => {
|
|
18
|
-
|
|
19
|
-
toValue: 0,
|
|
20
|
-
duration: DEFAULT_ANIMATION_DURATION,
|
|
21
|
-
useNativeDriver: true,
|
|
22
|
-
}).start(() => {
|
|
23
|
-
setIsLoading(false);
|
|
24
|
-
});
|
|
16
|
+
setIsLoading(false);
|
|
25
17
|
};
|
|
26
18
|
if (showLoadingState) {
|
|
27
19
|
return (_jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }));
|
|
28
20
|
}
|
|
29
|
-
return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [_jsx(FastImage, { style: [
|
|
21
|
+
return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [isLoading && (_jsx(View, { style: [dimensions, { position: "absolute" }], children: _jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) })), _jsx(FastImage, { style: [
|
|
30
22
|
dimensions,
|
|
31
23
|
style,
|
|
32
24
|
// If we have a blurhash, we don't want to show a background color
|
|
@@ -35,12 +27,7 @@ export const Image = memo(({ aspectRatio, width, height, performResize = true, s
|
|
|
35
27
|
], resizeMode: resizeMode, onLoadEnd: onLoadEnd, source: {
|
|
36
28
|
priority: FastImage.priority.normal,
|
|
37
29
|
uri: getImageURL({ src, dimensions, geminiResizeMode, performResize }),
|
|
38
|
-
} })
|
|
39
|
-
dimensions,
|
|
40
|
-
// We are disabling the opacity animation in the new architecture because it is still slow
|
|
41
|
-
// We will bring this back once we are on RN81+ aka a version with this fix
|
|
42
|
-
{ position: "absolute", opacity: isNewArchitectureEnabled ? 0 : opacity },
|
|
43
|
-
], children: _jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) }))] }));
|
|
30
|
+
} })] }));
|
|
44
31
|
});
|
|
45
32
|
const useImageDimensions = (props) => {
|
|
46
33
|
const screenDimensions = useScreenDimensions();
|
|
@@ -64,7 +51,7 @@ const useImageDimensions = (props) => {
|
|
|
64
51
|
};
|
|
65
52
|
export const ImageSkeleton = ({ dimensions, blurhash, style }) => {
|
|
66
53
|
if (!!blurhash) {
|
|
67
|
-
return (_jsx(Flex, { ...dimensions, style: style, children: _jsx(Blurhash, { blurhash: blurhash, style: { flex: 1 }, decodeWidth: 16, decodeHeight: 16, decodeAsync: true }) }));
|
|
54
|
+
return (_jsx(Flex, { backgroundColor: "mono10", ...dimensions, style: style, children: _jsx(Blurhash, { blurhash: blurhash, style: { flex: 1 }, decodeWidth: 16, decodeHeight: 16, decodeAsync: true }) }));
|
|
68
55
|
}
|
|
69
56
|
return (_jsx(Flex, { style: style, children: _jsx(Skeleton, { children: _jsx(SkeletonBox, { ...dimensions }) }) }));
|
|
70
57
|
};
|