import { CSSProperties, ReactNode, memo, useCallback } from 'react'; import { IoIosSettings } from 'react-icons/io'; import { FaLock, FaUnlock } from 'react-icons/fa'; import { CrossIcon, ListIcon, VolumeUpIcon, VolumeOffIcon } from 'evergreen-ui'; import { useTranslation } from 'react-i18next'; import Button from './components/Button'; import ExportModeButton from './components/ExportModeButton'; import { withBlur } from './util'; import { primaryTextColor, controlsBackground, darkModeTransition } from './colors'; import useUserSettings from './hooks/useUserSettings'; const outFmtStyle = { height: 20, maxWidth: 100 }; const exportModeStyle = { flexGrow: 0, flexBasis: 140 }; const TopMenu = memo(({ filePath, fileFormat, copyAnyAudioTrack, toggleStripAudio, renderOutFmt, numStreamsToCopy, numStreamsTotal, setStreamsSelectorShown, toggleSettings, selectedSegments, isCustomFormatSelected, clearOutDir, }: { filePath: string | undefined, fileFormat: string | undefined, copyAnyAudioTrack: boolean, toggleStripAudio: () => void, renderOutFmt: (style: CSSProperties) => ReactNode, numStreamsToCopy: number, numStreamsTotal: number, setStreamsSelectorShown: (v: boolean) => void, toggleSettings: () => void, selectedSegments, isCustomFormatSelected, clearOutDir, }) => { const { t } = useTranslation(); const { customOutDir, changeOutDir, simpleMode, outFormatLocked, setOutFormatLocked } = useUserSettings(); const onOutFormatLockedClick = useCallback(() => setOutFormatLocked((v) => (v ? undefined : fileFormat)), [fileFormat, setOutFormatLocked]); const showClearWorkingDirButton = !!customOutDir; function renderFormatLock() { const Icon = outFormatLocked ? FaLock : FaUnlock; return ; } return (
{filePath && ( <> )}
{showClearWorkingDirButton && ( )} {filePath && ( <> {renderOutFmt(outFmtStyle)} {!simpleMode && (isCustomFormatSelected || outFormatLocked) && renderFormatLock()} )}
); }); export default TopMenu;