/* * Wire * Copyright (C) 2021 Wire Swiss GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * */ import React from 'react'; import {QualifiedId} from '@wireapp/api-client/lib/user'; import {TabIndex} from '@wireapp/react-ui-kit/lib/types/enums'; import {VIDEO_STATE} from '@wireapp/avs'; import {Avatar, AVATAR_SIZE} from 'Components/Avatar'; import * as Icon from 'Components/Icon'; import {useKoSubscribableChildren} from 'Util/ComponentUtil'; import {isEnterKey} from 'Util/KeyboardUtil'; import {t} from 'Util/LocalizerUtil'; import {Video} from './Video'; import type {Participant} from '../../calling/Participant'; export interface GroupVideoGridTileProps { isMaximized: boolean; minimized: boolean; onTileDoubleClick: (userId: QualifiedId, clientId: string) => void; participant: Participant; participantCount: number; selfParticipant: Participant; } const getParticipantNameColor = ({ isActivelySpeaking, isAudioEstablished, }: { isActivelySpeaking: boolean; isAudioEstablished: boolean; }) => { if (!isAudioEstablished) { return 'var(--gray-60)'; } if (isActivelySpeaking) { return 'var(--app-bg-secondary)'; } return 'var(--white)'; }; const GroupVideoGridTile: React.FC = ({ minimized, participant, selfParticipant, participantCount, isMaximized, onTileDoubleClick, }) => { const {isMuted, videoState, videoStream, blurredVideoStream, isActivelySpeaking, isAudioEstablished} = useKoSubscribableChildren(participant, [ 'isMuted', 'videoStream', 'blurredVideoStream', 'isActivelySpeaking', 'videoState', 'isAudioEstablished', ]); const {name} = useKoSubscribableChildren(participant?.user, ['name']); const sharesScreen = videoState === VIDEO_STATE.SCREENSHARE; const sharesCamera = [VIDEO_STATE.STARTED, VIDEO_STATE.PAUSED].includes(videoState); const hasPausedVideo = videoState === VIDEO_STATE.PAUSED; const hasActiveVideo = (sharesCamera || sharesScreen) && !!videoStream; const activelySpeakingBoxShadow = `inset 0px 0px 0px 1px var(--group-video-bg), inset 0px 0px 0px 4px var(--accent-color), inset 0px 0px 0px 7px var(--app-bg-secondary)`; const groupVideoBoxShadow = participantCount > 1 ? 'inset 0px 0px 0px 2px var(--group-video-bg)' : 'initial'; const handleTileClick = () => onTileDoubleClick(participant?.user.qualifiedId, participant?.clientId); const handleEnterTileClick = (keyboardEvent: React.KeyboardEvent) => { if (isEnterKey(keyboardEvent)) { handleTileClick(); } }; const participantNameColor = getParticipantNameColor({isActivelySpeaking, isAudioEstablished}); const nameContainer = !minimized && (
{name} {!isAudioEstablished && ( {t('videoCallParticipantConnecting')} )}
); return ( ); }; export {GroupVideoGridTile};