import React, { useContext } from 'react'; import { useTranslation } from 'react-i18next'; import { AppContextProps, AppContext } from '../../contexts/AppContext'; import { Grid, Paper, Switch, useTheme, FormControlLabel, List, ListItem, ListItemIcon, Slider, Typography, ToggleButtonGroup, ToggleButton, } from '@mui/material'; import SelectLanguage from './SelectLanguage'; import { Translate, Palette, LightMode, DarkMode, SettingsOverscan, Link, AccountBalance, AttachMoney, } from '@mui/icons-material'; import { systemClient } from '../../services/System'; import SwapCalls from '@mui/icons-material/SwapCalls'; interface SettingsFormProps { dense?: boolean; showNetwork?: boolean; } const SettingsForm = ({ dense = false, showNetwork = false }: SettingsFormProps): JSX.Element => { const { fav, setFav, settings, setSettings } = useContext(AppContext); 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.setItem('settings_language', language); }} /> } icon={ } onChange={(e) => { const mode = e.target.checked ? 'dark' : 'light'; setSettings({ ...settings, mode }); systemClient.setItem('settings_mode', mode); }} /> } /> { const fontSize = e.target.value; setSettings({ ...settings, fontSize }); systemClient.setItem(`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} /> { setFav({ ...fav, mode, currency: mode === 'fiat' ? 0 : 1000 }); }} > {t('Fiat')} {t('Swaps')} {showNetwork ? ( { setSettings({ ...settings, network }); systemClient.setItem('settings_network', network); }} > {t('Mainnet')} {t('Testnet')} ) : ( <> )} ); }; export default SettingsForm;