-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
41 lines (34 loc) · 1.01 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
import React from 'react'
import { Button, StyleSheet, View } from 'react-native'
import TouchBlocker from './src'
const App: React.FC = () => {
const [touchEnabled, setTouchEnabled] = React.useState(true)
const [background, setBackground] = React.useState('#FFFFFF')
const toggleTouch = (): void => {
setTouchEnabled((value) => !value)
}
const changeBackground = (): void => {
setBackground(randomColor())
}
return (
<View style={[Styles.container, { backgroundColor: background }]}>
<Button
title={touchEnabled ? 'Disable Touch' : 'Enable Touch'}
onPress={toggleTouch}
/>
<TouchBlocker enableTouchEvents={touchEnabled}>
<Button title='Change background' onPress={changeBackground} />
</TouchBlocker>
</View>
)
}
const randomColor = (): string =>
`#${Math.floor(Math.random() * 16777215).toString(16)}`
const Styles = StyleSheet.create({
container: {
flex: 1,
height: '100%',
justifyContent: 'center'
}
})
export default App