/* 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 (
{t('General Settings')}