141 lines
5.8 KiB
TypeScript
141 lines
5.8 KiB
TypeScript
// Metro module 10337 (f10338).
|
|
import { useMemo } from "react";
|
|
import { View } from "react-native";
|
|
import AccessibilityStore from "../../a11y/AccessibilityStore";
|
|
import RelationshipStore from "../../../stores/RelationshipStore";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import { computeChannelName } from "../../channel/useChannelName";
|
|
import { ChannelTypesSets, ChannelTypes } from "../../../_bundle/Module692";
|
|
import { ChatIcon } from "../../../design/components/Icon/native/redesign/generated/ChatIcon";
|
|
import { ThreadIcon } from "../../../design/components/Icon/native/redesign/generated/ThreadIcon";
|
|
import { getSimpleChannelIconComponent } from "../../../utils/native/ChannelUtils";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { XSmallIcon } from "../../../design/components/Icon/native/redesign/generated/XSmallIcon";
|
|
let androidRippleConfig, hitSlop, useStyles;
|
|
const LocationText = function LocationText(props) {
|
|
const { channel, parentChannel, author, location: location2 } = props;
|
|
let color2 = props.color;
|
|
const styles = useStyles();
|
|
if (color2 == null) {
|
|
color2 = "text-muted";
|
|
}
|
|
const color = color2;
|
|
return <View style={styles.secondaryTextContainer}>
|
|
{author != null && <Text variant="text-md/bold" color={color} maxFontSizeMultiplier={1.75} style={styles.separator}>·</Text>}
|
|
{useMemo(() => {
|
|
const Component = ChannelTypesSets.PRIVATE_CHANNEL.has(channel.type) ? void 0 : channel.type === ChannelTypes.PUBLIC_THREAD ? parentChannel != null && parentChannel.type === ChannelTypes.GUILD_FORUM ? ChatIcon : ThreadIcon : getSimpleChannelIconComponent(channel);
|
|
return Component != null ? <Component color={color} style={styles.icon} /> : null;
|
|
}, [channel, parentChannel, styles.icon, color])}
|
|
<Text variant="text-md/semibold" color={color} lineClamp={1} style={styles.secondaryText}>{location2}</Text>
|
|
</View>;
|
|
};
|
|
androidRippleConfig = Object.freeze({
|
|
radius: 12
|
|
});
|
|
hitSlop = Object.freeze({
|
|
top: 8,
|
|
right: 8,
|
|
bottom: 8,
|
|
left: 8
|
|
});
|
|
useStyles = createStyles({
|
|
container: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: Module712.space.PX_8
|
|
},
|
|
headerContent: {
|
|
flex: 1,
|
|
flexDirection: "row",
|
|
alignItems: "center"
|
|
},
|
|
primaryText: {
|
|
flexShrink: 1,
|
|
marginRight: 2
|
|
},
|
|
secondaryTextContainer: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: 2,
|
|
flex: 1,
|
|
overflow: "hidden"
|
|
},
|
|
separator: {
|
|
marginHorizontal: 2
|
|
},
|
|
icon: {
|
|
width: 16,
|
|
height: 16
|
|
},
|
|
secondaryText: {
|
|
flex: 1
|
|
}
|
|
});
|
|
export default function MessageNotificationHeader(props) {
|
|
let location2;
|
|
const { channel: channel2, parentChannel: parentChannel2, guild, author } = props;
|
|
let expanded = props.expanded;
|
|
const { onDismiss, locationTextColor } = props;
|
|
const styles2 = useStyles();
|
|
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.roleStyle);
|
|
const colorString = author?.colorString;
|
|
const color2 = stateFromStores === "username" ? colorString : void 0;
|
|
const r23 = color2 != null ? {
|
|
color: color2
|
|
} : void 0;
|
|
L24: {
|
|
const r10 = computeChannelName(channel2, UserStore, RelationshipStore);
|
|
const type = channel2.type;
|
|
const GROUP_DM = ChannelTypes.GROUP_DM;
|
|
location2 = r10;
|
|
if (GROUP_DM !== type) {
|
|
if (ChannelTypes.GUILD_FORUM !== type && ChannelTypes.GUILD_TEXT !== type && ChannelTypes.GUILD_ANNOUNCEMENT !== type) {
|
|
if (ChannelTypes.ANNOUNCEMENT_THREAD !== type && ChannelTypes.PUBLIC_THREAD !== type) {
|
|
const PRIVATE_THREAD = ChannelTypes.PRIVATE_THREAD;
|
|
location2 = null;
|
|
if (PRIVATE_THREAD !== type) {
|
|
break L24;
|
|
}
|
|
}
|
|
const r15 = parentChannel2 != null ? computeChannelName(parentChannel2, UserStore, RelationshipStore) : null;
|
|
location2 = r15 != null ? `${r10}, ${r15}` : guild != null ? `${r10}, ${guild.name}` : r10;
|
|
break L24;
|
|
}
|
|
location2 = guild != null ? `${r10}, ${guild.name}` : null;
|
|
}
|
|
}
|
|
const r112 = [<View style={styles2.headerContent}>
|
|
{author != null && <Text variant="text-md/semibold" color="mobile-text-heading-primary" lineClamp={1} style={[styles2.primaryText, r23]}>{author.nick}</Text>}
|
|
{location2 != null && <LocationText location={location2} channel={channel2} parentChannel={parentChannel2} author={author} color={locationTextColor} />}
|
|
</View>, ,];
|
|
if (expanded) {
|
|
expanded = onDismiss != null;
|
|
}
|
|
if (expanded) {
|
|
expanded = <PressableOpacity accessibilityRole="button" accessibilityLabel={intl.string(t.LnEgqX)} hitSlop={hitSlop} androidRippleConfig={androidRippleConfig} onPress={() => onDismiss("close_from_expanded")}>
|
|
<XSmallIcon color="icon-subtle" style={{
|
|
height: 20,
|
|
width: 20
|
|
}} />
|
|
</PressableOpacity>;
|
|
}
|
|
r112[1] = expanded;
|
|
return <View style={styles2.container}>{r112}</View>;
|
|
};
|
|
export function SimpleNotificationHeader(props) {
|
|
const { text, secondaryText, labelStyle } = props;
|
|
const styles2 = useStyles();
|
|
return <View style={styles2.container}>
|
|
<Text variant="text-md/semibold" color="mobile-text-heading-primary" lineClamp={1} style={[styles2.primaryText, labelStyle]}>{text}</Text>
|
|
{secondaryText != null && <View style={styles2.secondaryTextContainer}>
|
|
<Text variant="text-md/bold" color="text-muted" maxFontSizeMultiplier={1.75} style={styles2.separator}>·</Text>
|
|
<Text variant="text-md/semibold" color="text-muted" lineClamp={1} style={styles2.secondaryText}>{secondaryText}</Text>
|
|
</View>}
|
|
</View>;
|
|
}
|