import React, { useEffect, useState } from 'react'; import { Text, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import i18n from '../../../../i18n'; import { getSubscriptionByRoomId } from '../../../../lib/database/services/Subscription'; import { useAppSelector } from '../../../../lib/hooks'; import { getRoomAvatar, getUidDirectMessage } from '../../../../lib/methods/helpers'; import { useTheme } from '../../../../theme'; import { useActionSheet } from '../../../ActionSheet'; import AvatarContainer from '../../../Avatar'; import Button from '../../../Button'; import { CustomIcon } from '../../../CustomIcon'; import { BUTTON_HIT_SLOP } from '../../../message/utils'; import StatusContainer from '../../../Status'; import useStyle from './styles'; export default function StartACallActionSheet({ rid, initCall }: { rid: string; initCall: Function }): React.ReactElement { const style = useStyle(); const { colors } = useTheme(); const [user, setUser] = useState({ username: '', avatar: '', uid: '' }); const [mic, setMic] = useState(true); const [cam, setCam] = useState(false); const username = useAppSelector(state => state.login.user.username); const { hideActionSheet } = useActionSheet(); useEffect(() => { (async () => { const room = await getSubscriptionByRoomId(rid); const uid = (await getUidDirectMessage(room)) as string; const avt = getRoomAvatar(room); setUser({ uid, username: room?.name || '', avatar: avt }); })(); }, [rid]); const handleColor = (enabled: boolean) => (enabled ? colors.conferenceCallEnabledIcon : colors.conferenceCallDisabledIcon); return ( {i18n.t('Start_a_call')} setCam(!cam)} style={[style.iconCallContainer, cam && style.enabledBackground, { marginRight: 6 }]} hitSlop={BUTTON_HIT_SLOP} > setMic(!mic)} style={[style.iconCallContainer, mic && style.enabledBackground]} hitSlop={BUTTON_HIT_SLOP} > {user.username}