Skip to content

Commit b84c8bc

Browse files
committed
Add auto next with timeout
1 parent 669f30e commit b84c8bc

5 files changed

Lines changed: 24 additions & 14 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const DEFAULT_COUNTRY_CODE = 'DE';
2-
export const AUTO_NEXT_ENABLED = false;
2+
export const AUTO_NEXT_ENABLED = true;
3+
export const AUTO_NEXT_TIMEOUT = 200;
34
export const APP_NAME = "cotect"
45
export const OFFLINE_MODE_ENABLED = true;

app/mobile/screens/steps/CovidContactStep.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {RadioButton, Text, TouchableRipple} from 'react-native-paper';
1010

1111
import StepContainer from './StepContainer';
1212

13-
import {AUTO_NEXT_ENABLED} from '../../constants/Configuration';
13+
import {AUTO_NEXT_ENABLED, AUTO_NEXT_TIMEOUT} from '../../constants/Configuration';
1414

1515
const styles = StyleSheet.create({
1616
radioButtonItem: {
@@ -26,14 +26,16 @@ export default function CovidContactStep(props) {
2626
{key: 'true', value: t('basics.yes')},
2727
{key: 'false', value: t('basics.no')},
2828
];
29-
29+
3030
const [selection, setSelection] = useState(props.caseReport.covid_contact !== undefined && props.caseReport.covid_contact !== null ? String(props.caseReport.covid_contact) : undefined);
3131

3232
const onSelect = item => {
3333
setSelection(item);
3434
if (AUTO_NEXT_ENABLED) {
35-
// onNext is triggers faster then the state change?
36-
props.onNext(getStateToBeSaved(item));
35+
setTimeout(() => {
36+
// onNext is triggers faster then the state change?
37+
props.onNext(getStateToBeSaved(item));
38+
}, AUTO_NEXT_TIMEOUT);
3739
}
3840
};
3941

app/mobile/screens/steps/CovidTestedStep.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {RadioButton, Text, TouchableRipple} from 'react-native-paper';
1010

1111
import {CaseReport} from '../../client/cotect-backend/index';
1212

13-
import {AUTO_NEXT_ENABLED} from '../../constants/Configuration';
13+
import {AUTO_NEXT_ENABLED, AUTO_NEXT_TIMEOUT} from '../../constants/Configuration';
1414

1515
import StepContainer from './StepContainer';
1616

@@ -46,8 +46,10 @@ export default function CovidTestedStep(props) {
4646
setSelection(item);
4747

4848
if (AUTO_NEXT_ENABLED) {
49-
// onNext is triggered faster then the state change?
50-
props.onNext(getStateToBeSaved(item));
49+
setTimeout(() => {
50+
// onNext is triggered faster then the state change?
51+
props.onNext(getStateToBeSaved(item));
52+
}, AUTO_NEXT_TIMEOUT);
5153
}
5254
};
5355

app/mobile/screens/steps/GenderStep.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {CaseReport} from '../../client/cotect-backend/index';
1212

1313
import StepContainer from './StepContainer';
1414

15-
import {AUTO_NEXT_ENABLED} from '../../constants/Configuration';
15+
import {AUTO_NEXT_ENABLED, AUTO_NEXT_TIMEOUT} from '../../constants/Configuration';
1616

1717
const styles = StyleSheet.create({
1818
radioButtonItem: {
@@ -34,8 +34,10 @@ export default function GenderStep(props) {
3434
const onSelect = item => {
3535
setSelection(item);
3636
if (AUTO_NEXT_ENABLED) {
37-
// onNext is triggered faster then the state change?
38-
props.onNext(getStateToBeSaved(item));
37+
setTimeout(() => {
38+
// onNext is triggered faster then the state change?
39+
props.onNext(getStateToBeSaved(item));
40+
}, AUTO_NEXT_TIMEOUT);
3941
}
4042
};
4143

app/mobile/screens/steps/SymptomsDateStep.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {format, subDays, parseISO} from 'date-fns';
1414

1515
import {CALENDAR_THEME} from '../../constants/DefaultStyles';
1616

17-
import {AUTO_NEXT_ENABLED} from '../../constants/Configuration';
17+
import {AUTO_NEXT_ENABLED, AUTO_NEXT_TIMEOUT} from '../../constants/Configuration';
1818

1919
const styles = StyleSheet.create({});
2020

@@ -80,8 +80,11 @@ export default function SymptomsDateStep(props) {
8080
setSelectedDate(date);
8181
setMarkedDate(newMarkedDate);
8282
if (AUTO_NEXT_ENABLED) {
83-
// jump to next step
84-
props.onNext(getStateToBeSaved(date));
83+
setTimeout(() => {
84+
// jump to next step
85+
props.onNext(getStateToBeSaved(date));
86+
}, AUTO_NEXT_TIMEOUT);
87+
8588
}
8689
}
8790
};

0 commit comments

Comments
 (0)