forked from BeingBharat/BSBOceanProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeScreen.js
More file actions
72 lines (61 loc) · 1.54 KB
/
Copy pathHomeScreen.js
File metadata and controls
72 lines (61 loc) · 1.54 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React, { useEffect, useRef } from 'react';
import { View, Text, PanResponder, Animated, Dimensions, StyleSheet } from 'react-native';
const Home = () => {
const pan = useRef(new Animated.ValueXY()).current;
const panResponder = useRef(
PanResponder.create({
onStartShouldSetPanResponder: () => true,
onPanResponderGrant: () => {
pan.setOffset({
x: pan.x._value,
y: pan.y._value
});
pan.setValue({ x: 0, y: 0 });
},
onPanResponderMove: (evt, gestureState) => {
pan.setValue({ x: gestureState.dx, y: gestureState.dy });
},
onPanResponderRelease: (evt, gestureState) => {
pan.flattenOffset();
}
})
).current;
return (
<View style={styles.container}>
<Animated.View
style={[styles.card,{
transform: [{translateX: pan.x}, {translateY: pan.y}],
}]}
{...panResponder.panHandlers}
>
<Text style={styles.text}>Swipe me!</Text>
</Animated.View>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
card: {
width: 200,
height: 200,
backgroundColor: '#FE474C',
borderRadius: 200,
justifyContent: 'center',
alignItems: 'center',
shadowColor: 'black',
shadowOffset: { width: 0, height: 2 },
shadowRadius: 6,
shadowOpacity: 0.3,
elevation: 2
},
text: {
fontSize: 20,
color: 'white',
fontWeight: 'bold'
}
});
export default Home;