@quintype/native-components 2.29.1 → 2.29.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.29.1",
3
+ "version": "2.29.3",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -19,6 +19,7 @@
19
19
  "react-htmltext": "^0.40.2",
20
20
  "react-native-fast-image": ">=8.3.2",
21
21
  "react-native-image-pan-zoom": "^2.1.12",
22
+ "react-native-is-detox": "^1.2.3",
22
23
  "react-native-lightbox": "0.8.1",
23
24
  "react-native-modal": "^13.0.1",
24
25
  "react-native-render-html": "^4.2.3",
@@ -32,11 +33,11 @@
32
33
  "react": ">=17.0.2",
33
34
  "react-native": ">=0.67.5",
34
35
  "react-native-blob-util": ">=6.7.4",
36
+ "react-native-device-info": "^11.1.0",
35
37
  "react-native-fast-image": ">=8.3.2",
36
38
  "react-native-linear-gradient": "^2.8.3",
37
39
  "react-native-pdf": ">=6.7.4",
38
40
  "react-native-vector-icons": "^10.0.0",
39
- "react-native-device-info": "^11.1.0",
40
41
  "react-native-webview": ">=11.0.0"
41
42
  },
42
43
  "devDependencies": {
@@ -47,6 +47,7 @@ export const authorRowStyleSheet = (appThemeContext) => {
47
47
  readtimeComponent: {
48
48
  justifyContent: 'center',
49
49
  alignItems: 'center',
50
+ padding: 10,
50
51
  },
51
52
  });
52
53
  };
@@ -1,10 +1,13 @@
1
1
  import { Text } from "@quintype/native-components/src/components/Text";
2
2
  import isHTML from "is-html";
3
- import React from "react";
3
+ import React, { useContext } from 'react';
4
4
  import { I18nManager, Linking, StyleSheet } from "react-native";
5
5
  import HTML from "react-native-render-html";
6
+ import { AppTheme } from "../../utils";
7
+
6
8
 
7
9
  const CustomHtmlParser = ({ text, textStyle={}, containerStyle={} }) => {
10
+ const { useDeeplinkHandler } = useContext(AppTheme);
8
11
  const textStyles = StyleSheet.flatten([
9
12
  textStyle,
10
13
  {
@@ -18,7 +21,7 @@ const CustomHtmlParser = ({ text, textStyle={}, containerStyle={} }) => {
18
21
  key={Math.random()}
19
22
  baseFontStyle={textStyles}
20
23
  onLinkPress={(evt, href) => {
21
- Linking.openURL(href);
24
+ useDeeplinkHandler(href);
22
25
  }}
23
26
  containerStyle={containerStyle}
24
27
  />
@@ -40,7 +40,7 @@ const getHTMLContent = (embedJs) => {
40
40
  const width = useWindowDimensions().width;
41
41
  const decodedContent = getDecodedContent(embedJs);
42
42
  let htmlContent = replaceDefaultProtocol(decodedContent);
43
- htmlContent = removeWidthnHeight(htmlContent);
43
+
44
44
  const webViewScript = `
45
45
  <script type="application/javascript">
46
46
  var interValId;
@@ -78,6 +78,7 @@ export const JSEmbedElement = (props) => {
78
78
  const [height, setHeight] = useState(-1);
79
79
  const webViewRef = useRef(null);
80
80
  const screenWidth = useWindowDimensions().width;
81
+ const screenHeight = useWindowDimensions().height;
81
82
  const width = get(
82
83
  props,
83
84
  ['currentLayout', 'width'],
@@ -92,18 +93,34 @@ export const JSEmbedElement = (props) => {
92
93
  setHeight(parseInt(event.nativeEvent.data));
93
94
  };
94
95
 
95
- const constructSource = () => {
96
- const urlMapper = {
97
- [STORY_ELEMENT_SUBTYPES.TWITTER]: 'https://twitter.com',
98
- [STORY_ELEMENT_SUBTYPES.FACEBOOK]: 'https://facebook.com',
99
- [STORY_ELEMENT_SUBTYPES.INSTAGRAM]: 'https://instagram.com',
100
- };
96
+ // Function to manually extract the base URL from an iframe src
97
+ const extractBaseUrlFromIframe = (iframeHtml) => {
98
+ const regex = /src="([^"]+)"/; // Regex to extract src URL from iframe
99
+ const match = iframeHtml.match(regex);
100
+
101
+ if (match && match[1]) {
102
+ const srcUrl = match[1]; // The full src URL from iframe
103
+
104
+ // Manually extract the base URL (protocol + host + pathname)
105
+ const urlPattern = /^(https?:\/\/[^/]+(?:\/[^?]*)?)/;
106
+ const baseUrlMatch = srcUrl.match(urlPattern);
101
107
 
102
- const baseUrl = urlMapper[props.element.subtype] || 'https://twitter.com';
108
+ if (baseUrlMatch) {
109
+ return baseUrlMatch[1]; // Return the base URL
110
+ } else {
111
+ console.error('Invalid URL format.');
112
+ return null;
113
+ }
114
+ } else {
115
+ console.error('Iframe src not found.');
116
+ return null;
117
+ }
118
+ };
103
119
 
120
+ const constructSource = () => {
104
121
  return {
105
122
  html: getHTMLContent(props.element['embed-js']),
106
- baseUrl,
123
+ baseUrl: extractBaseUrlFromIframe(getDecodedContent(props.element['embed-js'])),
107
124
  };
108
125
  };
109
126
 
@@ -113,7 +130,7 @@ export const JSEmbedElement = (props) => {
113
130
  ref={webViewRef}
114
131
  style={{
115
132
  width,
116
- height: Number(height),
133
+ height: Math.min(Number(height), screenHeight-250),
117
134
  flex: 0,
118
135
  opacity: 0.99,
119
136
  }}
@@ -132,6 +149,7 @@ export const JSEmbedElement = (props) => {
132
149
  source={constructSource()}
133
150
  mixedContentMode="always"
134
151
  mediaPlaybackRequiresUserAction={true}
152
+ nestedScrollEnabled={true}
135
153
  />
136
154
  </View>
137
155
  }
@@ -162,6 +180,7 @@ export const JSEmbedElement = (props) => {
162
180
  mixedContentMode="always"
163
181
  mediaPlaybackRequiresUserAction={true}
164
182
  injectedJavaScript='window.ReactNativeWebView.postMessage(document.body.scrollHeight)'
183
+ nestedScrollEnabled={true}
165
184
  />
166
185
  </View>
167
186
  );
@@ -20,7 +20,7 @@ export const PDFReader = ({ card, story }) => {
20
20
  const [modalVisible, setModalVisible] = useState(false);
21
21
 
22
22
  const { theme } = useContext(AppTheme);
23
- const { COLORS, FONT_SIZE, DARK_MODE, lineHeightMultiplier } = theme;
23
+ const { COLORS, FONT_SIZE, DARK_MODE, lineHeightMultiplier, translate } = theme;
24
24
 
25
25
  const showModal = () => {
26
26
  setModalVisible(true);
@@ -58,7 +58,9 @@ export const PDFReader = ({ card, story }) => {
58
58
  trustAllCerts={Platform.OS === 'ios'}
59
59
  />
60
60
  </Modal>
61
+ <Text style={{color:COLORS.BRAND_BLACK, fontSize: 25, fontWeight: 'bold', marginTop:40, marginLeft:15}}>{translate('Attachment')}</Text>
61
62
  <View style={styles.pdfContainer}>
63
+
62
64
  <View style={styles.pdfFileText}>
63
65
  <TouchableOpacity style={styles.pdfButton} onPress={showModal}>
64
66
  <Icon name="file-document-outline" size={56} style={styles.fileIcon} />
@@ -35,6 +35,10 @@ export const pdfStyles = (COLORS, FONT_SIZE, DARK_MODE, lineHeightMultiplier) =>
35
35
  },
36
36
  pdfContainer: {
37
37
  flexDirection: 'row',
38
+ marginBottom:40,
39
+ backgroundColor: COLORS.MONO6,
40
+ margin:10,
41
+ borderRadius: 5,
38
42
  },
39
43
  pdfFileText: {
40
44
  width: '80%',
@@ -0,0 +1,76 @@
1
+ import React, {useContext} from 'react';
2
+ import { View, TouchableOpacity, StyleSheet } from 'react-native';
3
+ import {
4
+ AppTheme
5
+ } from "@quintype/native-components";
6
+ import Icon from "react-native-vector-icons/MaterialIcons";
7
+ import { Text } from '@quintype/native-components/src/components/Text';
8
+ import {styles as paginationStyles} from "./styles";
9
+
10
+ const Pagination = ({ currentPage, totalPages, onPageChange }) => {
11
+ const { theme } = useContext(AppTheme);
12
+ const { COLORS, FONT_SIZE } = theme;
13
+ const styles = paginationStyles(COLORS, FONT_SIZE);
14
+ if(totalPages == 1) return null;
15
+ const range = 2;
16
+
17
+ const getPages = () => {
18
+ const pages = [];
19
+ let start = Math.max(1, currentPage - range);
20
+ let end = Math.min(totalPages, currentPage + range);
21
+
22
+ if (start > 1) pages.push('...');
23
+ for (let i = start; i <= end; i++) {
24
+ pages.push(i);
25
+ }
26
+ if (end < totalPages) pages.push('...');
27
+
28
+ return pages;
29
+ };
30
+
31
+
32
+ const handlePageChange = (page) => {
33
+ if (page >= 1 && page <= totalPages && page !== currentPage) {
34
+ onPageChange(page);
35
+ }
36
+ };
37
+
38
+ const pages = getPages();
39
+
40
+ return (
41
+ <View style={styles.container}>
42
+ <TouchableOpacity
43
+ onPress={() => handlePageChange(currentPage - 1)}
44
+ disabled={currentPage === 1}
45
+ style={[styles.arrow, currentPage === 1 && styles.disabled]}>
46
+ <Icon style={styles.iconStyle} name="arrow-back-ios-new" color={COLORS.BRAND_BLACK} size={FONT_SIZE.h5}/>
47
+ </TouchableOpacity>
48
+
49
+ {pages.map((page, index) => (
50
+ <TouchableOpacity
51
+ key={index}
52
+ onPress={() => handlePageChange(page)}
53
+ disabled={page === '...'}
54
+ style={[
55
+ styles.pageButton,
56
+ page === currentPage && styles.activePage,
57
+ ]}
58
+ >
59
+ <Text style={styles.pageText}>
60
+ {page}
61
+ </Text>
62
+ </TouchableOpacity>
63
+ ))}
64
+ <TouchableOpacity
65
+ onPress={() => handlePageChange(currentPage + 1)}
66
+ disabled={currentPage === totalPages}
67
+ style={[styles.arrow,{backgroundColor:COLORS.BRAND_WHITE}, currentPage === totalPages && styles.disabled]}>
68
+
69
+ <Icon style={styles.iconStyle} name="arrow-forward-ios" color={COLORS.BRAND_BLACK} size={FONT_SIZE.h5}/>
70
+ </TouchableOpacity>
71
+ </View>
72
+ );
73
+ };
74
+
75
+
76
+ export default Pagination;
@@ -0,0 +1,61 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export const styles = (COLORS, FONT_SIZE) => StyleSheet.create({
4
+ container: {
5
+ flexDirection: 'row',
6
+ alignItems: 'center',
7
+ justifyContent: 'center',
8
+ marginVertical: 20,
9
+ marginHorizontal:20,
10
+ borderRadius:5,
11
+ },
12
+ arrow: {
13
+ padding: 5,
14
+ borderRadius: 5,
15
+ backgroundColor: COLORS.BRAND_WHITE,
16
+ height:38,
17
+ paddingHorizontal:10,
18
+ shadowColor: "rgba(190,190,190,0.3)",
19
+ shadowOffset: { width: 0, height: 2.0 },
20
+ shadowOpacity: 1,
21
+ shadowRadius: 4,
22
+ elevation: 10,
23
+ },
24
+ arrowText: {
25
+ fontSize: 20,
26
+ color: COLORS.BRAND_BLACK,
27
+ },
28
+ pageButton: {
29
+ marginHorizontal: 2,
30
+ padding: 10,
31
+ borderRadius: 5,
32
+ backgroundColor: COLORS.BRAND_WHITE,
33
+ minHeight:38,
34
+ paddingHorizontal:12,
35
+ shadowColor: "rgba(190,190,190,0.3)",
36
+ shadowOffset: { width: 0, height: 2.0 },
37
+ shadowOpacity: 1,
38
+ shadowRadius: 4,
39
+ elevation: 100,
40
+ },
41
+ pageText: {
42
+ color: COLORS.BRAND_BLACK,
43
+ fontSize:FONT_SIZE.h6
44
+ },
45
+ activePage: {
46
+ borderColor: COLORS.BRAND_1,
47
+ minHeight:38,
48
+ padding: 10,
49
+ borderWidth:1
50
+ },
51
+ disabled: {
52
+ opacity: 0.5,
53
+ },
54
+ disabledText: {
55
+ color: COLORS.MONO6,
56
+ },
57
+ iconStyle:{
58
+ alignSelf: 'center',
59
+ marginTop:7
60
+ }
61
+ });
@@ -20,6 +20,7 @@ import Icon from 'react-native-vector-icons/AntDesign';
20
20
  import TrackPlayer, { usePlaybackState, Capability, State, AppKilledPlaybackBehavior, useProgress } from "react-native-track-player";
21
21
  import MaterialIcon from "react-native-vector-icons/MaterialCommunityIcons";
22
22
  import FontAwesomeIcon from "react-native-vector-icons/FontAwesome";
23
+ import { isDetoxSync } from 'react-native-is-detox';
23
24
 
24
25
  import Modal from 'react-native-modal';
25
26
 
@@ -162,7 +163,8 @@ export const Story = ({
162
163
  const [showModal, setShowModal] = useState(false);
163
164
  const [audioRate, setAudioRate] = useState(1);
164
165
  const playbackState = usePlaybackState();
165
- const progress = useProgress();
166
+ const isDetox = isDetoxSync();
167
+ const progress = useProgress(isDetox ? 2000 : undefined);
166
168
  const [isFinishedPlaying, setFinishedPlaying] = useState(false);
167
169
 
168
170
 
@@ -54,6 +54,7 @@ export const storyStyles = (COLORS, FONT_SIZE, DARK_MODE) => StyleSheet.create({
54
54
  },
55
55
  ttsStoryButtonStyle:{
56
56
  flexDirection:'row',
57
+ marginTop: 10,
57
58
  marginLeft:10,
58
59
  alignItems:'center',
59
60
  padding:10,
@@ -103,12 +103,12 @@ export const StoryContent = ({
103
103
  return <AllComponents.TitleElement card={storyElement} />;
104
104
  }
105
105
  case STORY_ELEMENT_TYPES.JS_EMBED: {
106
- switch (storyElement.subtype) {
107
- case STORY_ELEMENT_SUBTYPES.DAILY_MOTION: {
108
- return <DailyMotionPlayer element={storyElement} />;
109
- }
110
- default: break;
111
- }
106
+ // switch (storyElement.subtype) {
107
+ // case STORY_ELEMENT_SUBTYPES.DAILY_MOTION: {
108
+ // return <DailyMotionPlayer element={storyElement} />;
109
+ // }
110
+ // default: break;
111
+ // }
112
112
  return <AllComponents.JSEmbedElement element={storyElement} currentLayout={currentLayout} />;
113
113
  }
114
114
  default:
@@ -140,7 +140,7 @@ export const StoryGallery = ({ cdn, card }) => {
140
140
 
141
141
  const style = galleryStyles.fullWidth;
142
142
  return (
143
- <TouchableOpacity style={galleryStyles.subContainer}>
143
+ <TouchableOpacity style={[galleryStyles.subContainer,{margin:4}]}>
144
144
  <LightBoxImage
145
145
  onClickHandler={onPressHandler}
146
146
  hero={!!data.metaData['focus-point']}
@@ -11,20 +11,22 @@ export const styles = ({ FONT_SIZE }, screenDimensions) => {
11
11
  container: {
12
12
  width: '100%',
13
13
  paddingHorizontal: 10,
14
+
14
15
  },
15
16
  imgContainer: {
16
17
  width: '100%',
17
18
  flexDirection: 'row',
18
19
  flexWrap: 'wrap',
20
+
19
21
  },
20
22
  halfWidth: {
21
23
  width: (deviceWidth - 30) / 2,
22
24
  height: 124,
23
25
  },
24
26
  fullWidth: {
25
- width: (deviceWidth - 40) / 3,
26
- height: (deviceWidth - 40) / 3,
27
- margin: 2.5,
27
+ width: (deviceWidth - 45) / 3,
28
+ height: (deviceWidth - 45) / 3,
29
+ margin: 0,
28
30
  },
29
31
  descText: {
30
32
  fontSize: FONT_SIZE.h2,
@@ -1,10 +1,11 @@
1
- import React, { useContext } from 'react';
2
- import { View , ScrollView } from 'react-native';
1
+ import React, { useContext, useEffect } from 'react';
2
+ import { View , ScrollView, Button } from 'react-native';
3
3
  import get from 'lodash/get';
4
4
  import { formatData } from '../../utils/tableUtils';
5
5
  import { tableStyles } from './styles';
6
6
  import { Text } from '../index';
7
7
  import { AppTheme } from '../../utils';
8
+ import Pagination from '@quintype/native-components/src/components/Pagination';
8
9
 
9
10
  export const Table = ({ card }) => {
10
11
  const csv = get(card, ['data', 'content'], '');
@@ -18,11 +19,18 @@ export const Table = ({ card }) => {
18
19
  {},
19
20
  );
20
21
 
21
- const tableData = [tableHeaderRow].concat(headerData);
22
+ const tableData = headerData;
23
+ const [filteredData, setFilteredData] = React.useState([]);
24
+ const [activePage, setActivePage] = React.useState(1);
25
+
26
+ useEffect(()=>{
27
+ const nextData = tableData.slice(Math.max(0, (activePage - 1) * 10), activePage * 10);
28
+ setFilteredData([tableHeaderRow].concat(nextData))
29
+ },[activePage])
22
30
 
23
31
  const renderTableBody = () => (
24
32
  <View style={styles.tableBody}>
25
- {tableData.map((data) => (
33
+ {filteredData.map((data) => (
26
34
  <View style={styles.tableRow}>
27
35
  {headerFields.map((headerField) => (
28
36
  <View style={styles.tableHeaderTitle}>
@@ -34,11 +42,18 @@ export const Table = ({ card }) => {
34
42
  </View>
35
43
  );
36
44
 
45
+ const onPageChange = (page) => {
46
+ setActivePage(page);
47
+ };
48
+
37
49
  return (
50
+ <>
51
+ {filteredData.length > 1 && <Pagination currentPage={activePage} totalPages={parseInt(tableData.length % 10 === 0 ? tableData.length /10 : tableData.length /10+1)} onPageChange={onPageChange}/>}
38
52
  <ScrollView horizontal>
39
53
  <View style={styles.tableContainer}>
40
- <View>{renderTableBody()}</View>
54
+ {filteredData && <View>{renderTableBody()}</View>}
41
55
  </View>
42
56
  </ScrollView>
57
+ </>
43
58
  );
44
59
  };
@@ -8,7 +8,7 @@ import HTML from 'react-native-render-html';
8
8
  import { customHTMLStyles } from '../../constants/renderHTML';
9
9
 
10
10
  export const TextA = ({ answer }) => {
11
- const { theme } = useContext(AppTheme);
11
+ const { theme, useDeeplinkHandler } = useContext(AppTheme);
12
12
  const { COLORS, FONT_SIZE, lineHeightMultiplier, FONT_FAMILY} = theme;
13
13
  const styles = textAnswerStyles(COLORS, FONT_SIZE, lineHeightMultiplier);
14
14
  const customTagsStyles = customHTMLStyles();
@@ -29,7 +29,7 @@ export const TextA = ({ answer }) => {
29
29
  key={Math.random()}
30
30
  baseFontStyle={style}
31
31
  onLinkPress={(evt, href) => {
32
- Linking.openURL(href);
32
+ useDeeplinkHandler(href);
33
33
  }}
34
34
  tagsStyles={{
35
35
  del: customTagsStyles.del,
@@ -40,7 +40,7 @@ export const TextBigFact = ({ text, attribution, id }) => {
40
40
  key={Math.random()}
41
41
  baseFontStyle={style}
42
42
  onLinkPress={(evt, href) => {
43
- useDeeplinkHandler(href, props?.navigation);
43
+ useDeeplinkHandler(href);
44
44
  }}
45
45
  tagsStyles={{
46
46
  del: customTagsStyles.del,
@@ -36,7 +36,7 @@ export const TextBlockQuote = ({ text, attribution }) => {
36
36
  key={Math.random()}
37
37
  baseFontStyle={style}
38
38
  onLinkPress={(evt, href) => {
39
- useDeeplinkHandler(href, props?.navigation);
39
+ useDeeplinkHandler(href);
40
40
  }}
41
41
  tagsStyles={{
42
42
  del: customTagsStyles.del,
@@ -35,7 +35,7 @@ export const TextBlurb = ({ text }) => {
35
35
  key={Math.random()}
36
36
  baseFontStyle={style}
37
37
  onLinkPress={(evt, href) => {
38
- useDeeplinkHandler(href, props?.navigation);
38
+ useDeeplinkHandler(href);
39
39
  }}
40
40
  tagsStyles={{
41
41
  del: customTagsStyles.del,
@@ -7,7 +7,7 @@ import { AppTheme } from '@quintype/native-components/src/utils/context';
7
7
  import HTML from 'react-native-render-html';
8
8
  import { customHTMLStyles } from '../../constants/renderHTML';
9
9
  export const TextQ = ({ question }) => {
10
- const { theme } = useContext(AppTheme);
10
+ const { theme, useDeeplinkHandler } = useContext(AppTheme);
11
11
  const { COLORS, FONT_SIZE, lineHeightMultiplier, FONT_FAMILY } = theme;
12
12
  const styles = textQuestionStyles(COLORS, FONT_SIZE, lineHeightMultiplier);
13
13
  const customTagsStyles = customHTMLStyles();
@@ -28,7 +28,7 @@ export const TextQ = ({ question }) => {
28
28
  key={Math.random()}
29
29
  baseFontStyle={style}
30
30
  onLinkPress={(evt, href) => {
31
- Linking.openURL(href);
31
+ useDeeplinkHandler(href);
32
32
  }}
33
33
  tagsStyles={{
34
34
  del: customTagsStyles.del,
@@ -11,7 +11,7 @@ import { AppTheme } from '../../utils/context';
11
11
  import { alterQuoteData } from '../../utils';
12
12
 
13
13
  export const TextQuote = ({ text, attribution }) => {
14
- const { theme } = useContext(AppTheme);
14
+ const { theme, useDeeplinkHandler } = useContext(AppTheme);
15
15
  const {
16
16
  FONT_FAMILY, COLORS, FONT_SIZE, CAN_COPY_TEXT, lineHeightMultiplier,
17
17
  } = theme;
@@ -39,7 +39,7 @@ export const TextQuote = ({ text, attribution }) => {
39
39
  key={Math.random()}
40
40
  baseFontStyle={style}
41
41
  onLinkPress={(evt, href) => {
42
- Linking.openURL(href);
42
+ useDeeplinkHandler(href);
43
43
  }}
44
44
  tagsStyles={{
45
45
  del: customTagsStyles.del,
@@ -9,7 +9,7 @@ import { textSummaryStyles } from './styles';
9
9
  import { AppTheme } from '../../utils/context';
10
10
 
11
11
  export const TextSummary = (props) => {
12
- const { theme } = useContext(AppTheme);
12
+ const { theme, useDeeplinkHandler } = useContext(AppTheme);
13
13
  const {
14
14
  FONT_FAMILY, FONT_SIZE, COLORS, CAN_COPY_TEXT, lineHeightMultiplier,
15
15
  } = theme;
@@ -34,7 +34,7 @@ export const TextSummary = (props) => {
34
34
  key={Math.random()}
35
35
  baseFontStyle={style}
36
36
  onLinkPress={(evt, href) => {
37
- Linking.openURL(href);
37
+ useDeeplinkHandler(href);
38
38
  }}
39
39
  tagsStyles={{
40
40
  del: customTagsStyles.del,