@popp0102/nova 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Button.js +32 -7
- package/package.json +1 -1
package/lib/components/Button.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { View, Text, Pressable, StyleSheet } from 'react-native';
|
|
2
|
+
import { MaterialIcons } from '@expo/vector-icons';
|
|
2
3
|
import { useDeviceSize } from '../utils/deviceSize';
|
|
3
4
|
|
|
4
5
|
const colors = {
|
|
@@ -31,10 +32,20 @@ const responsiveSizes = {
|
|
|
31
32
|
},
|
|
32
33
|
};
|
|
33
34
|
|
|
34
|
-
export default function Button({
|
|
35
|
+
export default function Button({
|
|
36
|
+
type = 'primary',
|
|
37
|
+
style,
|
|
38
|
+
onPress,
|
|
39
|
+
children,
|
|
40
|
+
leftIcon,
|
|
41
|
+
rightIcon,
|
|
42
|
+
iconColor
|
|
43
|
+
}) {
|
|
35
44
|
const buttonColors = colors[type];
|
|
36
45
|
const deviceSize = useDeviceSize();
|
|
37
46
|
const sizes = responsiveSizes[deviceSize];
|
|
47
|
+
const iconSize = sizes.fontSize * 1.4;
|
|
48
|
+
const finalIconColor = iconColor || buttonColors.text;
|
|
38
49
|
|
|
39
50
|
return (
|
|
40
51
|
<View style={[style]}>
|
|
@@ -49,12 +60,20 @@ export default function Button({ type = 'primary', style, onPress, children }) {
|
|
|
49
60
|
pressed && styles.pressed,
|
|
50
61
|
]}
|
|
51
62
|
>
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
<View style={styles.buttonContent}>
|
|
64
|
+
{leftIcon && (
|
|
65
|
+
<MaterialIcons name={leftIcon} size={iconSize} color={finalIconColor} />
|
|
66
|
+
)}
|
|
67
|
+
<Text
|
|
68
|
+
style={[styles.text, { color: buttonColors.text, fontSize: sizes.fontSize }]}
|
|
69
|
+
numberOfLines={1}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
</Text>
|
|
73
|
+
{rightIcon && (
|
|
74
|
+
<MaterialIcons name={rightIcon} size={iconSize} color={finalIconColor} />
|
|
75
|
+
)}
|
|
76
|
+
</View>
|
|
58
77
|
</Pressable>
|
|
59
78
|
</View>
|
|
60
79
|
);
|
|
@@ -69,6 +88,12 @@ const styles = StyleSheet.create({
|
|
|
69
88
|
shadowRadius: 1.0,
|
|
70
89
|
elevation: 2,
|
|
71
90
|
},
|
|
91
|
+
buttonContent: {
|
|
92
|
+
flexDirection: 'row',
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
justifyContent: 'center',
|
|
95
|
+
gap: 8,
|
|
96
|
+
},
|
|
72
97
|
text: {
|
|
73
98
|
textAlign: 'center',
|
|
74
99
|
},
|