// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useState } from 'react'; import classNames from 'classnames'; import lodash from 'lodash'; import { Button, ButtonVariant } from './Button.js'; import type { LocalizerType } from '../types/Util.js'; import { Modal } from './Modal.js'; import type { PresentedSource, PresentableSource } from '../types/Calling.js'; import { Theme } from '../util/theme.js'; import { strictAssert } from '../util/assert.js'; const { groupBy } = lodash; export type PropsType = { i18n: LocalizerType; presentingSourcesAvailable: ReadonlyArray; selectPresentingSource: (id: string) => void; cancelPresenting: () => void; }; function Source({ onSourceClick, source, sourceToPresent, }: { onSourceClick: (source: PresentedSource) => void; source: PresentableSource; sourceToPresent?: PresentedSource; }): JSX.Element { return ( ); } export function CallingSelectPresentingSourcesModal({ i18n, presentingSourcesAvailable, selectPresentingSource, cancelPresenting, }: PropsType): JSX.Element | null { const [sourceToPresent, setSourceToPresent] = useState< PresentedSource | undefined >(undefined); if (!presentingSourcesAvailable.length) { throw new Error('No sources available for presenting'); } const sources = groupBy( presentingSourcesAvailable, source => source.isScreen ); const footer = ( <> ); return (
{i18n('icu:calling__SelectPresentingSourcesModal--entireScreen')}
{(sources.true ?? []).map(source => ( setSourceToPresent(selectedSource)} source={source} sourceToPresent={sourceToPresent} /> ))}
{i18n('icu:calling__SelectPresentingSourcesModal--window')}
{(sources.false ?? []).map(source => ( setSourceToPresent(selectedSource)} source={source} sourceToPresent={sourceToPresent} /> ))}
); }