// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useState } from 'react'; import classNames from 'classnames'; import { groupBy } from 'lodash'; import { Button, ButtonVariant } from './Button'; import type { LocalizerType } from '../types/Util'; import { Modal } from './Modal'; import type { PresentedSource, PresentableSource } from '../types/Calling'; import { Theme } from '../util/theme'; export type PropsType = { i18n: LocalizerType; presentingSourcesAvailable: Array; setPresenting: (_?: PresentedSource) => void; }; const Source = ({ onSourceClick, source, sourceToPresent, }: { onSourceClick: (source: PresentedSource) => void; source: PresentableSource; sourceToPresent?: PresentedSource; }): JSX.Element => { return ( ); }; export const CallingSelectPresentingSourcesModal = ({ i18n, presentingSourcesAvailable, setPresenting, }: 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 ); return ( { setPresenting(); }} theme={Theme.Dark} title={i18n('calling__SelectPresentingSourcesModal--title')} >
{i18n('calling__SelectPresentingSourcesModal--entireScreen')}
{sources.true.map(source => ( setSourceToPresent(selectedSource)} source={source} sourceToPresent={sourceToPresent} /> ))}
{i18n('calling__SelectPresentingSourcesModal--window')}
{sources.false.map(source => ( setSourceToPresent(selectedSource)} source={source} sourceToPresent={sourceToPresent} /> ))}
); };