@quintype/native-components 2.19.28 → 2.19.29-ui-toggles.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.
- package/package.json +1 -1
- package/src/components/CollectionCard/index.js +6 -1
- package/src/components/CollectionCardNew/index.js +5 -1
- package/src/components/PrimaryStoryCard/index.js +37 -31
- package/src/components/PrimaryStoryCardNew/index.js +7 -2
- package/src/components/SecondaryStoryCard/index.js +39 -37
- package/src/components/SecondaryStoryCardNew/index.js +36 -31
- package/src/components/ShareButton/index.js +17 -16
package/package.json
CHANGED
|
@@ -17,17 +17,21 @@ export const CollectionCard = ({
|
|
|
17
17
|
onStoryPress,
|
|
18
18
|
offset,
|
|
19
19
|
horizontalPadding,
|
|
20
|
-
initialOffset /* Number of items to load on first load
|
|
20
|
+
initialOffset, /* Number of items to load on first load */
|
|
21
|
+
hideCollectionTitle,
|
|
21
22
|
}) => {
|
|
22
23
|
const sliceLimit = offset || initialOffset || 5;
|
|
23
24
|
const primaryStory = !isEmpty(stories) && get(stories, [0, 'story'], stories[0]);
|
|
24
25
|
return (
|
|
25
26
|
<>
|
|
27
|
+
{!hideCollectionTitle
|
|
28
|
+
&& (
|
|
26
29
|
<CollectionTitle
|
|
27
30
|
title={collectionName}
|
|
28
31
|
onPress={onCollectionPress}
|
|
29
32
|
horizontalPadding={horizontalPadding}
|
|
30
33
|
/>
|
|
34
|
+
)}
|
|
31
35
|
<PrimaryStoryCard
|
|
32
36
|
onPress={() => {
|
|
33
37
|
!isEmpty(stories) && onStoryPress(primaryStory);
|
|
@@ -62,6 +66,7 @@ CollectionCard.propTypes = {
|
|
|
62
66
|
onStoryPress: PropTypes.func,
|
|
63
67
|
offset: PropTypes.number,
|
|
64
68
|
horizontalPadding: PropTypes.number,
|
|
69
|
+
hideCollectionTitle: PropTypes.bool,
|
|
65
70
|
};
|
|
66
71
|
|
|
67
72
|
CollectionCard.defaultProps = {
|
|
@@ -19,18 +19,21 @@ const CollectionCardNewBase = ({
|
|
|
19
19
|
collectionTestID,
|
|
20
20
|
offset,
|
|
21
21
|
horizontalPadding,
|
|
22
|
-
initialOffset /* Number of items to load on first load
|
|
22
|
+
initialOffset, /* Number of items to load on first load */
|
|
23
|
+
hideCollectionTitle,
|
|
23
24
|
}) => {
|
|
24
25
|
const sliceLimit = offset || initialOffset || 5;
|
|
25
26
|
const primaryStory = !isEmpty(stories) && get(stories, [0, 'story'], stories[0]);
|
|
26
27
|
|
|
27
28
|
return (
|
|
28
29
|
<>
|
|
30
|
+
{!hideCollectionTitle && (
|
|
29
31
|
<CollectionTitleNew
|
|
30
32
|
title={collectionName}
|
|
31
33
|
onPress={onCollectionPress}
|
|
32
34
|
horizontalPadding={horizontalPadding}
|
|
33
35
|
/>
|
|
36
|
+
)}
|
|
34
37
|
<PrimaryStoryCardNew
|
|
35
38
|
collectionTestID={collectionTestID}
|
|
36
39
|
onPress={() => {
|
|
@@ -71,6 +74,7 @@ CollectionCardNewBase.propTypes = {
|
|
|
71
74
|
onStoryPress: PropTypes.func,
|
|
72
75
|
collectionTestID: PropTypes.string,
|
|
73
76
|
horizontalPadding: PropTypes.number,
|
|
77
|
+
hideCollectionTitle: PropTypes.bool,
|
|
74
78
|
};
|
|
75
79
|
|
|
76
80
|
CollectionCardNewBase.defaultProps = {
|
|
@@ -1,32 +1,38 @@
|
|
|
1
|
-
import { throttle } from
|
|
2
|
-
import get from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import React, { useContext } from
|
|
5
|
-
import { StyleSheet, TouchableOpacity, View } from
|
|
6
|
-
import Icon from
|
|
1
|
+
import { throttle } from 'lodash';
|
|
2
|
+
import get from 'lodash/get';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React, { useContext } from 'react';
|
|
5
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
6
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
7
7
|
import {
|
|
8
8
|
AppTheme,
|
|
9
9
|
getImageMetadata,
|
|
10
10
|
getImageSlug,
|
|
11
11
|
getTimeForStoryCards,
|
|
12
|
-
} from
|
|
13
|
-
import { getStoryHeadline } from
|
|
14
|
-
import { ResponsiveImage, Text } from
|
|
15
|
-
import { storyStyles } from
|
|
12
|
+
} from '../../utils';
|
|
13
|
+
import { getStoryHeadline } from '../../utils/story';
|
|
14
|
+
import { ResponsiveImage, Text } from '../index';
|
|
15
|
+
import { storyStyles } from './styles';
|
|
16
16
|
import {
|
|
17
17
|
COMP_GENERAL_CONSTANTS,
|
|
18
18
|
COMP_CONTENT_CONSTANTS,
|
|
19
|
-
} from
|
|
19
|
+
} from '../../constants/component-constants';
|
|
20
20
|
|
|
21
21
|
export const PrimaryStoryCard = (props) => {
|
|
22
22
|
const { story = {} } = props;
|
|
23
23
|
const { theme } = useContext(AppTheme);
|
|
24
24
|
|
|
25
|
-
const translate = get(theme, [
|
|
25
|
+
const translate = get(theme, ['translate'], (word) => word);
|
|
26
26
|
|
|
27
|
-
const {
|
|
27
|
+
const {
|
|
28
|
+
COLORS,
|
|
29
|
+
FONT_SIZE,
|
|
30
|
+
locale,
|
|
31
|
+
reverseTimeAdverbPosition,
|
|
32
|
+
enableReadTimeOnStoryCards,
|
|
33
|
+
} = theme || {};
|
|
28
34
|
|
|
29
|
-
const DATE_FORMAT =
|
|
35
|
+
const DATE_FORMAT = 'd MMM, yyyy';
|
|
30
36
|
|
|
31
37
|
const styles = storyStyles(COLORS, FONT_SIZE);
|
|
32
38
|
const containerStyle = StyleSheet.flatten([
|
|
@@ -42,11 +48,11 @@ export const PrimaryStoryCard = (props) => {
|
|
|
42
48
|
props.authorTextStyle,
|
|
43
49
|
]);
|
|
44
50
|
|
|
45
|
-
const name = get(story.authors, [0,
|
|
46
|
-
const authorName = name ? `${translate(
|
|
47
|
-
const readTime = story[
|
|
48
|
-
? `${story[
|
|
49
|
-
:
|
|
51
|
+
const name = get(story.authors, [0, 'name']);
|
|
52
|
+
const authorName = name ? `${translate('By')} ${name} | ` : '';
|
|
53
|
+
const readTime = enableReadTimeOnStoryCards && story['read-time']
|
|
54
|
+
? `${story['read-time']} ${translate('min read')}`
|
|
55
|
+
: '';
|
|
50
56
|
|
|
51
57
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
52
58
|
|
|
@@ -63,14 +69,14 @@ export const PrimaryStoryCard = (props) => {
|
|
|
63
69
|
</View>
|
|
64
70
|
);
|
|
65
71
|
const showStoryType = () => {
|
|
66
|
-
switch (story[
|
|
67
|
-
case
|
|
72
|
+
switch (story['story-template']) {
|
|
73
|
+
case 'text':
|
|
68
74
|
return null;
|
|
69
|
-
case
|
|
70
|
-
return showIcon(
|
|
71
|
-
case
|
|
72
|
-
return showIcon(
|
|
73
|
-
case
|
|
75
|
+
case 'photo':
|
|
76
|
+
return showIcon('photo');
|
|
77
|
+
case 'video':
|
|
78
|
+
return showIcon('play');
|
|
79
|
+
case 'live-blog':
|
|
74
80
|
return showLiveBlogIcon();
|
|
75
81
|
default:
|
|
76
82
|
null;
|
|
@@ -105,13 +111,13 @@ export const PrimaryStoryCard = (props) => {
|
|
|
105
111
|
// TODO: Add corrected testID here
|
|
106
112
|
testID={COMP_CONTENT_CONSTANTS.authorName}
|
|
107
113
|
>
|
|
108
|
-
{authorName
|
|
109
|
-
getTimeForStoryCards(
|
|
110
|
-
story[
|
|
114
|
+
{authorName
|
|
115
|
+
+ getTimeForStoryCards(
|
|
116
|
+
story['published-at'],
|
|
111
117
|
DATE_FORMAT,
|
|
112
118
|
locale,
|
|
113
119
|
translate,
|
|
114
|
-
reverseTimeAdverbPosition
|
|
120
|
+
reverseTimeAdverbPosition,
|
|
115
121
|
)}
|
|
116
122
|
</Text>
|
|
117
123
|
<Text
|
|
@@ -138,6 +144,6 @@ PrimaryStoryCard.propTypes = {
|
|
|
138
144
|
};
|
|
139
145
|
|
|
140
146
|
PrimaryStoryCard.defaultProps = {
|
|
141
|
-
cdn:
|
|
147
|
+
cdn: '',
|
|
142
148
|
horizontalPadding: 12,
|
|
143
149
|
};
|
|
@@ -21,7 +21,12 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
21
21
|
const { story = {} } = props;
|
|
22
22
|
const { theme } = useContext(AppTheme);
|
|
23
23
|
const {
|
|
24
|
-
COLORS,
|
|
24
|
+
COLORS,
|
|
25
|
+
FONT_SIZE,
|
|
26
|
+
locale,
|
|
27
|
+
DARK_MODE,
|
|
28
|
+
reverseTimeAdverbPosition,
|
|
29
|
+
enableReadTimeOnStoryCards,
|
|
25
30
|
} = theme || {};
|
|
26
31
|
|
|
27
32
|
const translate = get(theme, ['translate'], (word) => word);
|
|
@@ -41,7 +46,7 @@ const PrimaryStoryCardNewBase = (props) => {
|
|
|
41
46
|
]);
|
|
42
47
|
|
|
43
48
|
const DATE_FORMAT = 'd MMM, yyyy';
|
|
44
|
-
const readTime = story['read-time']
|
|
49
|
+
const readTime = enableReadTimeOnStoryCards && story['read-time']
|
|
45
50
|
? `${story['read-time']} ${translate('min read')} · `
|
|
46
51
|
: '';
|
|
47
52
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { throttle } from
|
|
2
|
-
import get from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import React, { useContext } from
|
|
1
|
+
import { throttle } from 'lodash';
|
|
2
|
+
import get from 'lodash/get';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React, { useContext } from 'react';
|
|
5
5
|
import {
|
|
6
6
|
Image,
|
|
7
7
|
StyleSheet,
|
|
@@ -9,31 +9,36 @@ import {
|
|
|
9
9
|
View,
|
|
10
10
|
TextStyle,
|
|
11
11
|
TouchableOpacityProps,
|
|
12
|
-
} from
|
|
13
|
-
import Icon from
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
14
14
|
import {
|
|
15
15
|
AppTheme,
|
|
16
16
|
getImageMetadata,
|
|
17
17
|
getImageSlug,
|
|
18
18
|
getTimeForStoryCards,
|
|
19
|
-
} from
|
|
20
|
-
import { getStoryHeadline } from
|
|
21
|
-
import { ResponsiveImage, Text } from
|
|
22
|
-
import { secStoryCardStyles } from
|
|
19
|
+
} from '../../utils';
|
|
20
|
+
import { getStoryHeadline } from '../../utils/story';
|
|
21
|
+
import { ResponsiveImage, Text } from '../index';
|
|
22
|
+
import { secStoryCardStyles } from './styles';
|
|
23
23
|
import {
|
|
24
24
|
COMP_GENERAL_CONSTANTS,
|
|
25
25
|
COMP_CONTENT_CONSTANTS,
|
|
26
|
-
} from
|
|
26
|
+
} from '../../constants/component-constants';
|
|
27
27
|
|
|
28
28
|
export const SecondaryStoryCard = (props) => {
|
|
29
29
|
const { theme } = useContext(AppTheme);
|
|
30
|
-
const translate = get(theme, [
|
|
30
|
+
const translate = get(theme, ['translate'], (word) => word);
|
|
31
31
|
|
|
32
|
-
const {
|
|
32
|
+
const {
|
|
33
|
+
locale,
|
|
34
|
+
COLORS,
|
|
35
|
+
reverseTimeAdverbPosition,
|
|
36
|
+
enableReadTimeOnStoryCards,
|
|
37
|
+
} = theme;
|
|
33
38
|
const styles = secStoryCardStyles(theme);
|
|
34
39
|
const { story = {} } = props;
|
|
35
40
|
|
|
36
|
-
const DATE_FORMAT =
|
|
41
|
+
const DATE_FORMAT = 'd MMM, yyyy';
|
|
37
42
|
|
|
38
43
|
const containerStyle = StyleSheet.flatten([
|
|
39
44
|
styles.container,
|
|
@@ -48,15 +53,12 @@ export const SecondaryStoryCard = (props) => {
|
|
|
48
53
|
props.dateTextStyle,
|
|
49
54
|
]);
|
|
50
55
|
const iconStyles = StyleSheet.flatten([styles.iconStyles, props.iconStyle]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const readTime = story["read-time"]
|
|
58
|
-
? `${story["read-time"]} ${translate("min read")}`
|
|
59
|
-
: "";
|
|
56
|
+
|
|
57
|
+
const name = get(story.authors, [0, 'name']);
|
|
58
|
+
const authorName = name ? `${translate('By')} ${name} | ` : '';
|
|
59
|
+
const readTime = enableReadTimeOnStoryCards && story['read-time']
|
|
60
|
+
? `${story['read-time']} ${translate('min read')}`
|
|
61
|
+
: '';
|
|
60
62
|
|
|
61
63
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
62
64
|
|
|
@@ -74,14 +76,14 @@ export const SecondaryStoryCard = (props) => {
|
|
|
74
76
|
);
|
|
75
77
|
|
|
76
78
|
const showStoryType = () => {
|
|
77
|
-
switch (story[
|
|
78
|
-
case
|
|
79
|
+
switch (story['story-template']) {
|
|
80
|
+
case 'text':
|
|
79
81
|
return null;
|
|
80
|
-
case
|
|
81
|
-
return showIcon(
|
|
82
|
-
case
|
|
83
|
-
return showIcon(
|
|
84
|
-
case
|
|
82
|
+
case 'photo':
|
|
83
|
+
return showIcon('photo');
|
|
84
|
+
case 'video':
|
|
85
|
+
return showIcon('play');
|
|
86
|
+
case 'live-blog':
|
|
85
87
|
return showLiveBlogIcon();
|
|
86
88
|
default:
|
|
87
89
|
null;
|
|
@@ -97,8 +99,8 @@ export const SecondaryStoryCard = (props) => {
|
|
|
97
99
|
>
|
|
98
100
|
<ResponsiveImage
|
|
99
101
|
metaData={getImageMetadata(story)}
|
|
100
|
-
slug={getImageSlug(story) ||
|
|
101
|
-
cdn={props.cdn ||
|
|
102
|
+
slug={getImageSlug(story) || ''}
|
|
103
|
+
cdn={props.cdn || ''}
|
|
102
104
|
imageWidth={props.imageWidth}
|
|
103
105
|
>
|
|
104
106
|
<Text style={styles.xminContainer}>
|
|
@@ -126,13 +128,13 @@ export const SecondaryStoryCard = (props) => {
|
|
|
126
128
|
numberOfLines={2}
|
|
127
129
|
testID={COMP_CONTENT_CONSTANTS.authorName}
|
|
128
130
|
>
|
|
129
|
-
{authorName
|
|
130
|
-
getTimeForStoryCards(
|
|
131
|
-
story[
|
|
131
|
+
{authorName
|
|
132
|
+
+ getTimeForStoryCards(
|
|
133
|
+
story['published-at'],
|
|
132
134
|
DATE_FORMAT,
|
|
133
135
|
locale,
|
|
134
136
|
translate,
|
|
135
|
-
reverseTimeAdverbPosition
|
|
137
|
+
reverseTimeAdverbPosition,
|
|
136
138
|
)}
|
|
137
139
|
</Text>
|
|
138
140
|
<View style={iconStyles}>{props.iconComponent}</View>
|
|
@@ -154,6 +156,6 @@ SecondaryStoryCard.propTypes = TouchableOpacityProps && {
|
|
|
154
156
|
};
|
|
155
157
|
|
|
156
158
|
SecondaryStoryCard.defaultProps = {
|
|
157
|
-
cdn:
|
|
159
|
+
cdn: '',
|
|
158
160
|
horizontalPadding: 12,
|
|
159
161
|
};
|
|
@@ -1,35 +1,40 @@
|
|
|
1
|
-
import { get, throttle } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import React, { useContext, memo } from
|
|
1
|
+
import { get, throttle } from 'lodash';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React, { useContext, memo } from 'react';
|
|
4
4
|
import {
|
|
5
|
-
I18nManager,
|
|
6
5
|
StyleSheet,
|
|
7
6
|
TouchableOpacity,
|
|
8
7
|
View,
|
|
9
8
|
TextStyle,
|
|
10
9
|
TouchableOpacityProps,
|
|
11
|
-
} from
|
|
12
|
-
import Icon from
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
13
12
|
import {
|
|
14
13
|
AppTheme,
|
|
15
14
|
getImageMetadata,
|
|
16
15
|
getImageSlug,
|
|
17
16
|
getTimeForStoryCards,
|
|
18
|
-
} from
|
|
19
|
-
import { getStoryHeadline } from
|
|
20
|
-
import { ResponsiveImage, Text } from
|
|
21
|
-
import { storyStyles } from
|
|
17
|
+
} from '../../utils';
|
|
18
|
+
import { getStoryHeadline } from '../../utils/story';
|
|
19
|
+
import { ResponsiveImage, Text } from '../index';
|
|
20
|
+
import { storyStyles } from './styles';
|
|
22
21
|
import {
|
|
23
22
|
COMP_GENERAL_CONSTANTS,
|
|
24
23
|
COMP_CONTENT_CONSTANTS,
|
|
25
|
-
} from
|
|
24
|
+
} from '../../constants/component-constants';
|
|
26
25
|
|
|
27
26
|
const SecondaryStoryCardNewBase = (props) => {
|
|
28
27
|
const { story = {} } = props;
|
|
29
28
|
const { theme } = useContext(AppTheme);
|
|
30
|
-
const {
|
|
29
|
+
const {
|
|
30
|
+
locale,
|
|
31
|
+
DARK_MODE,
|
|
32
|
+
COLORS,
|
|
33
|
+
reverseTimeAdverbPosition,
|
|
34
|
+
enableReadTimeOnStoryCards,
|
|
35
|
+
} = theme;
|
|
31
36
|
|
|
32
|
-
const translate = get(theme, [
|
|
37
|
+
const translate = get(theme, ['translate'], (word) => word);
|
|
33
38
|
|
|
34
39
|
const styles = storyStyles(theme, DARK_MODE);
|
|
35
40
|
const containerStyle = StyleSheet.flatten([
|
|
@@ -45,10 +50,10 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
45
50
|
props.timestampStyle,
|
|
46
51
|
]);
|
|
47
52
|
|
|
48
|
-
const DATE_FORMAT =
|
|
49
|
-
const readTime = story[
|
|
50
|
-
? `${story[
|
|
51
|
-
:
|
|
53
|
+
const DATE_FORMAT = 'd MMM, yyyy';
|
|
54
|
+
const readTime = enableReadTimeOnStoryCards && story['read-time']
|
|
55
|
+
? `${story['read-time']} ${translate('min read')} · `
|
|
56
|
+
: '';
|
|
52
57
|
|
|
53
58
|
const throttledOnpress = throttle(props.onPress, 1000);
|
|
54
59
|
|
|
@@ -66,14 +71,14 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
66
71
|
);
|
|
67
72
|
|
|
68
73
|
const showStoryType = () => {
|
|
69
|
-
switch (story[
|
|
70
|
-
case
|
|
74
|
+
switch (story['story-template']) {
|
|
75
|
+
case 'text':
|
|
71
76
|
return null;
|
|
72
|
-
case
|
|
73
|
-
return showIcon(
|
|
74
|
-
case
|
|
75
|
-
return showIcon(
|
|
76
|
-
case
|
|
77
|
+
case 'photo':
|
|
78
|
+
return showIcon('photo');
|
|
79
|
+
case 'video':
|
|
80
|
+
return showIcon('play');
|
|
81
|
+
case 'live-blog':
|
|
77
82
|
return showLiveBlogIcon();
|
|
78
83
|
default:
|
|
79
84
|
null;
|
|
@@ -89,8 +94,8 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
89
94
|
>
|
|
90
95
|
<ResponsiveImage
|
|
91
96
|
metaData={getImageMetadata(story)}
|
|
92
|
-
slug={getImageSlug(story) ||
|
|
93
|
-
cdn={props.cdn ||
|
|
97
|
+
slug={getImageSlug(story) || ''}
|
|
98
|
+
cdn={props.cdn || ''}
|
|
94
99
|
imageWidth={props.imageWidth}
|
|
95
100
|
>
|
|
96
101
|
<View style={styles.storyTypeContainer}>{showStoryType()}</View>
|
|
@@ -111,13 +116,13 @@ const SecondaryStoryCardNewBase = (props) => {
|
|
|
111
116
|
// TODO: Add corrected testID here
|
|
112
117
|
testID={COMP_CONTENT_CONSTANTS.publishedDate}
|
|
113
118
|
>
|
|
114
|
-
{readTime
|
|
115
|
-
getTimeForStoryCards(
|
|
116
|
-
story[
|
|
119
|
+
{readTime
|
|
120
|
+
+ getTimeForStoryCards(
|
|
121
|
+
story['published-at'],
|
|
117
122
|
DATE_FORMAT,
|
|
118
123
|
locale,
|
|
119
124
|
translate,
|
|
120
|
-
reverseTimeAdverbPosition
|
|
125
|
+
reverseTimeAdverbPosition,
|
|
121
126
|
)}
|
|
122
127
|
</Text>
|
|
123
128
|
</View>
|
|
@@ -137,7 +142,7 @@ SecondaryStoryCardNewBase.propTypes = TouchableOpacityProps && {
|
|
|
137
142
|
};
|
|
138
143
|
|
|
139
144
|
SecondaryStoryCardNewBase.defaultProps = {
|
|
140
|
-
cdn:
|
|
145
|
+
cdn: '',
|
|
141
146
|
horizontalPadding: 12,
|
|
142
147
|
};
|
|
143
148
|
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import React, { useContext, memo } from
|
|
2
|
-
import { TouchableOpacity } from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import Icon from
|
|
5
|
-
import Share from
|
|
6
|
-
import { AppTheme } from
|
|
7
|
-
import { shareButtonStyles } from
|
|
8
|
-
import { getStoryHeadline } from
|
|
9
|
-
import { COMP_GENERAL_CONSTANTS } from
|
|
1
|
+
import React, { useContext, memo } from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import Icon from 'react-native-vector-icons/Ionicons';
|
|
5
|
+
import Share from 'react-native-share';
|
|
6
|
+
import { AppTheme } from '../../utils';
|
|
7
|
+
import { shareButtonStyles } from './styles';
|
|
8
|
+
import { getStoryHeadline } from '../../utils/story';
|
|
9
|
+
import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants';
|
|
10
10
|
|
|
11
11
|
const ShareButtonBase = (props) => {
|
|
12
12
|
const { theme } = useContext(AppTheme);
|
|
13
13
|
const styles = shareButtonStyles(theme);
|
|
14
|
-
const {
|
|
14
|
+
const { enableShareOnStoryCards } = theme;
|
|
15
|
+
const { story, type = 'story', slug } = props;
|
|
15
16
|
|
|
16
17
|
const getShareURL = () => {
|
|
17
18
|
const { url } = story || {};
|
|
18
19
|
switch (type) {
|
|
19
|
-
case
|
|
20
|
+
case 'story':
|
|
20
21
|
return url;
|
|
21
|
-
case
|
|
22
|
+
case 'card':
|
|
22
23
|
return `${url}${slug}`;
|
|
23
|
-
case
|
|
24
|
+
case 'image':
|
|
24
25
|
return `${url}${slug}`;
|
|
25
|
-
case
|
|
26
|
+
case 'attachment':
|
|
26
27
|
return slug;
|
|
27
28
|
default:
|
|
28
29
|
return url || slug;
|
|
@@ -43,14 +44,14 @@ const ShareButtonBase = (props) => {
|
|
|
43
44
|
return null;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
return (
|
|
47
|
+
return enableShareOnStoryCards ? (
|
|
47
48
|
<TouchableOpacity
|
|
48
49
|
onPress={share}
|
|
49
50
|
testID={COMP_GENERAL_CONSTANTS.shareButtonTouch}
|
|
50
51
|
>
|
|
51
52
|
<Icon style={styles.iconStyle} name="share-social-outline" size={20} />
|
|
52
53
|
</TouchableOpacity>
|
|
53
|
-
);
|
|
54
|
+
) : null;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
ShareButtonBase.propTypes = {
|