@popp0102/nova 0.9.6 → 0.10.0
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Text } from "react-native";
|
|
2
2
|
import { sizes, styles } from './config';
|
|
3
3
|
|
|
4
|
-
export default function Heading({ children, color = 'black', size = 'h4', fontFamily, textAlign = 'left' }) {
|
|
4
|
+
export default function Heading({ children, color = 'black', size = 'h4', fontFamily, textAlign = 'left', numberOfLines, ellipsizeMode = 'tail' }) {
|
|
5
5
|
const fontSize = sizes[size] || sizes.h4;
|
|
6
6
|
const fontWeight = fontFamily ? 'normal' : 'bold';
|
|
7
7
|
|
|
@@ -11,7 +11,11 @@ export default function Heading({ children, color = 'black', size = 'h4', fontFa
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<Text
|
|
14
|
+
<Text
|
|
15
|
+
style={[styles.heading, dynamicStyle]}
|
|
16
|
+
numberOfLines={numberOfLines}
|
|
17
|
+
ellipsizeMode={ellipsizeMode}
|
|
18
|
+
>
|
|
15
19
|
{children}
|
|
16
20
|
</Text>
|
|
17
21
|
);
|
|
@@ -7,19 +7,31 @@ export const styles = StyleSheet.create({
|
|
|
7
7
|
width: "100%",
|
|
8
8
|
},
|
|
9
9
|
topRow: {
|
|
10
|
-
|
|
11
|
-
alignItems: "center",
|
|
10
|
+
position: 'relative',
|
|
12
11
|
width: "100%",
|
|
12
|
+
minHeight: 48,
|
|
13
|
+
justifyContent: 'center',
|
|
13
14
|
},
|
|
14
15
|
backButton: {
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
left: 0,
|
|
18
|
+
top: 0,
|
|
19
|
+
bottom: 0,
|
|
15
20
|
width: 48,
|
|
21
|
+
justifyContent: 'center',
|
|
16
22
|
},
|
|
17
23
|
titleContainer: {
|
|
18
|
-
|
|
24
|
+
width: "100%",
|
|
25
|
+
paddingLeft: 48,
|
|
26
|
+
paddingRight: 40,
|
|
19
27
|
alignItems: 'center',
|
|
20
28
|
},
|
|
21
29
|
rightContent: {
|
|
22
|
-
|
|
30
|
+
position: 'absolute',
|
|
31
|
+
right: 0,
|
|
32
|
+
top: 0,
|
|
33
|
+
bottom: 0,
|
|
23
34
|
alignItems: "flex-end",
|
|
35
|
+
justifyContent: 'center',
|
|
24
36
|
},
|
|
25
37
|
});
|
|
@@ -6,31 +6,77 @@ import { styles } from './config';
|
|
|
6
6
|
|
|
7
7
|
export default function ScreenHeader({
|
|
8
8
|
title,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
leftIcon,
|
|
10
|
+
rightIcon,
|
|
11
11
|
titleFontFamily,
|
|
12
|
-
titleColor = "#4A2C0A"
|
|
13
|
-
backIconColor = "#4A2C0A"
|
|
12
|
+
titleColor = "#4A2C0A"
|
|
14
13
|
}) {
|
|
15
14
|
const deviceSize = useDeviceSize();
|
|
16
|
-
const titleSize = deviceSize === 'small' ? '
|
|
15
|
+
const titleSize = deviceSize === 'small' ? 'h4' : 'h3';
|
|
16
|
+
|
|
17
|
+
const leftIconColor = leftIcon?.color || "#4A2C0A";
|
|
18
|
+
const leftIconName = leftIcon?.name || "arrow-back";
|
|
19
|
+
const onLeftIconPress = leftIcon?.onSelect;
|
|
20
|
+
|
|
21
|
+
const rightIconColor = rightIcon?.color || "#4A2C0A";
|
|
22
|
+
const rightIconName = rightIcon?.name;
|
|
23
|
+
const onRightIconPress = rightIcon?.onSelect;
|
|
24
|
+
|
|
25
|
+
const renderLeftIcon = () => {
|
|
26
|
+
if (!leftIcon) return null;
|
|
27
|
+
|
|
28
|
+
const icon = <MaterialIcons name={leftIconName} size={32} color={leftIconColor} />;
|
|
29
|
+
|
|
30
|
+
if (onLeftIconPress) {
|
|
31
|
+
return (
|
|
32
|
+
<Pressable onPress={onLeftIconPress} style={styles.backButton} testID="screen-header-left-icon">
|
|
33
|
+
{icon}
|
|
34
|
+
</Pressable>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<View style={styles.backButton} testID="screen-header-left-icon">
|
|
40
|
+
{icon}
|
|
41
|
+
</View>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const renderRightIcon = () => {
|
|
46
|
+
if (!rightIconName) return null;
|
|
47
|
+
|
|
48
|
+
const icon = <MaterialIcons name={rightIconName} size={28} color={rightIconColor} />;
|
|
49
|
+
|
|
50
|
+
if (onRightIconPress) {
|
|
51
|
+
return (
|
|
52
|
+
<Pressable onPress={onRightIconPress} style={styles.rightContent} testID="screen-header-right-icon">
|
|
53
|
+
{icon}
|
|
54
|
+
</Pressable>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<View style={styles.rightContent} testID="screen-header-right-icon">
|
|
60
|
+
{icon}
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
17
64
|
|
|
18
65
|
return (
|
|
19
66
|
<View style={styles.header}>
|
|
20
67
|
<View style={styles.topRow}>
|
|
21
|
-
{
|
|
22
|
-
<Pressable onPress={onBack} style={styles.backButton} testID="screen-header-back-button">
|
|
23
|
-
<MaterialIcons name="arrow-back" size={32} color={backIconColor} />
|
|
24
|
-
</Pressable>
|
|
25
|
-
)}
|
|
68
|
+
{renderLeftIcon()}
|
|
26
69
|
<View style={styles.titleContainer}>
|
|
27
|
-
<Heading
|
|
70
|
+
<Heading
|
|
71
|
+
size={titleSize}
|
|
72
|
+
fontFamily={titleFontFamily}
|
|
73
|
+
color={titleColor}
|
|
74
|
+
numberOfLines={1}
|
|
75
|
+
>
|
|
76
|
+
{title}
|
|
77
|
+
</Heading>
|
|
28
78
|
</View>
|
|
29
|
-
{
|
|
30
|
-
<View style={styles.rightContent}>
|
|
31
|
-
{rightContent}
|
|
32
|
-
</View>
|
|
33
|
-
)}
|
|
79
|
+
{renderRightIcon()}
|
|
34
80
|
</View>
|
|
35
81
|
</View>
|
|
36
82
|
);
|