169 lines
6.4 KiB
TypeScript
169 lines
6.4 KiB
TypeScript
// Metro module 8285 (f8286).
|
|
import { View } from "react-native";
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import { RowType } from "../../ChannelPermissionsConstants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import { showConfirmModal } from "../../../../design/components/AlertModal/native/AlertModal.native";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import ChannelActionCreators from "../../../../actions/ChannelActionCreators";
|
|
import { memberOrRoleRemovedToast } from "../../../toast/native/ToastUtils";
|
|
import { PressableOpacity } from "../../../../design/void/Pressables/native/Pressables";
|
|
import { CircleXIcon } from "../../../../design/components/Icon/native/redesign/generated/CircleXIcon";
|
|
import { TableRow } from "../../../../design/components/TableRow/native/TableRow.native";
|
|
import { ShieldUserIcon } from "../../../../design/components/Icon/native/redesign/generated/ShieldUserIcon";
|
|
import { getRowTypeLabel } from "../../ChannelPermissionsUtils";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { Icon, Avatar, AvatarSizes, IconSizes } from "../../../../design/void/native";
|
|
import Module8287 from "../../../../_bundle/Module8287";
|
|
import Module8288 from "../../../../_bundle/Module8288";
|
|
import { useCheckboxA11yNative } from "../../../../_bundle/Module3907";
|
|
import { FormCheckbox } from "../../../../design/components/Forms/native/FormCheckbox.native";
|
|
let useStyles, RoleItem, MemberItem, EmptyRoleItem, ChannelOverwritesItem;
|
|
const RemoveIcon = function RemoveIcon(props) {
|
|
const { item, channelId, onRemove } = props;
|
|
const styles = useStyles();
|
|
return channelId != null ? <PressableOpacity disabled={item.disabled} accessibilityRole="button" accessibilityLabel={intl.string(t.N86XcP)} onPress={() => {
|
|
if (onRemove != null) {
|
|
return onRemove(item);
|
|
}
|
|
const { id: id2, name: name2 } = item;
|
|
const id = id2;
|
|
const name = name2;
|
|
const channelId2 = channelId;
|
|
showConfirmModal({
|
|
key: `remove-channel-overwrite-${id}`,
|
|
title: intl.string(t.GuPYQB),
|
|
content: intl.format(t.xERCnZ, {
|
|
name
|
|
}),
|
|
confirmText: intl.string(t.fKxYb0),
|
|
onConfirm: () => {
|
|
ChannelActionCreators.clearPermissionOverwrite(channelId2, id).then(() => {
|
|
memberOrRoleRemovedToast(name);
|
|
});
|
|
}
|
|
});
|
|
}}>
|
|
<CircleXIcon style={item.disabled ? styles.rowRemoveIconDisabled : void 0} />
|
|
</PressableOpacity> : null;
|
|
};
|
|
RoleItem = function RoleItem(props) {
|
|
const { disabled, item: item2 } = props;
|
|
let subLabel = props.subLabel;
|
|
const { channelId: channelId3, showType, showRemove, start, end } = props;
|
|
let trailing = props.trailing;
|
|
const { onPress: onPress2, accessibilityRole, accessibilityState, accessible } = props;
|
|
const props2 = {
|
|
icon: <ShieldUserIcon size="lg" color={item2.colorString} />,
|
|
label: item2.name,
|
|
subLabel: null,
|
|
start: null,
|
|
end: null,
|
|
trailing: null,
|
|
onPress: null,
|
|
disabled: null,
|
|
accessibilityRole: null,
|
|
accessibilityState: null,
|
|
accessible: null
|
|
};
|
|
if (showType) {
|
|
subLabel = getRowTypeLabel(item2.rowType);
|
|
}
|
|
props2.subLabel = subLabel;
|
|
props2.start = start;
|
|
props2.end = end;
|
|
if (showRemove) {
|
|
trailing = <RemoveIcon item={item2} channelId={channelId3} />;
|
|
}
|
|
props2.trailing = trailing;
|
|
props2.onPress = onPress2;
|
|
props2.disabled = disabled;
|
|
props2.accessibilityRole = accessibilityRole;
|
|
props2.accessibilityState = accessibilityState;
|
|
props2.accessible = accessible;
|
|
return <TableRow {...props2} />;
|
|
};
|
|
MemberItem = function MemberItem(props) {
|
|
const { item: item2, channelId: channelId3, showRemove, onRemove: onRemove2, guildId, start, end } = props;
|
|
let trailing = props.trailing;
|
|
const { onPress: onPress2, disabled, accessibilityRole, accessibilityState, accessible } = props;
|
|
const styles = useStyles();
|
|
const label = <View style={styles.nameWrapper}>
|
|
<Text style={[styles.name, styles.memberName]} lineClamp={1} variant="text-md/semibold" color="interactive-text-active">{item2.name}</Text>
|
|
{item2.rowType === RowType.OWNER ? <Icon size={Icon.Sizes.REFRESH_SMALL_16} source={Module8287} disableColor style={styles.ownerIcon} /> : null}
|
|
</View>;
|
|
const user = UserStore.getUser(item2.id);
|
|
const props2 = {
|
|
icon: <Avatar source={user == null ? void 0 : user.getAvatarSource(guildId)} size={AvatarSizes.SMALL} />,
|
|
label,
|
|
subLabel: item2.username,
|
|
start,
|
|
end,
|
|
trailing: null,
|
|
onPress: null,
|
|
disabled: null,
|
|
accessibilityRole: null,
|
|
accessibilityState: null,
|
|
accessible: null
|
|
};
|
|
if (showRemove) {
|
|
trailing = <RemoveIcon item={item2} channelId={channelId3} onRemove={onRemove2} />;
|
|
}
|
|
props2.trailing = trailing;
|
|
props2.onPress = onPress2;
|
|
props2.disabled = disabled;
|
|
props2.accessibilityRole = accessibilityRole;
|
|
props2.accessibilityState = accessibilityState;
|
|
props2.accessible = accessible;
|
|
return <TableRow {...props2} />;
|
|
};
|
|
EmptyRoleItem = function EmptyRoleItem(props) {
|
|
const item2 = props.item;
|
|
return <TableRow icon={<Icon source={Module8288} color={item2.colorString} size={IconSizes.MEDIUM} style={useStyles().roleIcon} />} label={item2.name} />;
|
|
};
|
|
ChannelOverwritesItem = function ChannelOverwritesItem(props) {
|
|
const { item: item2, ...props2 } = props;
|
|
const rowType = item2.rowType;
|
|
if (RowType.ADMINISTRATOR !== rowType && RowType.ROLE !== rowType) {
|
|
if (RowType.OWNER !== rowType && RowType.MEMBER !== rowType) {
|
|
if (RowType.EMPTY_STATE === rowType) {
|
|
return <EmptyRoleItem item={item2} {...props2} />;
|
|
}
|
|
return null;
|
|
}
|
|
return <MemberItem item={item2} {...props2} />;
|
|
}
|
|
return <RoleItem item={item2} {...props2} />;
|
|
};
|
|
useStyles = createStyles({
|
|
nameWrapper: {
|
|
flexDirection: "row",
|
|
alignItems: "flex-end",
|
|
marginRight: 16
|
|
},
|
|
name: {
|
|
paddingRight: 4
|
|
},
|
|
memberName: {
|
|
flexShrink: 1
|
|
},
|
|
ownerIcon: {
|
|
alignSelf: "center"
|
|
},
|
|
roleIcon: {
|
|
height: 30,
|
|
width: 30
|
|
},
|
|
rowRemoveIconDisabled: {
|
|
opacity: 0.3
|
|
}
|
|
});
|
|
export default ChannelOverwritesItem;
|
|
export function ChannelOverwritesCheckboxItem(props) {
|
|
const { checked, ...props2 } = props;
|
|
const checkboxA11yNative = useCheckboxA11yNative({
|
|
checked
|
|
});
|
|
return <ChannelOverwritesItem {...props2} accessible accessibilityRole={checkboxA11yNative.accessibilityRole} accessibilityState={checkboxA11yNative.accessibilityState} trailing={<FormCheckbox checked={checked} />} />;
|
|
}
|