signal-desktop/ts/components/CallingHeader.tsx

139 lines
4.1 KiB
TypeScript
Raw Normal View History

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
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
};
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,
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,
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">
{isGroupCall && participantCount ? (
2020-11-17 15:07:53 +00:00
<div className="module-calling-tools__button">
<Tooltip
content={i18n('calling__participants', [String(participantCount)])}
theme={Theme.Dark}
2020-11-17 15:07:53 +00:00
>
<button
aria-label={i18n('calling__participants', [
String(participantCount),
2020-11-17 15:07:53 +00:00
])}
2021-12-07 16:00:26 +00:00
className={classNames('CallingButton__participants--container', {
'CallingButton__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
>
2021-12-07 16:00:26 +00:00
<i className="CallingButton__participants" />
<span className="CallingButton__participants--count">
{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')}
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')}
2021-12-07 16:00:26 +00:00
className="CallingButton__settings"
2020-11-17 15:07:53 +00:00
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
2021-12-07 16:00:26 +00:00
? 'CallingButton__grid-view'
: 'CallingButton__speaker-view'
2021-01-08 22:57:54 +00:00
}
onClick={toggleSpeakerView}
type="button"
/>
</Tooltip>
</div>
)}
{togglePip && (
2020-11-17 15:07:53 +00:00
<div className="module-calling-tools__button">
<Tooltip content={i18n('calling__pip--on')} theme={Theme.Dark}>
2020-11-17 15:07:53 +00:00
<button
aria-label={i18n('calling__pip--on')}
2021-12-07 16:00:26 +00:00
className="CallingButton__pip"
2020-11-17 15:07:53 +00:00
onClick={togglePip}
2020-11-19 18:11:35 +00:00
type="button"
2020-11-17 15:07:53 +00:00
/>
</Tooltip>
</div>
)}
{onCancel && (
<div className="module-calling-tools__button">
<Tooltip content={i18n('cancel')} theme={Theme.Dark}>
<button
aria-label={i18n('cancel')}
2021-12-07 16:00:26 +00:00
className="CallingButton__cancel"
onClick={onCancel}
type="button"
/>
</Tooltip>
</div>
)}
2020-11-17 15:07:53 +00:00
</div>
</div>
);