decord/beta/source/components_native/common/UnreadBars.tsx
2026-10-01 14:13:23 +00:00

233 lines
8 KiB
TypeScript

// Module ID: 15992
// Function ID: 15993
// Name: UnreadBars
// Dependencies: [19, 17, 4825, 1074, 21, 4836, 5836, 576, 4683, 4540, 4801, 4802, 1177, 1115, 504, 11916, 2]
// Exports: default
// Module 15992 (UnreadBars)
import get_initialized from "get initialized" /* 504 */;
import nativeDefault from "native" /* 576 */;
import Constants from "Constants" /* 1074 */;
import intl2 from "intl" /* 1115 */;
import native from "native" /* 1177 */;
import native2 from "native" /* 4540 */;
import HapticUtils from "HapticUtils" /* 4801 */;
import haptics_HapticFeedbackTypesDefault from "haptics/HapticFeedbackTypes" /* 4802 */;
import TransitionGroup2 from "TransitionGroup" /* 11916 */;
import react from "react" /* 19 */;
import react_native from "react-native" /* 17 */;
import AccessibilityStore from "AccessibilityStore" /* 4825 */;
import Fragment from "Fragment" /* 21 */;
import createStyles from "createStyles" /* 4836 */;
import TextStyles from "TextStyles" /* 5836 */;
import ColorUtils_mod from "ColorUtils" /* 4683 */;
import size from "module_2" /* 2 */;
let ColorUtils;
let c9;
let closure_4;
let hasOwnProperty;
let metroImportAll;
let metroRequire;
let obj2;
let obj3;
let obj4;
({ View: closure_4, Animated: hasOwnProperty, TouchableWithoutFeedback: metroRequire } = react_native);
const Fonts = Constants.Fonts;
({ jsx: metroImportAll, jsxs: c9 } = Fragment);
let obj = { unreadText: obj2, unread: obj3, mention: obj4 };
obj2 = {};
const createLegacyClassComponentStyles = createStyles.createLegacyClassComponentStyles;
const DISPLAY_SEMIBOLD = Fonts.DISPLAY_SEMIBOLD;
let merged = Object.assign(TextStyles(DISPLAY_SEMIBOLD, nativeDefault.unsafe_rawColors.WHITE, 12, { uppercase: true }));
obj3 = { margin: 8, height: 24, justifyContent: "center", alignItems: "center", borderRadius: nativeDefault.radii.md, backgroundColor: ColorUtils.hexWithOpacity(nativeDefault.unsafe_rawColors.PRIMARY_400, 0.9) };
ColorUtils = ColorUtils_mod;
obj4 = { backgroundColor: ColorUtils.hexWithOpacity(nativeDefault.unsafe_rawColors.RED_400, 0.9) };
ColorUtils = ColorUtils_mod;
const authStore = createLegacyClassComponentStyles(obj);
const PureComponent = react.PureComponent;
class UnreadBar extends PureComponent {
constructor() {
const applyArgumentsResult = HermesBuiltin.applyArguments(this, new.target);
require = applyArgumentsResult;
applyArgumentsResult.state = { active: false };
const value = new RN.Value(0);
applyArgumentsResult.animation = value;
applyArgumentsResult.handlePress = function handlePress() {
let item;
let onPress;
({ item, onPress } = require.props);
const obj = HapticUtils;
const result = obj.triggerHapticFeedback(haptics_HapticFeedbackTypesDefault.IMPACT_LIGHT);
require.hide();
onPress(item);
};
applyArgumentsResult.handlePressIn = function handlePressIn() {
require.setState({ active: true });
};
applyArgumentsResult.handlePressOut = function handlePressOut() {
require.setState({ active: false });
};
return applyArgumentsResult;
}
componentWillEnter(arg0) {
this.show(arg0);
}
componentWillLeave(arg0) {
this.hide(arg0);
}
show(arg0) {
const springResult = hasOwnProperty.spring(this.animation, { toValue: 1, friction: 15, tension: 250, useNativeDriver: true });
springResult.start(arg0);
}
hide(arg0) {
const springResult = hasOwnProperty.spring(this.animation, { toValue: 0, friction: 15, tension: 250, useNativeDriver: true });
springResult.start(arg0);
}
getAnimatedStyle() {
let bottom;
let contentInset;
let items;
let num2;
let num3;
let tmp2;
const self = this;
const props = this.props;
({ bottom, contentInset } = props);
let num = contentInset.left;
const useReducedMotion = props.useReducedMotion;
const active = this.state.active;
if (num == null) {
num = 0;
}
const rect = { position: "absolute", left: num, right: num2 };
num2 = contentInset.right;
if (num2 == null) {
num2 = 0;
}
let str = "top";
if (bottom) {
str = "bottom";
}
if (bottom) {
let num4 = contentInset.bottom;
if (num4 == null) {
num4 = 0;
}
num3 = num4;
} else {
num3 = contentInset.top;
if (num3 == null) {
num3 = 0;
}
}
rect[str] = num3;
const obj = { opacity: self.animation };
const merged = Object.assign(rect);
if (useReducedMotion) {
tmp2 = obj;
} else {
const animation = self.animation;
let num5 = -72;
const interpolate = animation.interpolate;
const obj2 = { inputRange: [0, 1], outputRange: items };
if (bottom) {
num5 = 72;
}
items = [num5, ];
let num6 = 0;
if (active) {
num6 = 1;
}
items[1] = num6;
const items1 = [{ translateY: interpolate(obj2) }];
obj.transform = items1;
tmp2 = obj;
const obj3 = { translateY: interpolate(obj2) };
}
return tmp2;
}
render() {
let LegacyText;
let View;
let mention;
let obj2;
let obj3;
let obj4;
let section;
let stringResult;
let tmp4;
const tmp = closure_10(this.context);
const props = this.props;
({ mention, section } = props.item);
const compact = props.compact;
const obj = { accessibilityRole: "button", onPress: this.handlePress, onPressIn: this.handlePressIn, onPressOut: this.handlePressOut, testID: "unread-bar-touchable-" + mention + "-" + section, children: metroImportAll(View, obj2) };
View = hasOwnProperty.View;
const items = [tmp.unread, ];
let mention1;
obj2 = { style: this.getAnimatedStyle(), nativeID: "unread-bar-animated-view-" + mention + "-" + section, children: metroImportAll(tmp4, obj3) };
const tmp3 = metroRequire;
tmp4 = React3;
if (mention) {
mention1 = tmp.mention;
}
items[1] = mention1;
obj3 = { style: items, nativeID: "unread-bar-view-" + mention + "-" + section, children: metroImportAll(LegacyText, obj4) };
obj4 = { style: tmp.unreadText, maxFontSizeMultiplier: 1.5, children: stringResult };
LegacyText = native.LegacyText;
const intl = intl2.intl;
const string = intl.string;
const t = intl2.t;
if (compact) {
stringResult = string(t.y2b7CA);
} else if (mention) {
stringResult = string(t["8zH0LJ"]);
} else {
stringResult = string(t.FCRiT3);
}
return metroImportAll(tmp3, obj);
}
}
const prototype = UnreadBar.prototype;
UnreadBar.defaultProps = { bottom: false };
UnreadBar.contextType = native2.ThemeContext;
let result = size.fileFinishedImporting("components_native/common/UnreadBars.tsx");
export default function UnreadBars(contentInset) {
let afterItem;
let beforeItem;
let compact;
let items1;
let useReducedMotion;
({ scrollToLocation: require, beforeItem, afterItem, compact } = contentInset);
if (compact === undefined) {
compact = false;
}
contentInset = contentInset.contentInset;
if (contentInset === undefined) {
contentInset = { top: 0, left: 0, right: 0, bottom: 0 };
}
function handlePress(section) {
const obj = { section: section.section, item: section.row, animated: true };
require(obj);
}
const items = [AccessibilityStore];
const obj2 = get_initialized;
const stateFromStores = obj2.useStateFromStores(items, () => useReducedMotion.useReducedMotion);
let obj = { component: react.Fragment, children: items1 };
let tmp3 = null;
const TransitionGroup = TransitionGroup2.TransitionGroup;
const tmp2 = closure_9;
if (null != beforeItem) {
const obj3 = { compact, item: beforeItem, onPress: handlePress, contentInset, useReducedMotion: stateFromStores };
tmp3 = closure_8(UnreadBar, obj3, "BEFORE");
}
items1 = [tmp3, ];
let tmp6 = null;
if (null != afterItem) {
const obj4 = { compact, item: afterItem, onPress: handlePress, contentInset, bottom: true, useReducedMotion: stateFromStores };
tmp6 = closure_8(UnreadBar, obj4, "AFTER");
}
items1[1] = tmp6;
return tmp2(TransitionGroup, obj);
};