// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import classNames from 'classnames';
import React from 'react';
import type { LocalizerType } from '../types/Util';
import { CallViewMode } from '../types/Calling';
import { Tooltip } from './Tooltip';
import { Theme } from '../util/theme';
import { ContextMenu } from './ContextMenu';
export type PropsType = {
callViewMode?: CallViewMode;
i18n: LocalizerType;
isGroupCall?: boolean;
onCancel?: () => void;
participantCount: number;
togglePip?: () => void;
toggleSettings: () => void;
changeCallView?: (mode: CallViewMode) => void;
};
export function CallingHeader({
callViewMode,
changeCallView,
i18n,
isGroupCall = false,
onCancel,
participantCount,
togglePip,
toggleSettings,
}: PropsType): JSX.Element {
return (
{isGroupCall &&
participantCount > 2 &&
callViewMode &&
changeCallView && (
changeCallView(CallViewMode.Paginated),
value: CallViewMode.Paginated,
},
{
icon: 'CallSettingsButton__Icon--OverflowView',
label: i18n('icu:calling__view_mode--overflow'),
onClick: () => changeCallView(CallViewMode.Overflow),
value: CallViewMode.Overflow,
},
{
icon: 'CallSettingsButton__Icon--SpeakerView',
label: i18n('icu:calling__view_mode--speaker'),
onClick: () => changeCallView(CallViewMode.Speaker),
value: CallViewMode.Speaker,
},
]}
theme={Theme.Dark}
popperOptions={{
placement: 'bottom',
strategy: 'absolute',
}}
value={
// If it's Presentation we want to still show Speaker as selected
callViewMode === CallViewMode.Presentation
? CallViewMode.Speaker
: callViewMode
}
>
)}
{togglePip && (
)}
{onCancel && (
)}
);
}
const CALL_VIEW_MODE_ICON_CLASSNAMES: Record = {
[CallViewMode.Overflow]: 'CallSettingsButton__Icon--OverflowView',
[CallViewMode.Paginated]: 'CallSettingsButton__Icon--PaginatedView',
[CallViewMode.Speaker]: 'CallSettingsButton__Icon--SpeakerView',
[CallViewMode.Presentation]: 'CallSettingsButton__Icon--SpeakerView',
};
export function getCallViewIconClassname(viewMode: CallViewMode): string {
return CALL_VIEW_MODE_ICON_CLASSNAMES[viewMode];
}