55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
// Metro module 7969 (f7970).
|
|
import { useMemo } from "react";
|
|
import { View } from "react-native";
|
|
import AccessibilityStore from "../../../a11y/AccessibilityStore";
|
|
import { useStateFromStores } from "../../../../_bundle/defaultAreStatesEqual";
|
|
import { getAvatarDecorationURL } from "../../../../utils/AvatarUtils";
|
|
import { isAndroid } from "../../../../utils/PlatformUtils";
|
|
import ClipView from "../../../../design/components/Icon/native/ClipView";
|
|
import Module6208 from "../../../../_bundle/Module6208";
|
|
import FastImage from "../../../../components_native/common/FastImage";
|
|
export default function CutoutableAvatarDecoration(props) {
|
|
const { size, avatarDecoration, decorationStyle, animate, cutout } = props;
|
|
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
|
|
const memo = useMemo(() => {
|
|
let canAnimate = animate;
|
|
if (animate) {
|
|
canAnimate = !stateFromStores;
|
|
}
|
|
if (canAnimate) {
|
|
canAnimate = avatarDecoration != null;
|
|
}
|
|
let uri = getAvatarDecorationURL({
|
|
avatarDecoration,
|
|
canAnimate,
|
|
size
|
|
});
|
|
if (uri == null) {
|
|
uri = "";
|
|
}
|
|
return {
|
|
avatarDecorationUrl: uri,
|
|
sizeStyle: {
|
|
width: size,
|
|
height: size
|
|
},
|
|
style: [{
|
|
width: size,
|
|
height: size
|
|
}, decorationStyle],
|
|
shouldAnimate: canAnimate,
|
|
source: {
|
|
uri
|
|
}
|
|
};
|
|
}, [animate, size, avatarDecoration, decorationStyle, stateFromStores]);
|
|
const { shouldAnimate, avatarDecorationUrl, style, sizeStyle, source } = memo;
|
|
return avatarDecoration == null ? null : avatarDecorationUrl == null ? null : isAndroid() && shouldAnimate ? cutout != null ? <ClipView style={style} cutouts={cutout.nativeCutouts}>
|
|
<Module6208 url={avatarDecorationUrl} style={sizeStyle} />
|
|
</ClipView> : <View style={style} pointerEvents="none">
|
|
<Module6208 url={avatarDecorationUrl} style={sizeStyle} />
|
|
</View> : cutout != null ? <ClipView style={style} cutouts={cutout.nativeCutouts}>
|
|
<FastImage source={source} style={sizeStyle} />
|
|
</ClipView> : <FastImage source={source} style={style} />;
|
|
};
|