@widergy/mobile-ui 1.16.2 → 1.16.3
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.16.3](https://github.com/widergy/mobile-ui/compare/v1.16.2...v1.16.3) (2024-08-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* android highlight for markdown links ([#329](https://github.com/widergy/mobile-ui/issues/329)) ([0b712dc](https://github.com/widergy/mobile-ui/commit/0b712dc2bd364fcff8229766daf788ba2f4a2796))
|
|
7
|
+
|
|
1
8
|
## [1.16.2](https://github.com/widergy/mobile-ui/compare/v1.16.1...v1.16.2) (2024-08-08)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import { Text } from 'react-native';
|
|
3
3
|
import Markdown from 'react-native-markdown-display';
|
|
4
4
|
|
|
@@ -25,29 +25,39 @@ const Label = ({
|
|
|
25
25
|
const textVariants = Object.keys(textStyles);
|
|
26
26
|
const customStyles = getCustomStyles(textVariants, props, textStyles);
|
|
27
27
|
|
|
28
|
+
const [pressed, setPressed] = useState(false);
|
|
29
|
+
|
|
28
30
|
const styles = formatStyles(
|
|
29
31
|
useMarkdown,
|
|
30
32
|
[textStyles.base, textStyles.fontColor, customStyles, style],
|
|
31
|
-
markdownStyles
|
|
33
|
+
markdownStyles,
|
|
34
|
+
pressed
|
|
32
35
|
);
|
|
33
36
|
|
|
34
37
|
const LabelRenderer = useMarkdown ? Markdown : Text;
|
|
35
38
|
|
|
36
|
-
const propsByComponent = useMemo(
|
|
37
|
-
() =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
const propsByComponent = useMemo(() => {
|
|
40
|
+
const handleLinkPress = () => {
|
|
41
|
+
setPressed(true);
|
|
42
|
+
onLinkPress?.();
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
setPressed(false);
|
|
45
|
+
}, 200);
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return useMarkdown
|
|
50
|
+
? {
|
|
51
|
+
mergeStyle: false,
|
|
52
|
+
onLinkPress: handleLinkPress,
|
|
53
|
+
children: markdownFormat(children)
|
|
54
|
+
}
|
|
55
|
+
: {
|
|
56
|
+
allowFontScaling: allowFontScaling ?? theme.allowFontScaling,
|
|
57
|
+
...textProps,
|
|
58
|
+
children
|
|
59
|
+
};
|
|
60
|
+
}, [allowFontScaling, children, onLinkPress, textProps, theme.allowFontScaling, useMarkdown]);
|
|
51
61
|
|
|
52
62
|
return <LabelRenderer style={styles} {...propsByComponent} {...props} />;
|
|
53
63
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
3
|
import { verticalScale, horizontalScale } from '../../utils/scaleUtils';
|
|
4
|
+
import { IS_ANDROID } from '../../utils/platformUtils/constants';
|
|
4
5
|
|
|
5
6
|
export const getTextStyles = (theme, color) =>
|
|
6
7
|
StyleSheet.create({
|
|
@@ -101,5 +102,9 @@ export const markdownStyles = StyleSheet.create({
|
|
|
101
102
|
ordered_list_icon: {
|
|
102
103
|
height: '100%',
|
|
103
104
|
paddingBottom: verticalScale(10)
|
|
104
|
-
}
|
|
105
|
+
},
|
|
106
|
+
link: pressed => ({
|
|
107
|
+
backgroundColor: IS_ANDROID && pressed ? 'lightgray' : 'transparent',
|
|
108
|
+
textDecorationLine: 'underline'
|
|
109
|
+
})
|
|
105
110
|
});
|
|
@@ -15,7 +15,7 @@ const flattenStyles = (obj = {}, styles) => {
|
|
|
15
15
|
return obj;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export const formatStyles = (useMarkdown, styles, newMarkdownStyles = {}) => {
|
|
18
|
+
export const formatStyles = (useMarkdown, styles, newMarkdownStyles = {}, pressed) => {
|
|
19
19
|
const { paragraph } = newMarkdownStyles;
|
|
20
20
|
|
|
21
21
|
const flattenedStyles = flattenStyles({}, styles);
|
|
@@ -27,7 +27,8 @@ export const formatStyles = (useMarkdown, styles, newMarkdownStyles = {}) => {
|
|
|
27
27
|
bullet_list_icon,
|
|
28
28
|
ordered_list,
|
|
29
29
|
ordered_list_content,
|
|
30
|
-
ordered_list_icon
|
|
30
|
+
ordered_list_icon,
|
|
31
|
+
link
|
|
31
32
|
} = markdownStyles;
|
|
32
33
|
|
|
33
34
|
const paragraphStyle = { ...flattenedStyles, ...paragraph };
|
|
@@ -41,6 +42,7 @@ export const formatStyles = (useMarkdown, styles, newMarkdownStyles = {}) => {
|
|
|
41
42
|
ordered_list,
|
|
42
43
|
ordered_list_content,
|
|
43
44
|
ordered_list_icon,
|
|
45
|
+
link: link(pressed),
|
|
44
46
|
...newMarkdownStyles,
|
|
45
47
|
paragraph: paragraphStyle
|
|
46
48
|
}
|
package/package.json
CHANGED