@quintype/native-components 2.30.1 → 2.30.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.30.1",
3
+ "version": "2.30.2",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -8,16 +8,34 @@ import { AppTheme } from '../../utils/context';
8
8
 
9
9
  export const Text = (props) => {
10
10
  const { theme } = useContext(AppTheme);
11
- const { FONT_FAMILY, COLORS, CAN_COPY_TEXT } = theme;
11
+ const {
12
+ FONT_FAMILY, COLORS, CAN_COPY_TEXT, lineHeightMultiplier,
13
+ } = theme;
14
+
15
+ // Flatten the style first
16
+ const flattenedStyle = StyleSheet.flatten([props.style]) || {};
17
+
18
+ // Use fontSize from style or fallback, and lineHeight from style or calculate
19
+ const { fontSize } = flattenedStyle;
20
+ let lineHeight;
21
+ if (flattenedStyle.lineHeight != null) {
22
+ lineHeight = flattenedStyle.lineHeight;
23
+ } else if (fontSize != null) {
24
+ lineHeight = fontSize * (lineHeightMultiplier ?? 1.5);
25
+ }
12
26
 
13
27
  const RNStyle = {
14
28
  fontFamily: props.primary ? FONT_FAMILY.primary : FONT_FAMILY.secondary,
15
29
  writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
30
+ ...(fontSize != null ? { fontSize } : {}),
31
+ ...(lineHeight != null ? { lineHeight } : {}),
16
32
  };
17
- const flattenedStyle = StyleSheet.flatten([RNStyle, props.style]);
18
33
 
19
- const { ellipsizeMode, numberOfLines, allowFontScaling, testID } = props;
34
+ const mergedStyle = StyleSheet.flatten([RNStyle, props.style]);
20
35
 
36
+ const {
37
+ ellipsizeMode, numberOfLines, allowFontScaling, testID,
38
+ } = props;
21
39
  const textData = I18nManager.isRTL ? `\u200F${props.children}` : props.children;
22
40
 
23
41
  return (
@@ -29,7 +47,7 @@ export const Text = (props) => {
29
47
  ellipsizeMode={ellipsizeMode}
30
48
  numberOfLines={numberOfLines}
31
49
  testID={testID}
32
- style={flattenedStyle}
50
+ style={mergedStyle}
33
51
  fontFamily={RNStyle.fontFamily}
34
52
  allowFontScaling={allowFontScaling}
35
53
  >