import { remote } from 'electron'; import React, { useCallback, useEffect, useState } from 'react'; import { H3, Card, Dialog, Button } from '@blueprintjs/core'; import { Row, Col } from 'react-flexbox-grid'; import { createStyles, makeStyles } from '@material-ui/core/styles'; import { useTranslation } from 'react-i18next'; import CloseOverlayButton from '../../CloseOverlayButton'; import PreviewGridList from './PreviewGridList'; import DesktopCapturerSources from '../../../features/DesktopCapturerSourcesService'; import isWithReactRevealAnimations from '../../../utils/isWithReactRevealAnimations'; const desktopCapturerSourcesService = remote.getGlobal( 'desktopCapturerSourcesService' ) as DesktopCapturerSources; const Zoom = require('react-reveal/Zoom'); const Fade = require('react-reveal/Fade'); const useStyles = makeStyles(() => createStyles({ dialogRoot: { width: '90%', height: '87vh !important', overflowY: 'scroll', }, closeButton: { position: 'relative', width: '40px', height: '40px', left: 'calc(100% - 55px)', borderRadius: '100px', zIndex: 9999, }, overlayInnerRoot: { width: '90%', height: '90%' }, sharePreviewsContainer: { top: '60px', position: 'relative', height: '100%', }, }) ); interface ChooseAppOrScreenOverlayProps { isEntireScreenToShareChosen: boolean; isChooseAppOrScreenOverlayOpen: boolean; handleNextEntireScreen: () => void; handleNextApplicationWindow: () => void; handleClose: () => void; } export default function ChooseAppOrScreenOverlay( props: ChooseAppOrScreenOverlayProps ) { const { t } = useTranslation(); const { handleClose, isChooseAppOrScreenOverlayOpen, isEntireScreenToShareChosen, handleNextEntireScreen, handleNextApplicationWindow, } = props; const classes = useStyles(); const [ screenViewSharingObjectsMap, setScreenViewSharingObjectsMap, ] = useState>(new Map()); const [ appsWindowsViewSharingObjectsMap, setAppsWindowsViewSharingObjectsMap, ] = useState>(new Map()); const handleRefreshSources = useCallback(() => { if (isEntireScreenToShareChosen) { const sourcesToShare = desktopCapturerSourcesService.getScreenSources(); const screenViewMap = new Map(); sourcesToShare.forEach((source) => { screenViewMap.set(source.id, { thumbnailUrl: source.thumbnail.toDataURL(), name: source.name, }); }); setScreenViewSharingObjectsMap(screenViewMap); } else { const sourcesToShare = desktopCapturerSourcesService.getAppWindowSources(); const appViewMap = new Map(); sourcesToShare.forEach((source) => { appViewMap.set(source.id, { thumbnailUrl: source.thumbnail.toDataURL(), name: source.name, }); }); setAppsWindowsViewSharingObjectsMap(appViewMap); } }, [isEntireScreenToShareChosen]); useEffect(() => { handleRefreshSources(); }, [handleRefreshSources, isEntireScreenToShareChosen]); return (
{isEntireScreenToShareChosen ? (

{t('Select Entire Screen to Share')}

) : (

{t('Select App Window to Share')}

)}
{ handleNextEntireScreen(); handleClose(); }} handleNextApplicationWindow={() => { handleNextApplicationWindow(); handleClose(); }} />
); }