Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE #1326 — Added vibration and delay functionality #1465

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/Board/Board.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { DISPLAY_SIZE_GRID_COLS } from '../Settings/Display/Display.constants';
import NavigationButtons from '../NavigationButtons';
import EditGridButtons from '../EditGridButtons';
import { DEFAULT_ROWS_NUMBER, DEFAULT_COLUMNS_NUMBER } from './Board.constants';
import Navigation from '../Settings/Navigation/Navigation.component.js';

import { Link } from 'react-router-dom';

Expand Down Expand Up @@ -144,7 +145,14 @@ export class Board extends Component {
: 'boardContainerRef';
this[boardComponentRef].current.scrollTop = 0;
}
onTileClick(tile);
if (Navigation.vibrationMode) {
navigator.vibrate(200);
}
if (Navigation.delayMode) {
setTimeout(onTileClick(tile), 200);
} else {
onTileClick(tile);
}
};

handleTileFocus = tileId => {
Expand Down
54 changes: 54 additions & 0 deletions src/components/Settings/Navigation/Navigation.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ class Navigation extends React.Component {
});
};

toggleVibration = () => {
this.setState({
vibrationMode: !this.state.vibrationMode
});
};

toggleDelay = () => {
this.setState({
delayMode: !this.state.delayMode
});
};

onSubmit = () => {
const { isLiveMode, changeLiveMode } = this.props;
if (!this.state.liveMode && isLiveMode) {
Expand Down Expand Up @@ -289,6 +301,48 @@ class Navigation extends React.Component {
/>
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ResetToursItem />
<Divider />
<ListItem>
<ListItemText
className="Display__ListItemText"
primary={<FormattedMessage {...messages.showVibrationMode} />}
secondary={
<FormattedMessage
{...messages.showVibrationModeSecondary}
/>
}
/>
<ListItemSecondaryAction>
<Switch
checked={this.state.vibrationMode || false}
onChange={this.toggleVibration}
value="active"
color="secondary"
/>
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ResetToursItem />
<Divider />
<ListItem>
<ListItemText
className="Display__ListItemText"
primary={<FormattedMessage {...messages.showDelayMode} />}
secondary={
<FormattedMessage {...messages.showDelayModeSecondary} />
}
/>
<ListItemSecondaryAction>
<Switch
checked={this.state.delayMode || false}
onChange={this.toggleDelay}
value="active"
color="secondary"
/>
</ListItemSecondaryAction>
</ListItem>
</List>
</Paper>
</FullScreenDialog>
Expand Down
18 changes: 18 additions & 0 deletions src/components/Settings/Navigation/Navigation.messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ export default defineMessages({
defaultMessage:
'Live mode allows you to write text directly into the output bar and quickly play the sound. It is intended for users that can write.'
},
showVibrationMode: {
id: 'cboard.components.Settings.Navigation.showVibrationMode',
defaultMessage: 'Vibration Mode'
},
showVibrationModeSecondary: {
id: 'cboard.components.Settings.Navigation.showVibrationModeSecondary',
defaultMessage:
"Vibration mode makes your device vibrate whenever a tile is pressed, allowing for feedback once you've pressed a tile."
},
showDelayMode: {
id: 'cboard.components.Settings.Navigation.showVibrationMode',
defaultMessage: 'Turn on delay'
},
showDelayModeSecondary: {
id: 'cboard.components.Settings.Navigation.showVibrationModeSecondary',
defaultMessage:
'Delay mode disallows new tile presses while a tile is speaking'
},
bigScroll: {
id: 'cboard.components.Settings.Navigation.bigScroll',
defaultMessage: 'Enable big scroll buttons'
Expand Down