Files
discord-decomp/modules/collectibles/nameplates/native/Nameplate.tsx
T
2026-11-01 12:12:55 +02:00

122 lines
4.2 KiB
TypeScript

// Metro module 8070 (f8071).
import { useEffect } from "react";
import AccessibilityStore from "../../../a11y/AccessibilityStore";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import { useStateFromStores } from "../../../../_bundle/Module589";
import useTheme from "../../../../hooks/useTheme";
import ReanimatedRexport, { useSharedValue, Easing, useAnimatedStyle } from "../../../reanimated/ReanimatedRexport";
import { withTiming } from "../../../../design/animation/reanimated/timing/timing";
import { getBackgroundGradientColors } from "../utils";
import { getNameplateAssets } from "./NameplateUtils";
import Module4611 from "../../../../_bundle/Module4611";
import { isAndroid } from "../../../../utils/PlatformUtils";
import { APNGPlayer } from "../../../image/native/APNGPlayer.android";
import FastImage from "../../../../components_native/common/FastImage";
import { HermesBuiltin } from "../../../../_hermes/prelude";
let useStyles, __initData;
const NameplateInner = function NameplateInner(props) {
const { nameplate, isPressed = false, isFocused = false, isMuted = false, fullOpacity = false, isSquarePreview = false, invertPressOpacity = false, fadeIn = false } = props;
let sharedValue;
let c16235_0 = fadeIn;
let animate = props.animate;
if (animate === void 0) {
animate = false;
}
const style = props.style;
sharedValue = void 0;
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
const styles = useStyles(fullOpacity, isPressed, isFocused, isMuted, invertPressOpacity);
const theme = useTheme();
sharedValue = useSharedValue(fadeIn ? 0 : 1);
useEffect(() => {
if (c16235_0) {
sharedValue.set(withTiming(1, {
duration: 100,
easing: Easing.in(Easing.ease)
}));
}
}, [sharedValue, fadeIn]);
const A = function A() {
return {
opacity: sharedValue.get()
};
};
A.__closure = {
opacity: sharedValue
};
A.__workletHash = 15588901070870;
A.__initData = __initData;
const animatedStyle = useAnimatedStyle(A);
const backgroundGradientColors = getBackgroundGradientColors(nameplate.palette, theme);
const nameplateAssets = getNameplateAssets(nameplate);
let staticImageUrl = nameplateAssets.staticImageUrl;
const animatedImageUrl = nameplateAssets.animatedImageUrl;
if (animate) {
animate = !stateFromStores;
}
if (animate) {
staticImageUrl = animatedImageUrl;
}
if (staticImageUrl == null) {
staticImageUrl = "";
}
return <ReanimatedRexport.View style={[styles.container, style, animatedStyle]}>
{backgroundGradientColors != null ? <Module4611 style={styles.gradient} start={{
x: isSquarePreview ? -2 : 0,
y: 0
}} end={{
x: 1,
y: 0
}} colors={[backgroundGradientColors.left, backgroundGradientColors.right]} /> : null}
{isAndroid() && animate ? <APNGPlayer url={staticImageUrl} style={styles.img} autoplay /> : <FastImage source={{
uri: staticImageUrl
}} style={styles.img} accessibilityRole="image" />}
</ReanimatedRexport.View>;
};
useStyles = createStyles((a0, a1, a2, a3, a4) => {
let opacity2 = 1;
const opacity = a0 ? 1 : a3 ? a2 ? a1 ? a4 ? 0.3 : 0.6 : a2 ? 0.8 : 0.4 : 0 : a1 ? a4 ? 0.3 : 0.6 : a2 ? 0.8 : 0.4;
if (!a0) {
opacity2 = a3 ? a2 ? a1 ? a4 ? 0.4 : 0.5 : a2 ? 0.8 : 0.6 : 0.1 : a1 ? a4 ? 0.4 : 0.5 : a2 ? 0.8 : 0.6;
}
return {
container: {
position: "absolute",
overflow: "hidden",
top: 0,
bottom: 0,
left: 0,
right: 0
},
gradient: {
position: "absolute",
width: "100%",
height: "100%",
opacity
},
img: {
position: "absolute",
height: "100%",
right: 0,
aspectRatio: 5.333333333333333,
opacity: opacity2
}
};
});
__initData = {
code: "function NameplateTsx1(){const{opacity}=this.__closure;return{opacity:opacity.get()};}"
};
export default function Nameplate(props) {
const nameplate = props.nameplate;
const r9 = {};
let r1 = null;
const props2 = HermesBuiltin.copyDataProperties(r9, props, {
__proto__: null,
nameplate: 0
});
if (nameplate != null) {
r1 = <NameplateInner nameplate={nameplate} {...props2} aria-hidden />;
}
return r1;
};