Skip to content

Commit 013183c

Browse files
committed
feat: add NonFloatingButton component for enhanced user interaction
1 parent 6e4e3ab commit 013183c

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

src/NonFloatingButton.tsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
2+
import React from 'react';
3+
import Icon from './Icon';
4+
5+
const CLOSE_BUTTON_SIZE = 58;
6+
7+
interface NonFloatingButtonProps {
8+
openModal: () => void;
9+
hideIcon: () => void;
10+
logsLength: number;
11+
enableDeviceShake?: boolean;
12+
}
13+
14+
const NonFloatingButton: React.FunctionComponent<NonFloatingButtonProps> = ({
15+
hideIcon,
16+
logsLength,
17+
openModal,
18+
enableDeviceShake,
19+
}) => {
20+
return (
21+
<>
22+
{enableDeviceShake && (
23+
<View style={[styles.floatingCloseIcon]}>
24+
<TouchableOpacity onPress={hideIcon} style={styles.closeButton}>
25+
<Icon type="close" />
26+
</TouchableOpacity>
27+
</View>
28+
)}
29+
<View style={[styles.floatingButton]}>
30+
<TouchableOpacity onPress={openModal} activeOpacity={0.9}>
31+
<Text style={styles.floatingButtonText}>📊 {logsLength}</Text>
32+
</TouchableOpacity>
33+
</View>
34+
</>
35+
);
36+
};
37+
38+
const styles = StyleSheet.create({
39+
floatingButton: {
40+
position: 'absolute',
41+
bottom: 100,
42+
right: 20,
43+
backgroundColor: '#007AFF',
44+
padding: 16,
45+
borderRadius: 25,
46+
elevation: 1,
47+
shadowOffset: { width: 0, height: 2 },
48+
shadowOpacity: 0.3,
49+
shadowRadius: 4,
50+
zIndex: 1000,
51+
},
52+
floatingCloseIcon: {
53+
position: 'absolute',
54+
bottom: 150,
55+
right: 16,
56+
padding: 16,
57+
borderRadius: 25,
58+
zIndex: 1000,
59+
},
60+
floatingButtonText: {
61+
color: 'white',
62+
fontSize: 14,
63+
fontWeight: 'bold',
64+
},
65+
closeButton: {
66+
padding: 16,
67+
borderRadius: 70,
68+
width: CLOSE_BUTTON_SIZE,
69+
height: CLOSE_BUTTON_SIZE,
70+
justifyContent: 'center',
71+
alignItems: 'center',
72+
fontWeight: '900',
73+
},
74+
});
75+
76+
export default NonFloatingButton;

0 commit comments

Comments
 (0)