1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import React from 'react';
import {
Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, Container, FormControl, InputLabel, Select, MenuItem, Checkbox, FormControlLabel,
} from '@material-ui/core';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import { useLocalization, useTranslation } from '../LocalizationProvider';
import OptionsLayout from './OptionsLayout';
import usePersistedState from '../common/usePersistedState';
const useStyles = makeStyles((theme) => ({
container: {
marginTop: theme.spacing(2),
},
details: {
flexDirection: 'column',
},
}));
const PreferencesPage = () => {
const classes = useStyles();
const t = useTranslation();
const { languages, language, setLanguage } = useLocalization();
const languageList = Object.entries(languages).map((values) => ({ code: values[0], name: values[1].name }));
const [mapLiveRoutes, setMapLiveRoutes] = usePersistedState('mapLiveRoutes', false);
const [mapFollow, setMapFollow] = usePersistedState('mapFollow', false);
const [mapCluster, setMapCluster] = usePersistedState('mapCluster', true);
return (
<OptionsLayout>
<Container maxWidth="xs" className={classes.container}>
<Accordion defaultExpanded>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
<Typography variant="subtitle1">
{t('sharedPreferences')}
</Typography>
</AccordionSummary>
<AccordionDetails className={classes.details}>
<FormControl variant="filled" fullWidth>
<InputLabel>{t('loginLanguage')}</InputLabel>
<Select value={language} onChange={(e) => setLanguage(e.target.value)}>
{languageList.map((it) => <MenuItem key={it.code} value={it.code}>{it.name}</MenuItem>)}
</Select>
</FormControl>
</AccordionDetails>
</Accordion>
<Accordion>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
<Typography variant="subtitle1">
{t('mapTitle')}
</Typography>
</AccordionSummary>
<AccordionDetails className={classes.details}>
<FormControlLabel
control={<Checkbox checked={mapLiveRoutes} onChange={(event) => setMapLiveRoutes(event.target.checked)} />}
label={t('mapLiveRoutes')}
/>
<FormControlLabel
control={<Checkbox checked={mapFollow} onChange={(event) => setMapFollow(event.target.checked)} />}
label={t('deviceFollow')}
/>
<FormControlLabel
control={<Checkbox checked={mapCluster} onChange={(event) => setMapCluster(event.target.checked)} />}
label={t('mapClustering')}
/>
</AccordionDetails>
</Accordion>
</Container>
</OptionsLayout>
);
};
export default PreferencesPage;
|