import React, { useState } from 'react'; import { Text, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useDispatch } from 'react-redux'; import { acceptCall, cancelCall } from '../../../actions/videoConf'; import { ISubscription, SubscriptionType } from '../../../definitions'; import i18n from '../../../i18n'; import { useAppSelector } from '../../../lib/hooks'; import { useEndpointData } from '../../../lib/hooks/useEndpointData'; import { hideNotification } from '../../../lib/methods/helpers/notifications'; import { useTheme } from '../../../theme'; import { CustomIcon } from '../../CustomIcon'; import { CallHeader } from '../../CallHeader'; import { useStyle } from './style'; import useUserData from '../../../lib/hooks/useUserData'; import Ringer, { ERingerSounds } from '../../Ringer'; export interface INotifierComponent { notification: { text: string; payload: { sender: { username: string }; type: SubscriptionType; } & Pick; title: string; avatar: string; }; isMasterDetail: boolean; } const BUTTON_HIT_SLOP = { top: 12, right: 12, bottom: 12, left: 12 }; const IncomingCallHeader = React.memo( ({ uid, callId, avatar, roomName }: { callId: string; avatar: string; uid: string; roomName: string }) => { const [mic, setMic] = useState(true); const [cam, setCam] = useState(false); const [audio, setAudio] = useState(true); const dispatch = useDispatch(); const isMasterDetail = useAppSelector(state => state.app.isMasterDetail); const styles = useStyle(); const insets = useSafeAreaInsets(); const { colors } = useTheme(); return ( { setAudio(!audio); hideNotification(); }} style={styles.closeButton} > { setAudio(!audio); hideNotification(); dispatch(cancelCall({ callId })); }} style={styles.cancelButton} > {i18n.t('decline')} { setAudio(!audio); hideNotification(); dispatch(acceptCall({ callId })); }} style={styles.acceptButton} > {i18n.t('accept')} {audio ? : null} ); } ); const IncomingCallNotification = ({ notification: { rid, callId } }: { notification: { rid: string; callId: string }; }): React.ReactElement | null => { const { result } = useEndpointData('video-conference.info', { callId }); const user = useUserData(rid); if (result?.success && user.username) { return ; } return null; }; export default IncomingCallNotification;