-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
37 lines (32 loc) · 964 Bytes
/
App.tsx
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
import { StyleSheet, View, StatusBar } from 'react-native';
import { Dealer } from './components/Dealer';
import { Navbar } from './components/Navbar';
import { useReducer } from 'react';
const useForceRestart = () => {
return useReducer(key => key + 1, 0)
}
const useSpeed = () => {
const SPEEDS = [3000, 2000, 1500, 1000, 800, 1]
return useReducer(speed => {
const index = SPEEDS.indexOf(speed)
return SPEEDS[(index + 1) % SPEEDS.length]
}, SPEEDS[0])
}
export default function App() {
const [dealerKey, forceRestart] = useForceRestart()
const [speed, changeSpeed] = useSpeed()
return (
<View style={styles.container}>
<Navbar speed={speed} onRestart={forceRestart} onSpeed={changeSpeed} />
<Dealer key={dealerKey} speed={speed} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'stretch',
paddingTop: StatusBar.currentHeight
},
});