-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
77 lines (69 loc) · 1.56 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
/**
* 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, {useCallback, VFC} from 'react';
import {
ScrollView,
StyleSheet,
TouchableOpacity,
useColorScheme,
View,
} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
const row = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
type RowProps = {
prefix: number;
};
let blurTimeStamp: number = 0;
const Row: VFC<RowProps> = props => {
const onFocus = useCallback(() => {
console.log(`test: onFocus: diff: ${Date.now() - blurTimeStamp}`);
}, []);
const onBlur = useCallback(() => {
console.log('test: onBlur');
blurTimeStamp = Date.now();
}, []);
return (
<View style={styles.row}>
{row.map(key => (
<TouchableOpacity
key={`${props.prefix}-${key}`}
style={styles.touchable}
onFocus={onFocus}
onBlur={onBlur}
/>
))}
</View>
);
};
const App = () => {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
return (
<ScrollView style={backgroundStyle}>
{row.map(key => (
<Row key={key} prefix={key} />
))}
</ScrollView>
);
};
const styles = StyleSheet.create({
touchable: {
width: 50,
height: 50,
backgroundColor: 'red',
margin: 10,
},
row: {
flexDirection: 'row',
},
});
export default App;