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-10-26 19:15:33 +00:00
|
|
|
import type { ReactNode } from 'react';
|
|
|
|
import React from 'react';
|
2020-11-20 19:39:50 +00:00
|
|
|
import classNames from 'classnames';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { 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
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function CallingHeader({
|
2020-11-17 15:07:53 +00:00
|
|
|
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,
|
2022-11-18 00:45:19 +00:00
|
|
|
}: PropsType): JSX.Element {
|
|
|
|
return (
|
|
|
|
<div className="module-calling__header">
|
|
|
|
{title ? (
|
|
|
|
<div className="module-calling__header--header-name">{title}</div>
|
|
|
|
) : null}
|
|
|
|
{message ? (
|
|
|
|
<div className="module-ongoing-call__header-message">{message}</div>
|
|
|
|
) : null}
|
|
|
|
<div className="module-calling-tools">
|
|
|
|
{isGroupCall && participantCount ? (
|
|
|
|
<div className="module-calling-tools__button">
|
|
|
|
<Tooltip
|
|
|
|
content={i18n('calling__participants', [
|
2020-11-25 18:16:51 +00:00
|
|
|
String(participantCount),
|
2020-11-17 15:07:53 +00:00
|
|
|
])}
|
2022-11-18 00:45:19 +00:00
|
|
|
theme={Theme.Dark}
|
2020-11-20 19:39:50 +00:00
|
|
|
>
|
2022-11-18 00:45:19 +00:00
|
|
|
<button
|
|
|
|
aria-label={i18n('calling__participants', [
|
|
|
|
String(participantCount),
|
|
|
|
])}
|
|
|
|
className={classNames(
|
|
|
|
'CallingButton__participants--container',
|
|
|
|
{
|
|
|
|
'CallingButton__participants--shown': showParticipantsList,
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
onClick={toggleParticipants}
|
|
|
|
type="button"
|
|
|
|
>
|
|
|
|
<i className="CallingButton__participants" />
|
|
|
|
<span className="CallingButton__participants--count">
|
|
|
|
{participantCount}
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
) : null}
|
2021-01-08 22:57:54 +00:00
|
|
|
<div className="module-calling-tools__button">
|
|
|
|
<Tooltip
|
2022-11-18 00:45:19 +00:00
|
|
|
content={i18n('callingDeviceSelection__settings')}
|
2021-01-08 22:57:54 +00:00
|
|
|
theme={Theme.Dark}
|
|
|
|
>
|
|
|
|
<button
|
2022-11-18 00:45:19 +00:00
|
|
|
aria-label={i18n('callingDeviceSelection__settings')}
|
|
|
|
className="CallingButton__settings"
|
|
|
|
onClick={toggleSettings}
|
2021-01-08 22:57:54 +00:00
|
|
|
type="button"
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
2022-11-18 00:45:19 +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
|
|
|
|
? 'CallingButton__grid-view'
|
|
|
|
: 'CallingButton__speaker-view'
|
|
|
|
}
|
|
|
|
onClick={toggleSpeakerView}
|
|
|
|
type="button"
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{togglePip && (
|
|
|
|
<div className="module-calling-tools__button">
|
|
|
|
<Tooltip content={i18n('calling__pip--on')} theme={Theme.Dark}>
|
|
|
|
<button
|
|
|
|
aria-label={i18n('calling__pip--on')}
|
|
|
|
className="CallingButton__pip"
|
|
|
|
onClick={togglePip}
|
|
|
|
type="button"
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{onCancel && (
|
|
|
|
<div className="module-calling-tools__button">
|
|
|
|
<Tooltip content={i18n('cancel')} theme={Theme.Dark}>
|
|
|
|
<button
|
|
|
|
aria-label={i18n('cancel')}
|
|
|
|
className="CallingButton__cancel"
|
|
|
|
onClick={onCancel}
|
|
|
|
type="button"
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2020-11-17 15:07:53 +00:00
|
|
|
</div>
|
2022-11-18 00:45:19 +00:00
|
|
|
);
|
|
|
|
}
|