add feature to hide Workspace stats

This commit is contained in:
Mario 2020-11-05 18:30:27 +01:00
parent 5da3006e75
commit 70c8a1db60
6 changed files with 110 additions and 60 deletions

View File

@ -29,7 +29,7 @@ Blockly.Arduino['arduino_functions'] = function (block) {
return loopBranch; return loopBranch;
}; };
Blockly.Arduino['procedures_defreturn'] = function (block: Block | any) { Blockly.Arduino['procedures_defreturn'] = function (block) {
// Define a procedure with a return value. // Define a procedure with a return value.
const funcName = Blockly.Arduino.variableDB_.getName( const funcName = Blockly.Arduino.variableDB_.getName(
block.getFieldValue('NAME'), block.getFieldValue('NAME'),

View File

@ -49,7 +49,8 @@ class Home extends Component {
codeOn: false, codeOn: false,
gallery: [], gallery: [],
share: [], share: [],
projectToLoad: undefined projectToLoad: undefined,
stats: window.localStorage.getItem('stats'),
} }
componentDidMount() { componentDidMount() {
@ -90,8 +91,11 @@ class Home extends Component {
render() { render() {
return ( return (
<div> <div>
<div style={{ float: 'right', height: '40px', marginBottom: '20px' }}><WorkspaceFunc /></div> {this.state.stats ?
<div style={{ float: 'left', height: '40px', position: 'relative' }}><WorkspaceStats /></div> <div style={{ float: 'left', height: '40px', position: 'relative' }}><WorkspaceStats /></div>
: null
}
<div style={{ float: 'right', height: '40px', marginBottom: '20px' }}><WorkspaceFunc /></div>
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid item xs={12} md={this.state.codeOn ? 8 : 12} style={{ position: 'relative' }}> <Grid item xs={12} md={this.state.codeOn ? 8 : 12} style={{ position: 'relative' }}>
<Tooltip title={this.state.codeOn ? 'Code ausblenden' : 'Code anzeigen'} > <Tooltip title={this.state.codeOn ? 'Code ausblenden' : 'Code anzeigen'} >

View File

@ -15,7 +15,7 @@ const useStyles = makeStyles((theme) => ({
}, },
})); }));
export default function LanguageSelector() { export default function RenderSelector() {
const classes = useStyles(); const classes = useStyles();
const [renderer, setRenderer] = React.useState(window.localStorage.getItem('renderer')); const [renderer, setRenderer] = React.useState(window.localStorage.getItem('renderer'));

View File

@ -5,6 +5,7 @@ import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
import LanguageSelector from './LanguageSelector'; import LanguageSelector from './LanguageSelector';
import RenderSelector from './RenderSelector'; import RenderSelector from './RenderSelector';
import StatsSelector from './StatsSelector';
class Settings extends Component { class Settings extends Component {
@ -14,6 +15,7 @@ class Settings extends Component {
<Typography variant='h4' style={{ marginBottom: '5px' }}>Einstellungen</Typography> <Typography variant='h4' style={{ marginBottom: '5px' }}>Einstellungen</Typography>
<LanguageSelector /> <LanguageSelector />
<RenderSelector /> <RenderSelector />
<StatsSelector />
<Button <Button
style={{ marginTop: '20px' }} style={{ marginTop: '20px' }}
variant="contained" variant="contained"

View File

@ -0,0 +1,44 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import InputLabel from '@material-ui/core/InputLabel';
import MenuItem from '@material-ui/core/MenuItem';
import FormControl from '@material-ui/core/FormControl';
import Select from '@material-ui/core/Select';
const useStyles = makeStyles((theme) => ({
formControl: {
margin: theme.spacing(1),
minWidth: 400,
},
selectEmpty: {
marginTop: theme.spacing(2),
},
}));
export default function StatsSelector() {
const classes = useStyles();
const [stats, setStats] = React.useState(window.localStorage.getItem('stats'));
const handleChange = (event) => {
setStats(event.target.value);
window.localStorage.setItem('stats', event.target.value);
};
return (
<div>
<FormControl className={classes.formControl}>
<InputLabel id="demo-simple-select-label">Renderer</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={stats}
onChange={handleChange}
>
<MenuItem value={true}>On</MenuItem>
<MenuItem value={false}>Off</MenuItem>
</Select>
</FormControl>
<p>Schaltet die Statistiken Oberhalb der Arbeitsfläche ein bzw. aus</p>
</div>
);
}