signal-desktop/ts/components/CallingHeader.tsx

134 lines
4.2 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-23 21:37:39 +00:00
title?: string;
2020-11-17 15:07:53 +00:00
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-23 21:37:39 +00:00
title,
2020-11-17 15:07:53 +00:00
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 > 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')
}
2023-10-25 13:40:22 +00:00
className="CallingButton__tooltip"
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')
}
2023-10-25 13:40:22 +00:00
className="CallSettingsButton__Button"
2022-11-18 00:45:19 +00:00
onClick={toggleSpeakerView}
type="button"
2023-10-25 13:40:22 +00:00
>
<span
className={classNames(
'CallSettingsButton__Icon',
isInSpeakerView
? 'CallSettingsButton__Icon--GridView'
: 'CallSettingsButton__Icon--SpeakerView'
)}
/>
</button>
2022-11-18 00:45:19 +00:00
</Tooltip>
</div>
)}
2023-10-25 13:40:22 +00:00
<div className="module-calling-tools__button">
<Tooltip
content={i18n('icu:callingDeviceSelection__settings')}
className="CallingButton__tooltip"
theme={Theme.Dark}
>
<button
aria-label={i18n('icu:callingDeviceSelection__settings')}
className="CallSettingsButton__Button"
onClick={toggleSettings}
type="button"
>
<span className="CallSettingsButton__Icon CallSettingsButton__Icon--Settings" />
</button>
</Tooltip>
</div>
{togglePip && (
<div className="module-calling-tools__button">
<Tooltip
content={i18n('icu:calling__pip--on')}
className="CallingButton__tooltip"
theme={Theme.Dark}
>
<button
aria-label={i18n('icu:calling__pip--on')}
className="CallSettingsButton__Button"
onClick={togglePip}
type="button"
>
<span className="CallSettingsButton__Icon CallSettingsButton__Icon--Pip" />
</button>
</Tooltip>
</div>
)}
2022-11-18 00:45:19 +00:00
{onCancel && (
<div className="module-calling-tools__button">
2023-10-25 13:40:22 +00:00
<Tooltip
content={i18n('icu:cancel')}
theme={Theme.Dark}
className="CallingButton__tooltip"
>
2022-11-18 00:45:19 +00:00
<button
2023-03-30 00:03:25 +00:00
aria-label={i18n('icu:cancel')}
2023-10-25 13:40:22 +00:00
className="CallSettingsButton__Button CallSettingsButton__Button--Cancel"
2022-11-18 00:45:19 +00:00
onClick={onCancel}
type="button"
2023-10-25 13:40:22 +00:00
>
<span className="CallSettingsButton__Icon CallSettingsButton__Icon--Cancel" />
</button>
2022-11-18 00:45:19 +00:00
</Tooltip>
</div>
)}
</div>
2020-11-17 15:07:53 +00:00
</div>
2022-11-18 00:45:19 +00:00
);
}