mirror of
https://github.com/mue/mue.git
synced 2026-06-08 14:10:42 +02:00
Co-authored-by: Alex Sparkes <turbomarshmello@gmail.com> Co-authored-by: Wessel Tip <discord@go2it.eu> Co-authored-by: Isaac Saunders <contact@eartharoid.me>
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import SettingsFunctions from '../../../modules/settingsFunctions';
|
|
import CheckboxUI from '@material-ui/core/Checkbox';
|
|
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
|
|
export default class Checkbox extends React.PureComponent {
|
|
constructor(...args) {
|
|
super(...args);
|
|
this.state = {
|
|
checked: true
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const handleChange = () => {
|
|
SettingsFunctions.setItem(this.props.name);
|
|
let checked;
|
|
if (this.state.checked === true) checked = false;
|
|
else checked = true;
|
|
this.setState({ checked: checked });
|
|
}
|
|
|
|
let value = localStorage.getItem(this.props.name);
|
|
|
|
switch (value) {
|
|
case 'true': value = true; break;
|
|
case 'false': value = false; break;
|
|
default: value = false;
|
|
}
|
|
|
|
this.setState({ checked: value });
|
|
|
|
return (
|
|
<React.Fragment>
|
|
<FormControlLabel
|
|
control={<CheckboxUI name="checkedB" color="primary" checked={this.state.checked} onChange={handleChange} />}
|
|
label={this.props.text}
|
|
/>
|
|
<br/>
|
|
</React.Fragment>
|
|
);
|
|
}
|
|
} |