-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
110 lines (102 loc) · 2.57 KB
/
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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* Generated with the TypeScript template
* https://github.com/react-native-community/react-native-template-typescript
*
* @format
*/
import React, {useState, useEffect} from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
Text,
View,
PanResponder,
PanResponderStatic,
} from 'react-native';
import Colors from './theme/colors';
import {iDie} from './types/types';
import DiceView from './components/DiceView';
const App = () => {
const [instructionMode, setInstructionMode] = useState<boolean>(false);
const [outsideTarget, setOutsideTarget] = useState<boolean>(true);
const [currentInstruction, setCurrentInstruction] = useState<string>(
'Click any element on screen to learn more.',
);
const panResponder = React.useMemo(
() =>
PanResponder.create({
onStartShouldSetPanResponder: () => {
return true;
},
onPanResponderGrant: () => {
setOutsideTarget(true);
return true;
},
onPanResponderTerminationRequest: () => {
return true;
},
}),
[],
);
const setOutsideTargetFunc = () => {
setOutsideTarget(false);
};
return (
<View
style={styles.appContainer}
{...(panResponder ? panResponder.panHandlers : {})}>
<SafeAreaView
style={styles.appContainer}
{...(panResponder ? panResponder.panHandlers : {})}>
{instructionMode && (
<View style={styles.instructionContainer}>
<Text style={styles.instructionContainerText}>
{currentInstruction}
</Text>
</View>
)}
<DiceView
setInstructionMode={setInstructionMode}
instructionMode={instructionMode}
setCurrentInstruction={setCurrentInstruction}
setOutsideTargetFunc={setOutsideTargetFunc}
outsideTarget={outsideTarget}
/>
</SafeAreaView>
</View>
);
};
const styles = StyleSheet.create({
appContainer: {
flex: 1,
flexDirection: 'column',
backgroundColor: Colors.light,
},
instructionContainer: {
backgroundColor: Colors.dark,
padding: 10,
minHeight: 80,
justifyContent: 'center',
},
instructionContainerText: {
color: Colors.light,
fontSize: 15,
fontWeight: '600',
},
scrollViewWrapper: {
flex: 1,
backgroundColor: Colors.light,
},
scrollView: {
padding: 10,
flex: 1,
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
},
});
export default App;