-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathblock.tsx
More file actions
49 lines (45 loc) · 1.13 KB
/
block.tsx
File metadata and controls
49 lines (45 loc) · 1.13 KB
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
/** @format */
import * as React from 'react'
import {
Animated,
StyleProp,
TouchableWithoutFeedback,
StyleSheet,
GestureResponderHandlers,
} from 'react-native'
import { FunctionComponent } from 'react'
interface BlockProps {
style?: StyleProp<any>
dragStartAnimationStyle: StyleProp<any>
onPress?: () => void
onLongPress: () => void
onLongPressOut: () => void
panHandlers: GestureResponderHandlers
delayLongPress: number
children?: React.ReactNode
}
export const Block: FunctionComponent<BlockProps> = ({
style,
dragStartAnimationStyle,
onPress,
onLongPress,
onLongPressOut,
children,
panHandlers,
delayLongPress
}) => {
return (
<Animated.View style={[styles.blockContainer, style, dragStartAnimationStyle]} {...panHandlers}>
<Animated.View>
<TouchableWithoutFeedback delayLongPress={delayLongPress} delayPressOut={100} onPress={onPress} onLongPress={onLongPress} onPressOut={onLongPressOut}>
{children}
</TouchableWithoutFeedback>
</Animated.View>
</Animated.View>
)
}
const styles = StyleSheet.create({
blockContainer: {
alignItems: 'center',
},
})