import React from 'react'; import { useTranslation } from 'react-i18next'; import { Grid, Paper, Switch, useTheme, FormControlLabel, List, ListItem, ListItemIcon, Slider, Typography, ToggleButtonGroup, ToggleButton, } from '@mui/material'; import { Settings } from '../../models'; import SelectLanguage from './SelectLanguage'; import { Translate, Palette, LightMode, DarkMode, SettingsOverscan, Link, } from '@mui/icons-material'; import { systemClient } from '../../services/System'; interface SettingsFormProps { dense?: boolean; settings: Settings; setSettings: (state: Settings) => void; showNetwork?: boolean; } const SettingsForm = ({ dense = false, settings, setSettings, showNetwork = false, }: SettingsFormProps): JSX.Element => { const theme = useTheme(); const { t } = useTranslation(); const fontSizes = [ { label: 'XS', value: { basic: 12, pro: 10 } }, { label: 'S', value: { basic: 13, pro: 11 } }, { label: 'M', value: { basic: 14, pro: 12 } }, { label: 'L', value: { basic: 15, pro: 13 } }, { label: 'XL', value: { basic: 16, pro: 14 } }, ]; return ( { setSettings({ ...settings, language }); systemClient.setCookie('settings_language', language); }} /> } icon={ } onChange={(e) => { const mode = e.target.checked ? 'dark' : 'light'; setSettings({ ...settings, mode }); systemClient.setCookie('settings_mode', mode); }} /> } /> { const fontSize = e.target.value; setSettings({ ...settings, fontSize }); systemClient.setCookie( `settings_fontsize_${settings.frontend}`, fontSize.toString(), ); }} valueLabelDisplay='off' marks={fontSizes.map(({ label, value }) => ({ label: {t(label)}, value: settings.frontend === 'basic' ? value.basic : value.pro, }))} track={false} /> {showNetwork ? ( { setSettings({ ...settings, network }); systemClient.setCookie('settings_network', network); }} > {t('Mainnet')} {t('Testnet')} ) : ( <> )} ); }; export default SettingsForm;