2021-01-08 22:57:54 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2020-11-17 15:07:53 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-09-18 00:20:29 +00:00
|
|
|
import React, { ReactNode } from 'react';
|
2020-11-20 19:39:50 +00:00
|
|
|
import classNames from 'classnames';
|
2020-11-17 15:07:53 +00:00
|
|
|
import { LocalizerType } from '../types/Util';
|
2020-12-04 23:03:01 +00:00
|
|
|
import { Tooltip } from './Tooltip';
|
|
|
|
import { Theme } from '../util/theme';
|
2020-11-17 15:07:53 +00:00
|
|
|
|
|
|
|
export type PropsType = {
|
|
|
|
i18n: LocalizerType;
|
2021-01-08 22:57:54 +00:00
|
|
|
isInSpeakerView?: boolean;
|
2020-11-17 15:07:53 +00:00
|
|
|
isGroupCall?: boolean;
|
2021-09-18 00:20:29 +00:00
|
|
|
message?: ReactNode;
|
2021-08-17 21:45:18 +00:00
|
|
|
onCancel?: () => void;
|
2020-11-25 18:16:51 +00:00
|
|
|
participantCount: number;
|
2020-11-20 19:39:50 +00:00
|
|
|
showParticipantsList: boolean;
|
2020-11-23 21:37:39 +00:00
|
|
|
title?: string;
|
2020-11-17 15:07:53 +00:00
|
|
|
toggleParticipants?: () => void;
|
|
|
|
togglePip?: () => void;
|
|
|
|
toggleSettings: () => void;
|
2021-01-08 22:57:54 +00:00
|
|
|
toggleSpeakerView?: () => void;
|
2020-11-17 15:07:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const CallingHeader = ({
|
|
|
|
i18n,
|
2021-01-08 22:57:54 +00:00
|
|
|
isInSpeakerView,
|
2020-11-17 15:07:53 +00:00
|
|
|
isGroupCall = false,
|
2020-11-23 21:37:39 +00:00
|
|
|
message,
|
2021-08-17 21:45:18 +00:00
|
|
|
onCancel,
|
2020-11-25 18:16:51 +00:00
|
|
|
participantCount,
|
2020-11-20 19:39:50 +00:00
|
|
|
showParticipantsList,
|
2020-11-23 21:37:39 +00:00
|
|
|
title,
|
2020-11-17 15:07:53 +00:00
|
|
|
toggleParticipants,
|
|
|
|
togglePip,
|
|
|
|
toggleSettings,
|
2021-01-08 22:57:54 +00:00
|
|
|
toggleSpeakerView,
|
2020-11-17 15:07:53 +00:00
|
|
|
}: PropsType): JSX.Element => (
|
|
|
|
<div className="module-calling__header">
|
2020-11-23 21:37:39 +00:00
|
|
|
{title ? (
|
|
|
|
<div className="module-calling__header--header-name">{title}</div>
|
|
|
|
) : null}
|
|
|
|
{message ? (
|
|
|
|
<div className="module-ongoing-call__header-message">{message}</div>
|
|
|
|
) : null}
|
2020-11-17 15:07:53 +00:00
|
|
|
<div className="module-calling-tools">
|
2021-08-17 21:45:18 +00:00
|
|
|
{participantCount ? (
|
2020-11-17 15:07:53 +00:00
|
|
|
<div className="module-calling-tools__button">
|
|
|
|
<Tooltip
|
2020-11-25 18:16:51 +00:00
|
|
|
content={i18n('calling__participants', [String(participantCount)])}
|
2020-12-04 23:03:01 +00:00
|
|
|
theme={Theme.Dark}
|
2020-11-17 15:07:53 +00:00
|
|
|
>
|
|
|
|
<button
|
|
|
|
aria-label={i18n('calling__participants', [
|
2020-11-25 18:16:51 +00:00
|
|
|
String(participantCount),
|
2020-11-17 15:07:53 +00:00
|
|
|
])}
|
2020-11-20 19:39:50 +00:00
|
|
|
className={classNames(
|
|
|
|
'module-calling-button__participants--container',
|
|
|
|
{
|
|
|
|
'module-calling-button__participants--shown': showParticipantsList,
|
|
|
|
}
|
|
|
|
)}
|
2020-11-17 15:07:53 +00:00
|
|
|
onClick={toggleParticipants}
|
2020-11-19 18:11:35 +00:00
|
|
|
type="button"
|
2020-11-20 19:39:50 +00:00
|
|
|
>
|
|
|
|
<i className="module-calling-button__participants" />
|
|
|
|
<span className="module-calling-button__participants--count">
|
2020-11-25 18:16:51 +00:00
|
|
|
{participantCount}
|
2020-11-20 19:39:50 +00:00
|
|
|
</span>
|
|
|
|
</button>
|
2020-11-17 15:07:53 +00:00
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
<div className="module-calling-tools__button">
|
2020-11-19 23:38:59 +00:00
|
|
|
<Tooltip
|
|
|
|
content={i18n('callingDeviceSelection__settings')}
|
2020-12-04 23:03:01 +00:00
|
|
|
theme={Theme.Dark}
|
2020-11-19 23:38:59 +00:00
|
|
|
>
|
2020-11-17 15:07:53 +00:00
|
|
|
<button
|
|
|
|
aria-label={i18n('callingDeviceSelection__settings')}
|
|
|
|
className="module-calling-button__settings"
|
|
|
|
onClick={toggleSettings}
|
2020-11-19 18:11:35 +00:00
|
|
|
type="button"
|
2020-11-17 15:07:53 +00:00
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
2021-01-08 22:57:54 +00:00
|
|
|
{isGroupCall && participantCount > 2 && toggleSpeakerView && (
|
|
|
|
<div className="module-calling-tools__button">
|
|
|
|
<Tooltip
|
|
|
|
content={i18n(
|
|
|
|
isInSpeakerView
|
|
|
|
? 'calling__switch-view--to-grid'
|
|
|
|
: 'calling__switch-view--to-speaker'
|
|
|
|
)}
|
|
|
|
theme={Theme.Dark}
|
|
|
|
>
|
|
|
|
<button
|
|
|
|
aria-label={i18n(
|
|
|
|
isInSpeakerView
|
|
|
|
? 'calling__switch-view--to-grid'
|
|
|
|
: 'calling__switch-view--to-speaker'
|
|
|
|
)}
|
|
|
|
className={
|
|
|
|
isInSpeakerView
|
|
|
|
? 'module-calling-button__grid-view'
|
|
|
|
: 'module-calling-button__speaker-view'
|
|
|
|
}
|
|
|
|
onClick={toggleSpeakerView}
|
|
|
|
type="button"
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
)}
|
2021-08-17 21:45:18 +00:00
|
|
|
{togglePip && (
|
2020-11-17 15:07:53 +00:00
|
|
|
<div className="module-calling-tools__button">
|
2020-12-04 23:03:01 +00:00
|
|
|
<Tooltip content={i18n('calling__pip--on')} theme={Theme.Dark}>
|
2020-11-17 15:07:53 +00:00
|
|
|
<button
|
|
|
|
aria-label={i18n('calling__pip--on')}
|
|
|
|
className="module-calling-button__pip"
|
|
|
|
onClick={togglePip}
|
2020-11-19 18:11:35 +00:00
|
|
|
type="button"
|
2020-11-17 15:07:53 +00:00
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
)}
|
2021-08-17 21:45:18 +00:00
|
|
|
{onCancel && (
|
|
|
|
<div className="module-calling-tools__button">
|
|
|
|
<Tooltip content={i18n('cancel')} theme={Theme.Dark}>
|
|
|
|
<button
|
|
|
|
aria-label={i18n('cancel')}
|
|
|
|
className="module-calling-button__cancel"
|
|
|
|
onClick={onCancel}
|
|
|
|
type="button"
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
)}
|
2020-11-17 15:07:53 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|