@quintype/native-components 2.20.25 → 2.20.26-beta.1

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/README.md CHANGED
@@ -4,7 +4,26 @@
4
4
 
5
5
  `$ npm install @quintype/native-components --save`
6
6
 
7
- ### Linking
7
+ ## Creating and installing a beta version
8
+
9
+ ### Publishing a version with beta tag:
10
+ 1. Add, commit and push beta changes on a new branch.
11
+ 2. Run `npm i --legacy-peer-deps` (Using **node@16.19.0**, **npm@8.19.3**)
12
+ 3. Run `npm cache clean --force` in case the above command fails.
13
+ 4. Create a tag by running `npm version 2.21.0-beta.0` (add **\`-beta.*iteration*\`** (where ***iteration*** can just be incremented (+1) for subsequent beta-versions on the same development branch)
14
+ 5. Publish the tag by running `npm publish --tag beta`
15
+ 6. Make sure to commit and push the new beta versioning changes.
16
+
17
+ ### Installing a version with beta tag on host app:
18
+ npm install @quintype/native-components@beta
19
+
20
+ ### Note:
21
+ - `prePublishOnly` script that was in use before is incompatible with recent node/npm versions. Hence `standard-version-release.sh` is not used.
22
+ - Revert `"version"` changes from `package.json` before creating PR (for merging to `master`).
23
+ - Access all versions [here](https://www.npmjs.com/package/@quintype/native-components?activeTab=versions).
24
+
25
+
26
+ ## Linking
8
27
 
9
28
  This library has both js only as well as native components. Please check the instructions for the respective components for more details.
10
29
 
@@ -1,15 +1,15 @@
1
1
  #!/bin/bash -e
2
2
 
3
- npm install
4
- git diff --quiet
3
+ # npm install
4
+ # git diff --quiet
5
5
 
6
- BRANCH=$(git symbolic-ref --short HEAD)
6
+ # BRANCH=$(git symbolic-ref --short HEAD)
7
7
 
8
- if [ "$BRANCH" == 'master' ]
9
- then
10
- npx standard-version
11
- else
12
- npx standard-version --prerelease "$(git symbolic-ref --short HEAD | sed s:/:-:g )" --skip.changelog=true
13
- fi
8
+ # if [ "$BRANCH" == 'master' ]
9
+ # then
10
+ # npx standard-version
11
+ # else
12
+ # npx standard-version --prerelease "$(git symbolic-ref --short HEAD | sed s:/:-:g )" --skip.changelog=true
13
+ # fi
14
14
 
15
- git push --follow-tags origin "$BRANCH"
15
+ # git push --follow-tags origin "$BRANCH"
package/jest-setup.js CHANGED
@@ -2,11 +2,6 @@ jest.mock('@react-navigation/native', () => ({
2
2
  useNavigation: () => jest.fn(),
3
3
  }));
4
4
 
5
- jest.mock('rn-fetch-blob', () => ({
6
- DocumentDir: () => { },
7
- polyfill: () => { },
8
- }));
9
-
10
5
  jest.mock('react-native-device-info', () => ({
11
6
  DocumentDir: () => { },
12
7
  polyfill: () => { },
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.20.25",
3
+ "version": "2.20.26-beta.1",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
7
  "test": "jest --detectOpenHandles",
8
8
  "lint": "npx eslint './src/**/*.{js,jsx}'",
9
- "lint:ci": "npx eslint $(git diff --pretty='' --diff-filter=d --name-only origin/master..HEAD -- '*.js' '*.jsx') ./start.js",
10
- "prepublishOnly": "./bin-dev-scripts/standard-version-release.sh"
9
+ "lint:ci": "npx eslint $(git diff --pretty='' --diff-filter=d --name-only origin/master..HEAD -- '*.js' '*.jsx') ./start.js"
11
10
  },
12
11
  "dependencies": {
13
12
  "atob": "^2.1.2",
@@ -20,27 +19,26 @@
20
19
  "react-native-fast-image": "8.3.2",
21
20
  "react-native-image-pan-zoom": "^2.1.12",
22
21
  "react-native-lightbox": "0.8.1",
23
- "react-native-pdf": "^5.1.4",
24
22
  "react-native-render-html": "^4.2.3",
25
- "react-native-share": "^8.1.0",
26
- "rn-fetch-blob": "^0.10.16"
23
+ "react-native-share": "^8.1.0"
27
24
  },
28
25
  "peerDependencies": {
29
- "@react-navigation/native": ">=5.7.3",
26
+ "@react-navigation/native": ">=6.1.17",
30
27
  "lodash": ">=4.17.20",
31
28
  "react": ">=17.0.2",
32
29
  "react-native": ">=0.67.5",
33
30
  "react-native-fast-image": ">=8.3.2",
34
- "react-native-pdf": ">=6.2.0",
31
+ "react-native-pdf": ">=6.7.4",
32
+ "react-native-blob-util": ">=6.7.4",
35
33
  "react-native-webview": ">=11.0.0",
36
34
  "rn-fetch-blob": ">=0.12.0",
37
- "react-native-vector-icons": "^10.0.0"
35
+ "react-native-vector-icons": "^10.0.0",
36
+ "react-native-linear-gradient": "^2.8.3"
38
37
  },
39
38
  "devDependencies": {
40
39
  "@babel/core": "^7.11.1",
41
40
  "@babel/runtime": "^7.11.2",
42
41
  "@react-native-community/eslint-config": "^2.0.0",
43
- "@react-navigation/native": "^5.7.1",
44
42
  "@testing-library/jest-native": "^3.4.3",
45
43
  "@testing-library/react-native": "^7.1.0",
46
44
  "babel-jest": "^26.3.0",
@@ -53,10 +51,9 @@
53
51
  "husky": "^4.2.5",
54
52
  "jest": "^26.4.0",
55
53
  "metro-react-native-babel-preset": "^0.62.0",
56
- "react": "17.0.2",
57
- "react-native": "0.67.4",
54
+ "react": "18.2.0",
55
+ "react-native": "0.71.17",
58
56
  "react-native-device-info": "^5.6.5",
59
- "react-native-gesture-handler": "^1.9.0",
60
57
  "react-native-svg": "^12.3.0",
61
58
  "react-navigation-hooks": "^1.1.0",
62
59
  "react-test-renderer": "16.13.1"
@@ -65,7 +62,6 @@
65
62
  "preset": "react-native",
66
63
  "setupFilesAfterEnv": [
67
64
  "./jest-setup.js",
68
- "./node_modules/react-native-gesture-handler/jestSetup.js",
69
65
  "@testing-library/jest-native/extend-expect"
70
66
  ],
71
67
  "moduleNameMapper": {
@@ -1,8 +1,7 @@
1
1
  import { get } from 'lodash';
2
2
  import PropTypes from 'prop-types';
3
3
  import React, { useContext } from 'react';
4
- import { Linking, View } from 'react-native';
5
- import { TouchableOpacity } from 'react-native-gesture-handler';
4
+ import { Linking, View, TouchableOpacity } from 'react-native';
6
5
  import { AppTheme } from '../../utils';
7
6
  import { Text } from '../Text';
8
7
  import { styles } from './styles';
@@ -14,6 +14,8 @@ import { ClockIcon } from '../../Icons/ClockIcon';
14
14
  import { storyStyles } from './styles';
15
15
  import { isStoryFree, mutateDataBeforeAccess, getFirstVideoElement } from '../../utils/story';
16
16
  import { isMiddleIndexOfArray } from '../../utils/arrayUtils';
17
+ import LinearGradient from "react-native-linear-gradient";
18
+ import { hexToRgb } from '@quintype/native-components/src/utils/colorUtils';
17
19
 
18
20
  const getLiveBlogTimeStamp = (card, DATE_FORMAT, share, styles, locale) => {
19
21
  const slug = `?cardId=${card.id}`;
@@ -77,7 +79,7 @@ const getStoryCards = (
77
79
  getAd,
78
80
  locale,
79
81
  ) => cards.map((card, index, source) => (
80
- <View key={card?.id}>
82
+ <View key={card?.id}>
81
83
  {isLiveBlog
82
84
  && getLiveBlogTimeStamp(card, DATE_FORMAT, share, styles, locale)}
83
85
 
@@ -107,7 +109,6 @@ const getStoryCards = (
107
109
  {/* ^ In the case of a story having just 1 card,
108
110
  requesting mid-content-Ad if there are > 1 story-elements in that card
109
111
  (> 2 story-elements in case of video story since the 1st story-element gets rendered in header). */}
110
-
111
112
  <StoryContent
112
113
  testID={contentTestID}
113
114
  key={storyElement?.id}
@@ -144,15 +145,15 @@ export const Story = ({
144
145
  storyHasAccess = 'loading',
145
146
  currentLayout,
146
147
  getAd,
148
+ showWall,
149
+ userObjectLength,
150
+ numberOfVisibleStoryCard,
151
+ linkedStories
147
152
  }) => {
148
153
  const { theme } = useContext(AppTheme);
149
- const { COLORS, FONT_SIZE, locale } = theme;
154
+ const { COLORS, FONT_SIZE, locale, DARK_MODE } = theme;
150
155
  const styles = storyStyles(COLORS, FONT_SIZE);
151
-
152
- const {
153
- cards = [],
154
- 'linked-stories': linkedStories,
155
- } = mutateDataBeforeAccess(story, storyHasAccess);
156
+ const cards = story?.cards ?? [];
156
157
 
157
158
  const firstVideoElement = story['story-template'] === STORY_TYPES.VIDEO_STORY
158
159
  ? getFirstVideoElement(cards)
@@ -181,12 +182,21 @@ export const Story = ({
181
182
  return null;
182
183
  };
183
184
 
184
- useEffect(() => {
185
- checkStoryAccess(story);
186
- }, []);
185
+ const GradientView = () => {
186
+ return (
187
+ <LinearGradient
188
+ colors={[
189
+ DARK_MODE ? hexToRgb("#252525", 0) : hexToRgb(COLORS.BRAND_WHITE, 0),
190
+ DARK_MODE ? hexToRgb("#252525", 1) : hexToRgb(COLORS.BRAND_WHITE, 1),
191
+ ]}
192
+ style={{ height: 200}}
193
+ ></LinearGradient>
194
+ );
195
+ };
187
196
 
188
197
  return (
189
198
  <>
199
+ <View>
190
200
  <StoryHeader
191
201
  firstVideoElement={firstVideoElement}
192
202
  testID={headerTestID}
@@ -196,6 +206,8 @@ export const Story = ({
196
206
  onSectionPress={onSectionPress}
197
207
  />
198
208
 
209
+
210
+
199
211
  {getAd()}
200
212
 
201
213
  {getStoryCards(
@@ -219,7 +231,13 @@ export const Story = ({
219
231
  locale,
220
232
  )}
221
233
 
222
- {accessComponent(story, storyHasAccess)}
234
+ {(!(isStoryFree(story) === 0 || storyHasAccess === "granted") && showWall) && <View style={styles.overlay} >
235
+ <GradientView />
236
+ </View>
237
+ }
238
+ </View>
239
+ {accessComponent(story, storyHasAccess, showWall)}
240
+
223
241
 
224
242
  {shouldShowComments()}
225
243
 
@@ -37,4 +37,7 @@ export const storyStyles = (COLORS, FONT_SIZE) => StyleSheet.create({
37
37
  color: COLORS.BRAND_1,
38
38
  fontSize: FONT_SIZE.title,
39
39
  },
40
+ overlay:{
41
+ marginTop:-220
42
+ }
40
43
  });
@@ -1,7 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import { View } from 'react-native';
4
- import { TouchableOpacity } from 'react-native-gesture-handler';
3
+ import { View, TouchableOpacity } from 'react-native';
5
4
  import { ShareIcon } from '../../Icons/ShareIcon';
6
5
  import { AppTheme, getScreenPercentageWidth, stripHTML } from '../../utils';
7
6
  import { Text } from '../index';
@@ -1,7 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext, useRef, useState } from 'react';
3
- import { TouchableOpacity, View } from 'react-native';
4
- import { FlatList } from 'react-native-gesture-handler';
3
+ import { TouchableOpacity, View, FlatList } from 'react-native';
5
4
  import Icon from 'react-native-vector-icons/AntDesign';
6
5
  import { AppTheme } from '../../utils';
7
6
  import { SlideshowStoryCard } from '../SlideshowStoryCard';
@@ -1,7 +1,6 @@
1
1
  import React, { useContext } from 'react';
2
- import { View } from 'react-native';
2
+ import { View , ScrollView } from 'react-native';
3
3
  import get from 'lodash/get';
4
- import { ScrollView } from 'react-native-gesture-handler';
5
4
  import { formatData } from '../../utils/tableUtils';
6
5
  import { tableStyles } from './styles';
7
6
  import { Text } from '../index';
@@ -2,7 +2,6 @@ export const hexToRgb = (hex, alpha=1) => {
2
2
  let rgbCode = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(m, r, g, b) => '#' + r + r + g + g + b + b)
3
3
  .substring(1).match(/.{2}/g)
4
4
  .map(x => parseInt(x, 16));
5
- console.log('risi - color', `rgb(${rgbCode[0]}, ${rgbCode[1]}, ${rgbCode[2]}, ${alpha})`)
6
5
  return `rgba(${rgbCode[0]}, ${rgbCode[1]}, ${rgbCode[2]}, ${alpha})`;
7
6
  }
8
7
 
@@ -42,21 +42,51 @@ export const getFirstVideoElement = (cards) => cards
42
42
  || (type === 'jsembed' && subtype === 'dailymotion-video'),
43
43
  ) || {};
44
44
 
45
- export const mutateDataBeforeAccess = (item, storyHasAccess) => {
45
+ export const mutateDataBeforeAccess = (item, storyHasAccess, visibleCardCountForBlockedStories) => {
46
46
  if (isStoryFree(item) === 0 || storyHasAccess === 'granted') {
47
47
  return item;
48
48
  }
49
49
  if (storyHasAccess !== 'loading' && storyHasAccess === 'granted') {
50
50
  return item;
51
51
  }
52
- /* The following steps are necessary to keep argument mutation at bay */
53
- const firstCardObject = get(item, ['cards', 0], {});
52
+ const firstCardObject = get(item, ['cards', 2], {});
54
53
  const firstCardElement = get(firstCardObject, !STORY_TYPES.VIDEO_STORY && ['story-elements', 0], {});
54
+ let visibleContentsForBlockedStory = [];
55
+ let showBlockingWall = false;
56
+ let visibleStoryCount = 0;
57
+ // visibleCardCountForBlockedStories = 0;
58
+ if(!visibleCardCountForBlockedStories){
59
+ return {
60
+ cards: visibleContentsForBlockedStory,
61
+ showBlockingWall: true
62
+ }
63
+ }
64
+
65
+ if(item.cards && item.cards.length > 0){
66
+ for(let i = 0; i < item.cards.length; i++){
67
+ let storyElement = [];
68
+ for(let j=0; j<item.cards[i]['story-elements'].length; j++){
69
+ let tempStoryElement = item.cards[i]['story-elements'][j];
70
+ if(visibleStoryCount < visibleCardCountForBlockedStories-1){
71
+ storyElement.push(tempStoryElement);
72
+ visibleStoryCount++;
73
+ } else {
74
+ showBlockingWall = true;
75
+ storyElement.push(tempStoryElement);
76
+ break;
77
+ }
78
+ }
79
+
80
+ visibleContentsForBlockedStory.push({...item.cards[i],'story-elements' : storyElement});
81
+ if(showBlockingWall) break;
82
+ }
83
+ }
55
84
 
56
85
  return {
57
86
  ...item,
58
87
  ...{
59
- cards: [{ ...firstCardObject, 'story-elements': [firstCardElement] }],
88
+ cards: visibleContentsForBlockedStory,
60
89
  },
90
+ showBlockingWall
61
91
  };
62
92
  };