Files
discord-decomp/modules/notification_center/native/ForYouItemImage.tsx
T
2026-11-01 12:12:55 +02:00

207 lines
8.1 KiB
TypeScript

// Metro module 15295 (f15296).
import * as Module19 from "react";
import { useMemo } from "react";
import { View } from "react-native";
import { getGuildAcronym } from "../../../records/GuildRecord";
import GuildStore from "../../../stores/GuildStore";
import UserStore from "../../../stores/UserStore";
import * as _Constants from "../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { ItemEnum, NotificationCenterItems } from "../NotificationCenterItemsTypes";
import Module12259 from "../../../_bundle/Module12259";
import Module15297 from "../../../_bundle/Module15297";
import Module15298 from "../../../_bundle/Module15298";
import Module15299 from "../../../_bundle/Module15299";
import Module15300 from "../../../_bundle/Module15300";
import FastImage from "../../../components_native/common/FastImage";
import Module15301 from "../../../_bundle/Module15301";
import { Avatar, AvatarSizes, Icon, IconSizes } from "../../../design/void/native";
import Module15302 from "../../../_bundle/Module15302";
import Module15303 from "../../../_bundle/Module15303";
import useAnalyticsLocations from "../../app_analytics/useAnalyticsLocations";
import { useStateFromStores } from "../../../_bundle/Module589";
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
import showUserProfileActionSheet from "../../user_profile/native/showUserProfileActionSheet";
import { getAvatarSource } from "../../profile_customization/native/ProfileCustomizationUtils";
import Module15304 from "../../../_bundle/Module15304";
import { Text } from "../../../design/components/Text/native/Text";
let useStyles2;
const { FRIEND_BACKGROUND, MESSAGE_BACKGROUND, PROFILE_BACKGROUND } = _Constants;
const useStyles = createStyles((a0) => {
const height = a0 ? 32 : 48;
const borderRadius = height / 2;
return {
container: {
height,
width: height,
borderRadius,
marginEnd: a0 ? 8 : 12,
alignItems: "center",
justifyContent: "center"
},
rowImage: {
height,
width: height,
borderRadius
},
guildFallbackImage: {
height: "auto",
maxHeight: borderRadius,
width: "auto",
color: Module712.colors.INTERACTIVE_TEXT_DEFAULT
}
};
});
useStyles2 = createStyles({
fallbackImage: {
color: Module712.colors.WHITE
},
fallbackImageV2: {
color: Module712.colors.INTERACTIVE_TEXT_DEFAULT
},
brandBackground: {
backgroundColor: Module712.colors.BACKGROUND_BRAND
},
profileBackground: {
backgroundColor: PROFILE_BACKGROUND
},
friendBackground: {
backgroundColor: FRIEND_BACKGROUND
},
messageBackground: {
backgroundColor: MESSAGE_BACKGROUND
},
guildGridBackground: {
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH
}
});
const r68 = Module19.memo(function({ item, compactMode }) {
let r45, r86, r161, brandBackground, profileBackground;
const styles = useStyles(compactMode);
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
const styles2 = useStyles2();
const id = item.other_user?.id;
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getUser(id));
const memo = useMemo(() => stateFromStores != null ? <PressableOpacity onPress={() => {
showUserProfileActionSheet({
userId: stateFromStores.id,
localUser: stateFromStores,
messageId: item.message_id,
sourceAnalyticsLocations: analyticsLocations
});
}}>
<Avatar source={getAvatarSource(stateFromStores, item.guild_id, void 0, item.acked)} size={compactMode ? AvatarSizes.REFRESH_MEDIUM_32 : AvatarSizes.LARGE_48} avatarDecoration={stateFromStores.avatarDecoration} />
</PressableOpacity> : null, [stateFromStores, compactMode, item.acked, item.guild_id, item.message_id, analyticsLocations]);
if (item.icon_name != null) {
r45 = <Icon source={item.icon_name === "icHighlight" ? Module15299 : Module15300} color={styles2.fallbackImage.color} />;
brandBackground = styles2.brandBackground;
} else if (item.icon_url != null) {
const r208 = memo != null;
brandBackground = null;
r45 = memo;
if (!r208) {
r45 = <FastImage style={styles.rowImage} source={{
uri: item.icon_url
}} resizeMode="contain" />;
brandBackground = styles2.brandBackground;
}
} else {
const r43 = memo != null;
brandBackground = null;
r45 = memo;
if (!r43) {
if (item.type === "lifecycle_item") {
L40: {
const item_enum = item.item_enum;
if (item_enum === ItemEnum.UPDATE_PROFILE) {
r161 = <FastImage source={Module15301} />;
} else {
if (item_enum !== ItemEnum.FIND_FRIENDS && item_enum !== ItemEnum.ADD_FRIEND) {
if (item_enum === ItemEnum.FIRST_MESSAGE) {
r161 = <FastImage source={Module15303} style={{
width: "105%"
}} />;
break L40;
}
r161 = <Icon source={Module15300} />;
break L40;
}
r161 = <Icon source={Module15302} size={IconSizes.SMALL_20} color={Module712.unsafe_rawColors.WHITE} />;
}
}
L50: {
const item_enum2 = item.item_enum;
if (item_enum2 === ItemEnum.UPDATE_PROFILE) {
profileBackground = styles2.profileBackground;
} else {
if (item_enum2 !== ItemEnum.FIND_FRIENDS && item_enum2 !== ItemEnum.ADD_FRIEND) {
if (item_enum2 === ItemEnum.FIRST_MESSAGE) {
profileBackground = styles2.messageBackground;
break L50;
}
profileBackground = styles2.brandBackground;
break L50;
}
profileBackground = styles2.friendBackground;
}
}
if (profileBackground == null) {
profileBackground = null;
}
brandBackground = profileBackground;
r45 = r161;
} else if (item.type === NotificationCenterItems.REFERRAL_PROGRAM_ENTRYPOINT_REMINDER) {
r45 = <FastImage source={Module15304} style={styles.rowImage} resizeMode="contain" />;
brandBackground = styles2.brandBackground;
} else {
const guild = GuildStore.getGuild(item.guild_id);
const r19 = guild != null ? getGuildAcronym(guild) : null;
L20: {
const type = item.type;
if (NotificationCenterItems.MISSED_MESSAGES === type) {
r86 = {
icon: Module12259,
color: styles2.fallbackImage.color
};
} else if (NotificationCenterItems.FRIEND_REQUEST_REMINDER === type) {
r86 = {
icon: Module15297,
color: styles2.fallbackImage.color
};
} else {
if (NotificationCenterItems.GUILD_SCHEDULED_EVENT_STARTED !== type && NotificationCenterItems.TOP_MESSAGES !== type && NotificationCenterItems.MISSED_MESSAGES !== type) {
if (NotificationCenterItems.TOP_MESSAGES === type) {
r86 = {
icon: Module15299,
color: styles2.fallbackImage.color
};
break L20;
}
r86 = {
icon: Module15300,
color: styles2.fallbackImage.color
};
break L20;
}
r86 = {
icon: Module15298,
color: styles2.fallbackImageV2.color,
backgroundStyle: styles2.guildGridBackground
};
}
}
const r119 = r86.icon === Module15298 && r19 != null ? <Text variant={r19.length > 4 ? "text-md/normal" : "text-lg/normal"} style={[styles.rowImage, styles.guildFallbackImage]}>{r19}</Text> : <Icon source={r86.icon} color={r86.color} />;
let backgroundStyle = r86.backgroundStyle;
if (backgroundStyle == null) {
backgroundStyle = styles2.brandBackground;
}
brandBackground = backgroundStyle;
r45 = r119;
}
}
}
return <View style={[styles.container, brandBackground]}>{r45}</View>;
});
export { r68 as ForYouItemImage };