signal-desktop/ts/components/CallingHeader.tsx

146 lines
4.5 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
2020-11-17 15:07:53 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import type { ReactNode } from 'react';
import React from 'react';
2020-11-20 19:39:50 +00:00
import classNames from 'classnames';
import type { LocalizerType } from '../types/Util';
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;
onCancel?: () => void;
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,
onCancel,
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
2023-03-30 00:03:25 +00:00
content={i18n('icu:calling__participants', {
2023-03-27 23:37:39 +00:00
people: String(participantCount),
})}
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
2023-03-30 00:03:25 +00:00
aria-label={i18n('icu:calling__participants', {
2023-03-27 23:37:39 +00:00
people: String(participantCount),
})}
2022-11-18 00:45:19 +00:00
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
2023-03-30 00:03:25 +00:00
content={i18n('icu:callingDeviceSelection__settings')}
2021-01-08 22:57:54 +00:00
theme={Theme.Dark}
>
<button
2023-03-30 00:03:25 +00:00
aria-label={i18n('icu:callingDeviceSelection__settings')}
2022-11-18 00:45:19 +00:00
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={
2022-11-18 00:45:19 +00:00
isInSpeakerView
2023-03-30 00:03:25 +00:00
? i18n('icu:calling__switch-view--to-grid')
: i18n('icu:calling__switch-view--to-speaker')
}
2022-11-18 00:45:19 +00:00
theme={Theme.Dark}
>
<button
aria-label={
2022-11-18 00:45:19 +00:00
isInSpeakerView
2023-03-30 00:03:25 +00:00
? i18n('icu:calling__switch-view--to-grid')
: i18n('icu:calling__switch-view--to-speaker')
}
2022-11-18 00:45:19 +00:00
className={
isInSpeakerView
? 'CallingButton__grid-view'
: 'CallingButton__speaker-view'
}
onClick={toggleSpeakerView}
type="button"
/>
</Tooltip>
</div>
)}
{togglePip && (
<div className="module-calling-tools__button">
2023-03-30 00:03:25 +00:00
<Tooltip content={i18n('icu:calling__pip--on')} theme={Theme.Dark}>
2022-11-18 00:45:19 +00:00
<button
2023-03-30 00:03:25 +00:00
aria-label={i18n('icu:calling__pip--on')}
2022-11-18 00:45:19 +00:00
className="CallingButton__pip"
onClick={togglePip}
type="button"
/>
</Tooltip>
</div>
)}
{onCancel && (
<div className="module-calling-tools__button">
2023-03-30 00:03:25 +00:00
<Tooltip content={i18n('icu:cancel')} theme={Theme.Dark}>
2022-11-18 00:45:19 +00:00
<button
2023-03-30 00:03:25 +00:00
aria-label={i18n('icu:cancel')}
2022-11-18 00:45:19 +00:00
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
);
}