104 lines
4.1 KiB
TypeScript
104 lines
4.1 KiB
TypeScript
// Metro module 12241 (f12242).
|
|
import { useEffect } from "react";
|
|
import { View } from "react-native";
|
|
import GuildStore from "../../../../stores/GuildStore";
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import { InstantInviteSources, RelationshipTypes } from "../../../../Constants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import GuildIcon, { GuildIconSizes } from "../../../guild/native/GuildIcon";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import Dispatcher from "../../../../Dispatcher";
|
|
import * as _ToastUtils from "../../../toast/native/ToastUtils";
|
|
import { ActionSheet } from "../../../../design/components/Sheet/native/ActionSheet.native";
|
|
import { BottomSheetTitleHeader } from "../../../../design/components/Sheet/native/BottomSheetTitleHeader.native";
|
|
import QRCode from "../../../../components_native/QRCode";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
const useStyles = createStyles({
|
|
container: {
|
|
padding: Module712.space.PX_12,
|
|
display: "flex",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
gap: Module712.space.PX_24
|
|
},
|
|
iconContainer: {
|
|
position: "absolute",
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
justifyContent: "center",
|
|
alignItems: "center"
|
|
},
|
|
icon: {
|
|
padding: Module712.space.PX_4,
|
|
borderRadius: Module712.radii.lg + Module712.space.PX_4,
|
|
backgroundColor: Module712.colors.WHITE
|
|
},
|
|
code: {
|
|
alignSelf: "center"
|
|
}
|
|
});
|
|
export default function InstantInviteQRCodeActionSheet(props) {
|
|
let r51;
|
|
const link = props.link;
|
|
const styles = useStyles();
|
|
const title = props.location === InstantInviteSources.ADD_FRIENDS_MODAL ? intl.string(t.VUNqoc) : intl.string(t.DqE26p);
|
|
const { location: location2, channel } = props;
|
|
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
|
|
if (channel != null) {
|
|
const guild = GuildStore.getGuild(channel.guild_id);
|
|
r51 = guild != null ? {
|
|
visible: intl.format(t.VK3zyF, {
|
|
name: guild.name
|
|
}),
|
|
plainText: intl.formatToPlainString(t.VK3zyF, {
|
|
name: guild.name
|
|
})
|
|
} : location2 === InstantInviteSources.ADD_FRIENDS_MODAL ? stateFromStores != null ? {
|
|
visible: intl.format(t.zDGAfl, {
|
|
name: stateFromStores.username
|
|
}),
|
|
plainText: intl.formatToPlainString(t.zDGAfl, {
|
|
name: stateFromStores.username
|
|
})
|
|
} : null : null;
|
|
} else {
|
|
r51 = location2 === InstantInviteSources.ADD_FRIENDS_MODAL ? stateFromStores != null ? {
|
|
visible: intl.format(t.zDGAfl, {
|
|
name: stateFromStores.username
|
|
}),
|
|
plainText: intl.formatToPlainString(t.zDGAfl, {
|
|
name: stateFromStores.username
|
|
})
|
|
} : null : null;
|
|
}
|
|
const channel2 = props.channel;
|
|
const r99 = channel2 != null ? GuildStore.getGuild(channel2.guild_id) != null ? <GuildIcon guild={GuildStore.getGuild(channel2.guild_id)} size={GuildIconSizes.LARGE} /> : null : null;
|
|
const presentFriendRequestAcceptedToast = _ToastUtils.presentFriendRequestAcceptedToast;
|
|
useEffect(() => {
|
|
const handleRelationshipAdd2 = function handleRelationshipAdd({ relationship }) {
|
|
if (relationship.type === RelationshipTypes.FRIEND) {
|
|
presentFriendRequestAcceptedToast(relationship.user);
|
|
}
|
|
};
|
|
Dispatcher.subscribe("RELATIONSHIP_ADD", handleRelationshipAdd2);
|
|
return () => {
|
|
Dispatcher.unsubscribe("RELATIONSHIP_ADD", handleRelationshipAdd2);
|
|
};
|
|
}, [presentFriendRequestAcceptedToast]);
|
|
return <ActionSheet header={<BottomSheetTitleHeader title={title} />}>
|
|
<View style={styles.container}>
|
|
<View>
|
|
<QRCode text={link} size={240} style={styles.code} accessibilityLabel={r51?.plainText} />
|
|
{r99 != null && <View style={styles.iconContainer}>
|
|
<View style={styles.icon}>{r99}</View>
|
|
</View>}
|
|
</View>
|
|
{r51 != null && <Text variant="text-md/normal">{r51.visible}</Text>}
|
|
</View>
|
|
</ActionSheet>;
|
|
};
|