-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
71 lines (61 loc) · 1.78 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { ScreenOrientation, Speech } from 'expo';
import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import CountDown from 'react-native-countdown-component';
export default class App extends Component {
speechOptions = {
language: "de_DE",
rate: 1,
}
speechOptionsSlow = Object.assign({}, this.speechOptions, {
rate: 0.1,
})
state = {
play: true,
time: 17,
}
componentDidMount() {
Speech.stop();
ScreenOrientation.allowAsync(ScreenOrientation.Orientation.ALL_BUT_UPSIDE_DOWN);
}
tellTime = (seconds) => {
// gets wrong seconds as input... subtract 1
seconds = seconds - 1;
timesToTell = [1, 2, 3, 4, 5, 10, 15, 30, 45];
minutes = seconds / 60;
hours = minutes / 60;
if (timesToTell.includes(seconds)) {
Speech.speak(seconds + "", this.speechOptions);
} else if (timesToTell.includes(minutes)) {
console.log("minutes");
Speech.speak(minutes + " Minute" + ((minutes == 1) ? "" : "n"), this.speechOptions);
} else if (timesToTell.includes(hours)) {
Speech.speak(hours + " Stunde" + ((hours == 1) ? "" : "n"), this.speechOptions);
}
}
render() {
var { play, time } = this.state;
return (
<View style={styles.container}>
<CountDown
until={time}
running={play}
onFinish={() => Speech.speak("biep, biep, biep", this.speechOptionsSlow)}
onPress={() => this.state.play = !this.state.play}
onChange={this.tellTime}
size={40}
showSeparator={false}
timeToShow={['H', 'M', 'S']}
/>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});