-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardScreen.jsx
116 lines (112 loc) · 2.78 KB
/
CardScreen.jsx
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
111
112
113
114
115
116
import React, { createRef, useState } from "react";
import { View, Text, SafeAreaView, StyleSheet } from "react-native";
import Swiper from "react-native-deck-swiper";
import { MaterialIcons } from "@expo/vector-icons";
import { MaterialCommunityIcons } from "@expo/vector-icons";
const data = [
{
id: 1,
color: "#97d2f0",
},
{
id: 2,
color: "#88f6ba",
},
{
id: 3,
color: "#f7d88c",
},
{
id: 4,
color: "#D48B65",
},
{
id: 5,
color: "#C45B63",
},
];
const CardPage = () => {
const [index, setIndex] = useState(0);
return (
<SafeAreaView style={styles.container}>
<View style={{ flex: 1, height: "100%", marginTop: 50 }}>
<Swiper
ref={createRef()}
cards={data}
cardIndex={index}
showSecondCard={true}
verticalSwipe={false}
stackSize={3}
stackAnimationFriction={15}
stackAnimationTension={40}
stackScale={5}
stackSeparation={22}
renderCard={(item) => (
<View style={[styles.card, { backgroundColor: item.color }]} />
)}
infinite
backgroundColor={"transparent"}
onSwiped={() => setIndex(index + 1)}
animateOverlayLabelsOpacity
animateCardOpacity
disableTopSwipe
disableBottomSwipe
overlayLabels={{
left: {
element: (
<MaterialCommunityIcons
name="close-circle"
size={70}
color="#D45E5C"
/>
),
style: {
wrapper: {
flexDirection: "column",
alignItems: "flex-end",
justifyContent: "flex-start",
marginTop: 5,
marginLeft: -5,
},
},
},
right: {
element: (
<MaterialIcons name="check-circle" size={70} color="#48AC87" />
),
style: {
wrapper: {
flexDirection: "column",
alignItems: "flex-start",
justifyContent: "flex-start",
marginTop: 5,
marginLeft: 5,
},
},
},
}}
overlayLabelStyle={{
overflow: "hidden",
backgroundColor: "transparent",
}}
/>
</View>
</SafeAreaView>
);
};
export default CardPage;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
},
card: {
justifyContent: "center",
alignItems: "center",
width: "100%",
borderRadius: 7.5,
shadowRadius: 20,
shadowOpacity: 0.1,
height: "85%",
},
});