Files
discord-decomp/sources/modules/soundboard/native/SoundButton.tsx
T
2026-07-27 16:20:00 +03:00

242 lines
17 KiB
TypeScript

/* Metro module 15423; source: modules/soundboard/native/SoundButton.tsx; dependencies: [31, 27, 1878, 15418, 33, 4017, 4501, 697, 477, 5278, 4577, 6739, 11508, 15424, 566, 15425, 6771, 6789, 6951, 3802, 7890, 7892, 3857, 10896, 1244, 15427, 4573, 6705, 2] */
function _fun118000(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#118000, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15620:6, offset: 0x024c7f82, size: 869 bytes, params: 8, frame: 28
var object3;
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const value = undefined;
const value2 = importAll(31) /* metro dependency 31 */;
const View = (require(27) /* metro dependency 27 */).View;
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
const SOUND_BUTTON_HEIGHT = (require(15418) /* metro dependency 15418: SoundboardStyleConstants */).SOUND_BUTTON_HEIGHT;
const value3 = require(33) /* metro dependency 33 */;
const env0_6 = value3.jsx;
const env0_7 = value3.jsxs;
const reanimatedRexport = importDefault(4017) /* metro dependency 4017: ReanimatedRexport */;
let createAnimatedComponent = reanimatedRexport.createAnimatedComponent;
const env0_8 = Reflect.apply(createAnimatedComponent, reanimatedRexport, [View]);
const env0_9 = {'damping': 10, 'stiffness': 300, 'mass': 1};
const createStylesModule = require(4501) /* metro dependency 4501: createStyles */;
const createStyles = createStylesModule.createStyles;
object3 = {};
const object4 = {'marginTop': 4, 'height': null, 'backgroundColor': null, 'display': 'flex',
'flexDirection': 'column', 'justifyContent': 'center', 'alignItems': 'center', 'borderRadius': null,
'borderWidth': 1};
object4.height = SOUND_BUTTON_HEIGHT;
const CARD_BACKGROUND_DEFAULT = (importDefault(697) /* metro dependency 697: native */).colors.CARD_BACKGROUND_DEFAULT;
object4.backgroundColor = CARD_BACKGROUND_DEFAULT;
object4.borderRadius = (importDefault(697) /* metro dependency 697: native */).radii.lg;
const BORDER_MUTED = (importDefault(697) /* metro dependency 697: native */).colors.BORDER_MUTED;
object4.borderColor = BORDER_MUTED;
const SHADOW_LOW = (importDefault(697) /* metro dependency 697: native */).shadows.SHADOW_LOW;
copyDataProperties(object4, SHADOW_LOW, undefined);
object3.button = object4;
const CARD_PRIMARY_PRESSED_BG = (importDefault(697) /* metro dependency 697: native */).colors.CARD_PRIMARY_PRESSED_BG;
object3.buttonPressed = {backgroundColor: CARD_PRIMARY_PRESSED_BG};
object3.buttonDisabled = {opacity: 0.5};
const object6 = {'borderStyle': 'solid', 'borderWidth': 2};
const STATUS_SPEAKING = (importDefault(697) /* metro dependency 697: native */).colors.STATUS_SPEAKING;
object6.borderColor = STATUS_SPEAKING;
const CARD_SECONDARY_BG = (importDefault(697) /* metro dependency 697: native */).colors.CARD_SECONDARY_BG;
object6.backgroundColor = CARD_SECONDARY_BG;
object3.buttonPlaying = object6;
const value6 = 24;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
object3.emoji = {'height': 24, 'width': 24, 'fontSize': null, 'lineHeight': 28,
fontSize: platformUtilsModule.isIOS() ? value6 : value};
const object8 = {'display': 'flex', 'alignItems': 'center', 'justifyContent': 'center', 'height': 40, 'width': 40,
'backgroundColor': null, 'backgroundSize': 32, 'borderRadius': null, 'marginBottom': 8};
const BACKGROUND_MOD_MUTED = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_MOD_MUTED;
object8.backgroundColor = BACKGROUND_MOD_MUTED;
object8.borderRadius = (importDefault(697) /* metro dependency 697: native */).radii.round;
object3.emojiWrapper = object8;
object3.text = {marginHorizontal: 8};
object3.textPlaying = {marginHorizontal: 6};
const object9 = {'position': 'absolute', 'top': null, 'end': null, 'width': 12, 'height': 12};
let PX_12 = (importDefault(697) /* metro dependency 697: native */).space.PX_12;
object9.top = PX_12;
PX_12 = (importDefault(697) /* metro dependency 697: native */).space.PX_12;
object9.end = PX_12;
const WHITE = (importDefault(697) /* metro dependency 697: native */).colors.WHITE;
object9.tintColor = WHITE;
object3.lock = object9;
const env0_10 = Reflect.apply(createStyles, createStylesModule, [object3]);
const value8 = reanimatedRexport;
createAnimatedComponent = value8.createAnimatedComponent;
const PressableOpacity = (require(5278) /* metro dependency 5278: Pressables */).PressableOpacity;
const env0_11 = Reflect.apply(createAnimatedComponent, value8, [PressableOpacity]);
object3 = {code: 'function SoundButtonTsx1(){const{animationConfig,withDelay,withSpring,interpolate,SPRING_CONFIG}=this.__closure;var _animationConfig$play,_animationConfig$pres,_animationConfig;const isNotPressed=animationConfig.sharedValues.pressed.get()===0;const isPlaying=animationConfig.sharedValues.playing.get()>0;const shouldDoPlayingAnimation=isNotPressed&&isPlaying;const playingAnimationScaleValue=withDelay((_animationConfig$play=animationConfig.playingAnimationDelay)!==null&&_animationConfig$play!==void 0?_animationConfig$play:0,withSpring(interpolate(animationConfig.sharedValues.playing.get(),[0,1],[1,animationConfig.scaleFactors.playing]),SPRING_CONFIG));const pressedAnimationScaleValue=withSpring(interpolate(animationConfig.sharedValues.pressed.get(),[0,1],[1,animationConfig.scaleFactors.pressed]),SPRING_CONFIG);const rotationScaleValue=interpolate(animationConfig.sharedValues.pressed.get(),[0,1],[0,(_animationConfig$pres=(_animationConfig=animationConfig)===null||_animationConfig===void 0?void 0:_animationConfig.pressedRotationDegrees)!==null&&_animationConfig$pres!==void 0?_animationConfig$pres:0]);return{transform:[{scale:shouldDoPlayingAnimation?playingAnimationScaleValue:pressedAnimationScaleValue},{rotate:rotationScaleValue+"deg"}]};}'};
const value9 = value2.memo(_fun118004);
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/soundboard/native/SoundButton.tsx');
exports.SoundButton = value9;
return value;
}
function useAnimation(a0) { // fn#118001, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15620:2620, offset: 0x024c82e7, size: 163 bytes, params: 2, frame: 18
const env0_0 = a0;
const reanimatedRexportModule = require(4017) /* metro dependency 4017: ReanimatedRexport */;
const useAnimatedStyle = reanimatedRexportModule.useAnimatedStyle;
const closure = useAnimationT;
const object2 = {animationConfig: a0};
object2.withDelay = reanimatedRexportModule.withDelay;
object2.withSpring = (require(4577) /* metro dependency 4577: spring */).withSpring;
object2.interpolate = reanimatedRexportModule.interpolate;
object2.SPRING_CONFIG = env0_9;
closure.__closure = object2;
closure.__workletHash = 13932429225740;
closure.__initData = env0_12;
return Reflect.apply(useAnimatedStyle, reanimatedRexportModule, [closure]);
}
function SoundButtonEmoji({sound, sharedValues}) { // fn#118003, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15620:3400, offset: 0x024c8590, size: 279 bytes, params: 2, frame: 21
const styles = useStyles();
const value2 = useAnimation({sharedValues: sharedValues, scaleFactors: {'pressed': 0.8, 'playing': 1.2}});
const value3 = useAnimation({sharedValues: sharedValues, scaleFactors: {'pressed': 0.7200000000000001,
'playing': 1.08}, playingAnimationDelay: 100, pressedRotationDegrees: -15});
const binding = env0_8;
return ((Component) => <Component style={[styles.emojiWrapper,
value2]}>{((Component) => <Component style={value3}>{((Component) => <Component fastImageStyle={styles.emoji} textEmojiStyle={styles.emoji} src={(importDefault(11508) /* metro dependency 11508: getSoundboardEmojiUrl */)(sound,
24)} name={sound.emojiName ?? ''} />)(importDefault(6739) /* metro dependency 6739: Emoji */)}</Component>)(binding)}</Component>)(binding);
}
function _fun118004({sound, channel, style, isSectionLocked}) { // fn#118004, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15620:3846, offset: 0x024c86a7, size: 867 bytes, params: 2, frame: 33
isSectionLocked = !(isSectionLocked === undefined) && isSectionLocked;
const soundboardHooksModule = require(15424) /* metro dependency 15424: SoundboardHooks */;
const useSoundButtonStyleConfig = soundboardHooksModule.useSoundButtonStyleConfig;
const buttonWidth = Reflect.apply(useSoundButtonStyleConfig, soundboardHooksModule, []).buttonWidth;
let r11 = sound.emojiId != null || sound.emojiName != null;
const styles = useStyles();
const currentUser = (require(566) /* metro dependency 566: flux */).useStateFromStores([UserStore], function() {
return UserStore.getCurrentUser();
});
const value5 = (importDefault(15425) /* metro dependency 15425: useSoundboardSoundPlayerNative */)(sound,
channel.id);
const playSoundboardSound = value5.playSoundboardSound;
const env0_3 = playSoundboardSound;
const isPlayingSound = value5.isPlayingSound;
const defaultImport2 = importDefault(6771) /* metro dependency 6771: useAnalyticsLocations */;
const SOUNDBOARD_BUTTON = (importDefault(6789) /* metro dependency 6789: AnalyticsLocation */).SOUNDBOARD_BUTTON;
const analyticsLocations = defaultImport2(SOUNDBOARD_BUTTON).analyticsLocations;
const canUseSoundboardSound2 = (require(6951) /* metro dependency 6951: SoundboardUtils */).canUseSoundboardSound(currentUser,
sound, channel);
const value6 = !canUseSoundboardSound2;
let binding = env0_3;
const value7 = binding.useCallback(_fun118006, [analyticsLocations, channel.guild_id, currentUser,
playSoundboardSound, sound, value6]);
const value8 = _fun118007(isPlayingSound);
const value9 = useAnimation({sharedValues: value8.sharedValues, scaleFactors: {'pressed': 0.95, 'playing': 1.05}});
const value11 = value8.sharedValues.pressed.get() > 0;
const value12 = binding.useCallback(_fun118011, [channel.id, sound]);
binding = env0_11;
const bindingProps = {style: [styles.button, {width: buttonWidth}, value11 ? styles.buttonPressed : null, value9,
isPlayingSound ? styles.buttonPlaying : null,
canUseSoundboardSound2 || isSectionLocked ? null : styles.buttonDisabled, style], accessibilityRole: 'button',
accessibilityLabel: sound.name, onPressIn: value8.handlers.pressIn, onPressOut: value8.handlers.pressOut,
onPress: value7, onLongPress: value12};
r11 = r11 && <SoundButtonEmoji sharedValues={value8.sharedValues} sound={sound} />;
const Text = (require(4573) /* metro dependency 4573: Text */).Text;
return (
<View>
{((Component) => <Component {...bindingProps}>{r11}<Text lineClamp={1} style={[styles.text,
isPlayingSound ? styles.textPlaying : null]} variant="text-sm/semibold">{sound.name}</Text></Component>)(binding)}
{(canUseSoundboardSound2 ? value6 : !isSectionLocked) && ((LockIcon) => <LockIcon style={styles.lock} />)((require(6705) /* metro dependency 6705: LockIcon */).LockIcon)}
</View>
);
}
function useAnimationT() { // fn#118002, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15620:2660, owner: useAnimation.t, offset: 0x024c838a, size: 518 bytes, params: 1, frame: 32
let binding = env0_0;
const value2 = binding.sharedValues.pressed.get();
const value3 = binding.sharedValues.playing.get();
const value4 = 0;
const value5 = value3 > value4;
const value7 = undefined;
const reanimatedRexportModule = require(4017) /* metro dependency 4017: ReanimatedRexport */;
const withDelay = reanimatedRexportModule.withDelay;
const r6 = binding.playingAnimationDelay ?? value4;
const springModule = require(4577) /* metro dependency 4577: spring */;
let withSpring = springModule.withSpring;
const moduleValue3 = reanimatedRexportModule;
let interpolate = moduleValue3.interpolate;
binding = env0_0;
const value9 = Reflect.apply(interpolate, moduleValue3, [binding.sharedValues.playing.get(), [0, 1], [1,
binding.scaleFactors.playing]]);
const binding2 = env1_9;
const value10 = Reflect.apply(withDelay, reanimatedRexportModule, [r6, Reflect.apply(withSpring, springModule,
[value9, binding2])]);
const moduleValue4 = springModule;
withSpring = moduleValue4.withSpring;
const moduleValue5 = reanimatedRexportModule;
const value12 = Reflect.apply(withSpring, moduleValue4,
[moduleValue5.interpolate(binding.sharedValues.pressed.get(), [0, 1], [1, binding.scaleFactors.pressed]),
binding2]);
const items2 = [{scale: value4 !== value2 ? value12 : value5 ? value10 : value12}];
const moduleValue6 = reanimatedRexportModule;
interpolate = moduleValue6.interpolate;
binding = env0_0;
items2[1] = {rotate: '' + Reflect.apply(interpolate, moduleValue6, [binding.sharedValues.pressed.get(), [0, 1], [0,
(binding == null ? value7 : env0_0.pressedRotationDegrees) ?? value4]]) + 'deg'};
return {transform: items2};
}
function _fun118006() { // fn#118006, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15620:4235, offset: 0x024c8a0a, size: 300 bytes, params: 1, frame: 17
var value2;
var defaultImport;
var open;
var object2;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
var value;
if (env0_5) {
value2 = environment.__proto__;
defaultImport = importDefault(3802) /* metro dependency 3802: PremiumUtils */;
if (defaultImport.canUseSoundboardEverywhere(currentUser)) {
if (!sound.available) {
value = importDefault(3857) /* metro dependency 3857: ToastActionCreators */;
open = value.open;
object2 = {key: 'DISABLED_SOUND_PRESSED', icon: importDefault(10896) /* metro dependency 10896 */};
object2.content = intl.string(t.MDOXJR);
object2.toastDurationMs = 3000;
Reflect.apply(open, value, [object2]);
}
} else if (sound.guildId === channel.guild_id) {
if (!sound.available) {
value = importDefault(3857) /* metro dependency 3857: ToastActionCreators */;
open = value.open;
object2 = {key: 'DISABLED_SOUND_PRESSED', icon: importDefault(10896) /* metro dependency 10896 */};
object2.content = intl.string(t.MDOXJR);
object2.toastDurationMs = 3000;
Reflect.apply(open, value, [object2]);
}
} else {
(importDefault(7890) /* metro dependency 7890: openPremiumUpsellActionSheet */)((require(7892) /* metro dependency 7892: EntitlementFeatureNames */).EntitlementFeatureNames.SOUNDBOARD_EVERYWHERE);
}
} else {
playSoundboardSound(analyticsLocations);
}
}
function _fun118007(a0) { // fn#118007, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15620:4545, offset: 0x024c8b36, size: 203 bytes, params: 2, frame: 19
var environment;
const env0_0 = a0;
let value = environment.__proto__;
const value2 = (require(4017) /* metro dependency 4017: ReanimatedRexport */).useSharedValue(0);
const value3 = (require(4017) /* metro dependency 4017: ReanimatedRexport */).useSharedValue(0);
const binding = env1_3;
value = binding.useCallback(_fun118008, [value2]);
const value4 = binding.useCallback(_fun118009, [value2]);
binding.useEffect(_fun118010, [a0, value3, value2]);
return {handlers: {pressIn: value, pressOut: value4}, sharedValues: {pressed: value2, playing: value3}};
}
function _fun118011() { // fn#118011, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15620:4944, offset: 0x024c8c22, size: 49 bytes, params: 1, frame: 13
const value = environment.__proto__;
(importDefault(15427) /* metro dependency 15427: openSoundboardSoundPreviewActionSheet */)(channel.id, sound);
}
function _fun118010() { // fn#118010, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15620:4705, offset: 0x024c8c01, size: 33 bytes, params: 1, frame: 12
const binding = env0_2;
binding.set(env0_0 ? 1 : 0);
}