/* eslint-disable jsx-a11y/anchor-is-valid */ /* eslint-disable jsx-a11y/no-static-element-interactions */ /* eslint-disable jsx-a11y/click-events-have-key-events */ import { ipcRenderer, shell } from 'electron'; import React, { useContext, useEffect, useState } from 'react'; import { Overlay, Classes, H3, H6, H4, Tabs, Tab, Icon, Text, Checkbox, } from '@blueprintjs/core'; import { useTranslation } from 'react-i18next'; import { Col, Row } from 'react-flexbox-grid'; import { createStyles, makeStyles } from '@material-ui/core/styles'; import { DARK_UI_BACKGROUND, LIGHT_UI_BACKGROUND, SettingsContext, } from '../../containers/SettingsProvider'; import CloseOverlayButton from '../CloseOverlayButton'; import SettingRowLabelAndInput from './SettingRowLabelAndInput'; import isWithReactRevealAnimations from '../../utils/isWithReactRevealAnimations'; import config from '../../api/config'; import LanguageSelector from '../LanguageSelector'; import ToggleThemeBtnGroup from '../ToggleThemeBtnGroup'; const { port } = config; const Fade = require('react-reveal/Fade'); interface SettingsOverlayProps { isSettingsOpen: boolean; handleClose: () => void; } const useStylesWithTheme = (isDarkTheme: boolean) => makeStyles(() => createStyles({ checkboxSettings: { margin: '0' }, overlayInnerRoot: { width: '90%' }, overlayInsideFade: { height: '90vh', backgroundColor: isDarkTheme ? DARK_UI_BACKGROUND : LIGHT_UI_BACKGROUND, }, absoluteCloseButton: { position: 'absolute', left: 'calc(100% - 65px)' }, tabNavigationRowButton: { fontWeight: 700 }, iconInTablLeftButton: { marginRight: '5px' }, }) ); export default function SettingsOverlay(props: SettingsOverlayProps) { const { t } = useTranslation(); const { handleClose, isSettingsOpen } = props; const [latestVersion, setLatestVersion] = useState(''); const [currentVersion, setCurrentVersion] = useState(''); const { isDarkTheme } = useContext(SettingsContext); useEffect(() => { const getLatestVersion = async () => { const gotLatestVersion = await ipcRenderer.invoke('get-latest-version'); if (gotLatestVersion !== '') { setLatestVersion(gotLatestVersion); } }; getLatestVersion(); const getCurrentVersion = async () => { const gotCurrentVersion = await ipcRenderer.invoke('get-current-version'); if (gotCurrentVersion !== '') { setCurrentVersion(gotCurrentVersion); } }; getCurrentVersion(); }, []); const getClassesCallback = useStylesWithTheme(isDarkTheme); const getAutomaticUpdatesCheckboxInput = () => { return ( ); }; const GeneralSettingsPanel: React.FC = () => ( <>

{t('General Settings')}

} /> } /> ); const SecurityPanel: React.FC = () => (

{t('Security Settings')}

{`HTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic views in web-applications. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop.`}
); const AboutPanel: React.FC = () => ( ); const getTabNavSecurityButton = () => { return ( {t('Security')} ); }; const getTabNavGeneralSettingsButton = () => { return ( {t('General')} ); }; const getTabNavAboutButton = () => { return ( {t('About')} ); }; return (
{latestVersion !== '' && currentVersion !== '' && latestVersion !== currentVersion ? (

{ e.preventDefault(); shell.openExternal('https://deskreen.com'); }} style={{ width: 'calc(100% - 50px)', }} > {/* eslint-disable-next-line react/jsx-one-expression-per-line */} {`${t( 'A new version of Deskreen is available! Click to download new version' )} ${latestVersion}`}

) : ( <> )} }> {getTabNavGeneralSettingsButton()} }> {getTabNavSecurityButton()} }> {getTabNavAboutButton()}
); }