2020-07-01 00:11:48 +02:00
|
|
|
import React from 'react';
|
2020-06-23 02:06:40 +02:00
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import { connect } from 'react-redux';
|
2020-07-01 00:11:48 +02:00
|
|
|
import { withRouter } from 'react-router';
|
2020-06-23 02:06:40 +02:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import styled from 'styled-components';
|
2020-06-23 20:54:09 +02:00
|
|
|
|
|
|
|
import * as PreferencesActions from '../IDE/actions/preferences';
|
|
|
|
import * as IdeActions from '../IDE/actions/ide';
|
|
|
|
|
2020-07-01 00:11:48 +02:00
|
|
|
import IconButton from '../../components/mobile/IconButton';
|
2020-06-23 02:06:40 +02:00
|
|
|
import Screen from '../../components/mobile/MobileScreen';
|
|
|
|
import Header from '../../components/mobile/Header';
|
2020-06-30 21:52:03 +02:00
|
|
|
import PreferencePicker from '../../components/mobile/PreferencePicker';
|
2020-06-23 02:06:40 +02:00
|
|
|
import { ExitIcon } from '../../common/icons';
|
2020-06-23 22:03:51 +02:00
|
|
|
import { remSize, prop } from '../../theme';
|
2020-06-23 02:06:40 +02:00
|
|
|
|
|
|
|
const Content = styled.div`
|
|
|
|
z-index: 0;
|
|
|
|
margin-top: ${remSize(68)};
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
const SettingsHeader = styled(Header)`
|
2020-07-01 21:44:19 +02:00
|
|
|
background: transparent;
|
2020-06-23 02:06:40 +02:00
|
|
|
`;
|
|
|
|
|
2020-06-23 22:03:51 +02:00
|
|
|
const SectionHeader = styled.h2`
|
|
|
|
color: ${prop('primaryTextColor')};
|
2020-07-01 21:44:19 +02:00
|
|
|
padding-top: ${remSize(32)};
|
2020-07-01 00:11:48 +02:00
|
|
|
`;
|
|
|
|
|
|
|
|
const SectionSubeader = styled.h3`
|
|
|
|
color: ${prop('primaryTextColor')};
|
2020-06-23 22:03:51 +02:00
|
|
|
`;
|
|
|
|
|
2020-06-23 02:06:40 +02:00
|
|
|
|
|
|
|
const MobilePreferences = (props) => {
|
2020-06-23 22:15:59 +02:00
|
|
|
const {
|
2020-06-23 22:27:43 +02:00
|
|
|
setTheme, setAutosave, setLinewrap, setTextOutput, setGridOutput, setSoundOutput, lineNumbers, lintWarning
|
2020-06-23 22:15:59 +02:00
|
|
|
} = props;
|
|
|
|
const {
|
2020-06-23 22:27:43 +02:00
|
|
|
theme, autosave, linewrap, textOutput, gridOutput, soundOutput, setLineNumbers, setLintWarning
|
2020-06-23 22:15:59 +02:00
|
|
|
} = props;
|
2020-06-23 20:54:09 +02:00
|
|
|
|
2020-06-23 22:03:51 +02:00
|
|
|
const generalSettings = [
|
2020-06-23 02:06:40 +02:00
|
|
|
{
|
|
|
|
title: 'Theme',
|
2020-06-23 20:54:09 +02:00
|
|
|
value: theme,
|
2020-06-23 02:06:40 +02:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
value: 'light', label: 'light', ariaLabel: 'light theme on', name: 'light theme', id: 'light-theme-on'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'dark', label: 'dark', ariaLabel: 'dark theme on', name: 'dark theme', id: 'dark-theme-on'
|
|
|
|
},
|
|
|
|
{
|
2020-07-01 22:37:32 +02:00
|
|
|
value: 'contrast',
|
|
|
|
label: 'contrast',
|
|
|
|
ariaLabel: 'contrast theme on',
|
|
|
|
name: 'contrast theme',
|
|
|
|
id: 'contrast-theme-on'
|
2020-06-23 02:06:40 +02:00
|
|
|
}
|
|
|
|
],
|
2020-06-23 20:54:09 +02:00
|
|
|
onSelect: x => setTheme(x) // setTheme
|
2020-06-23 02:06:40 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
title: 'Autosave',
|
2020-06-23 20:54:09 +02:00
|
|
|
value: autosave,
|
2020-06-23 02:06:40 +02:00
|
|
|
options: [
|
|
|
|
{
|
2020-06-23 20:54:09 +02:00
|
|
|
value: true, label: 'On', ariaLabel: 'autosave on', name: 'autosave', id: 'autosave-on'
|
2020-06-23 02:06:40 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-23 20:54:09 +02:00
|
|
|
value: false, label: 'Off', ariaLabel: 'autosave off', name: 'autosave', id: 'autosave-off'
|
2020-06-23 02:06:40 +02:00
|
|
|
},
|
|
|
|
],
|
2020-06-23 20:54:09 +02:00
|
|
|
onSelect: x => setAutosave(x) // setAutosave
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
title: 'Word Wrap',
|
|
|
|
value: linewrap,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
value: true, label: 'On', ariaLabel: 'linewrap on', name: 'linewrap', id: 'linewrap-on'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: false, label: 'Off', ariaLabel: 'linewrap off', name: 'linewrap', id: 'linewrap-off'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onSelect: x => setLinewrap(x)
|
2020-06-23 02:06:40 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2020-06-23 22:27:43 +02:00
|
|
|
const outputSettings = [
|
2020-06-23 22:15:59 +02:00
|
|
|
{
|
|
|
|
title: 'Plain-text',
|
|
|
|
value: textOutput,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
value: true, label: 'On', ariaLabel: 'text output on', name: 'text output', id: 'text-output-on'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: false, label: 'Off', ariaLabel: 'text output off', name: 'text output', id: 'text-output-off'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onSelect: x => setTextOutput(x)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Table-text',
|
|
|
|
value: gridOutput,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
value: true, label: 'On', ariaLabel: 'table output on', name: 'table output', id: 'table-output-on'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: false, label: 'Off', ariaLabel: 'table output off', name: 'table output', id: 'table-output-off'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onSelect: x => setGridOutput(x)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Sound',
|
|
|
|
value: soundOutput,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
value: true, label: 'On', ariaLabel: 'sound output on', name: 'sound output', id: 'sound-output-on'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: false, label: 'Off', ariaLabel: 'sound output off', name: 'sound output', id: 'sound-output-off'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onSelect: x => setSoundOutput(x)
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2020-06-23 22:27:43 +02:00
|
|
|
const accessibilitySettings = [
|
|
|
|
{
|
|
|
|
title: 'Line Numbers',
|
|
|
|
value: lineNumbers,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
value: true, label: 'On', ariaLabel: 'line numbers on', name: 'line numbers', id: 'line-numbers-on'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: false, label: 'Off', ariaLabel: 'line numbers off', name: 'line numbers', id: 'line-numbers-off'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onSelect: x => setLineNumbers(x)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Lint Warning Sound',
|
|
|
|
value: lintWarning,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
value: true, label: 'On', ariaLabel: 'lint warning on', name: 'lint warning', id: 'lint-warning-on'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: false, label: 'Off', ariaLabel: 'lint warning off', name: 'lint warning', id: 'lint-warning-off'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onSelect: x => setLintWarning(x)
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2020-06-23 02:06:40 +02:00
|
|
|
return (
|
2020-06-23 21:18:34 +02:00
|
|
|
<Screen fullscreen>
|
|
|
|
<section>
|
2020-07-01 00:17:05 +02:00
|
|
|
<SettingsHeader transparent title="Preferences">
|
2020-06-23 21:18:34 +02:00
|
|
|
|
2020-07-01 21:44:19 +02:00
|
|
|
<IconButton to="/mobile" icon={ExitIcon} aria-label="Return to ide view" />
|
2020-06-23 21:18:34 +02:00
|
|
|
</SettingsHeader>
|
|
|
|
<section className="preferences">
|
|
|
|
<Content>
|
2020-06-23 22:03:51 +02:00
|
|
|
<SectionHeader>General Settings</SectionHeader>
|
2020-06-30 21:52:03 +02:00
|
|
|
{ generalSettings.map(option => <PreferencePicker key={`${option.title}wrapper`} {...option} />) }
|
2020-06-23 22:03:51 +02:00
|
|
|
|
|
|
|
<SectionHeader>Accessibility</SectionHeader>
|
2020-06-30 21:52:03 +02:00
|
|
|
{ accessibilitySettings.map(option => <PreferencePicker key={`${option.title}wrapper`} {...option} />) }
|
2020-06-23 22:15:59 +02:00
|
|
|
|
2020-06-23 22:27:43 +02:00
|
|
|
<SectionHeader>Accessible Output</SectionHeader>
|
2020-07-01 00:11:48 +02:00
|
|
|
<SectionSubeader>Used with screen reader</SectionSubeader>
|
2020-06-30 21:52:03 +02:00
|
|
|
{ outputSettings.map(option => <PreferencePicker key={`${option.title}wrapper`} {...option} />) }
|
2020-06-23 22:27:43 +02:00
|
|
|
|
2020-06-23 21:18:34 +02:00
|
|
|
</Content>
|
|
|
|
</section>
|
2020-06-23 02:06:40 +02:00
|
|
|
</section>
|
|
|
|
</Screen>);
|
|
|
|
};
|
|
|
|
|
2020-06-23 22:27:43 +02:00
|
|
|
|
2020-06-23 02:06:40 +02:00
|
|
|
MobilePreferences.propTypes = {
|
|
|
|
fontSize: PropTypes.number.isRequired,
|
|
|
|
lineNumbers: PropTypes.bool.isRequired,
|
|
|
|
autosave: PropTypes.bool.isRequired,
|
|
|
|
linewrap: PropTypes.bool.isRequired,
|
|
|
|
textOutput: PropTypes.bool.isRequired,
|
|
|
|
gridOutput: PropTypes.bool.isRequired,
|
|
|
|
soundOutput: PropTypes.bool.isRequired,
|
|
|
|
lintWarning: PropTypes.bool.isRequired,
|
|
|
|
theme: PropTypes.string.isRequired,
|
|
|
|
|
|
|
|
setLinewrap: PropTypes.func.isRequired,
|
|
|
|
setLintWarning: PropTypes.func.isRequired,
|
|
|
|
setTheme: PropTypes.func.isRequired,
|
|
|
|
setFontSize: PropTypes.func.isRequired,
|
|
|
|
setLineNumbers: PropTypes.func.isRequired,
|
|
|
|
setAutosave: PropTypes.func.isRequired,
|
|
|
|
setTextOutput: PropTypes.func.isRequired,
|
|
|
|
setGridOutput: PropTypes.func.isRequired,
|
|
|
|
setSoundOutput: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2020-06-23 20:54:09 +02:00
|
|
|
...state.preferences,
|
2020-06-23 02:06:40 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => bindActionCreators({
|
|
|
|
...PreferencesActions,
|
|
|
|
...IdeActions
|
|
|
|
}, dispatch);
|
|
|
|
|
|
|
|
|
2020-06-23 20:54:09 +02:00
|
|
|
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(MobilePreferences));
|