-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbutton.js
98 lines (88 loc) · 2.36 KB
/
button.js
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
import React, { useState} from "react";
import { View, TouchableOpacity, StyleSheet, Animated } from "react-native";
import Icon from "react-native-vector-icons/FontAwesome";
const FloatingButton = () => {
const [icon_1] = useState(new Animated.Value(40));
const [icon_2] = useState(new Animated.Value(40));
const [icon_3] = useState(new Animated.Value(40));
const [pop, setPop] = useState(false);
const popIn = () => {
setPop(true);
Animated.timing(icon_1, {
toValue: 130,
duration: 500,
useNativeDriver: false,
}).start();
Animated.timing(icon_2, {
toValue: 110,
duration: 500,
useNativeDriver: false,
}).start();
Animated.timing(icon_3, {
toValue: 130,
duration: 500,
useNativeDriver: false,
}).start();
}
const popOut = () => {
setPop(false);
Animated.timing(icon_1, {
toValue: 40,
duration: 500,
useNativeDriver: false,
}).start();
Animated.timing(icon_2, {
toValue: 40,
duration: 500,
useNativeDriver: false,
}).start();
Animated.timing(icon_3, {
toValue: 40,
duration: 500,
useNativeDriver: false,
}).start();
}
return(
<View style={{
flex: 1
}}>
<Animated.View style={[styles.circle, { bottom: icon_1}]}>
<TouchableOpacity>
<Icon name="cloud-upload" size={25} color="#FFFF" />
</TouchableOpacity>
</Animated.View>
<Animated.View style={[styles.circle, { bottom: icon_2, right: icon_2}]}>
<TouchableOpacity>
<Icon name="print" size={25} color="#FFFF" />
</TouchableOpacity>
</Animated.View>
<Animated.View style={[styles.circle, { right: icon_3}]}>
<TouchableOpacity>
<Icon name="share-alt" size={25} color="#FFFF" />
</TouchableOpacity>
</Animated.View>
<TouchableOpacity
style={styles.circle}
onPress={() => {
pop === false ? popIn() : popOut();
}}
>
<Icon name="plus" size={25} color="#FFFF" />
</TouchableOpacity>
</View>
)
}
export default FloatingButton;
const styles = StyleSheet.create({
circle: {
backgroundColor: '#f52d56',
width: 60,
height: 60,
position: 'absolute',
bottom: 40,
right: 40,
borderRadius: 50,
justifyContent: 'center',
alignItems: 'center',
}
})