import React from 'react';
import { Text, View } from 'react-native';
import { BorderlessButton } from 'react-native-gesture-handler';
import { CustomIcon, TIconsName } from '../../../containers/CustomIcon';
import { ISubscription, SubscriptionType } from '../../../definitions';
import i18n from '../../../i18n';
import { useVideoConf } from '../../../lib/hooks/useVideoConf';
import { useTheme } from '../../../theme';
import styles from '../styles';
function BaseButton({
danger,
iconName,
onPress,
label,
showIcon = true,
enabled = true
}: {
danger?: boolean;
iconName: TIconsName;
onPress?: (prop: any) => void;
label: string;
showIcon?: boolean;
enabled?: boolean;
}): React.ReactElement | null {
const { colors } = useTheme();
const color = danger ? colors.dangerColor : colors.actionTintColor;
if (showIcon)
return (
{label}
);
return null;
}
function CallButton({ rid, roomFromRid }: { rid: string; isDirect: boolean; roomFromRid: boolean }): React.ReactElement | null {
const { callEnabled, disabledTooltip, showInitCallActionSheet } = useVideoConf(rid);
return (
);
}
interface IRoomInfoButtons {
rid: string;
room: ISubscription | undefined;
roomUserId?: string;
isDirect: boolean;
fromRid?: string;
handleCreateDirectMessage: () => void;
handleIgnoreUser: () => void;
handleBlockUser: () => void;
roomFromRid: ISubscription | undefined;
}
export const RoomInfoButtons = ({
rid,
room: roomFromProps,
roomUserId,
isDirect,
fromRid,
handleCreateDirectMessage,
handleIgnoreUser,
handleBlockUser,
roomFromRid
}: IRoomInfoButtons): React.ReactElement => {
const room = roomFromRid || roomFromProps;
// Following the web behavior, when is a DM with myself, shouldn't appear block or ignore option
const isDmWithMyself = room?.uids?.filter((uid: string) => uid !== roomUserId).length === 0;
const isFromDm = room?.t === SubscriptionType.DIRECT;
const isDirectFromSaved = isDirect && fromRid && room;
const isIgnored = room?.ignored?.includes?.(roomUserId || '');
const isBlocked = room?.blocker;
const renderIgnoreUser = isDirectFromSaved && !isFromDm && !isDmWithMyself;
const renderBlockUser = isDirectFromSaved && isFromDm && !isDmWithMyself;
return (
);
};
export default RoomInfoButtons;