@quintype/native-components 2.29.4-beta.4 → 2.29.5

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.4-beta.4",
3
+ "version": "2.29.5",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  import { hexToRgb } from '@quintype/native-components/src/utils/colorUtils';
2
2
  import PropTypes from 'prop-types';
3
- import React, { useContext, useEffect, useState } from 'react';
4
- import { I18nManager, TouchableOpacity, View, AppState } from 'react-native';
3
+ import React, { useContext, useEffect, useState, useFocusEffect } from 'react';
4
+ import { I18nManager, TouchableOpacity, View, StyleSheet, AppState } from 'react-native';
5
5
  import LinearGradient from "react-native-linear-gradient";
6
6
  import { ClockIcon } from '../../Icons/ClockIcon';
7
7
  import { AppTheme, getTimeInFormat } from '../../utils';
@@ -9,18 +9,21 @@ import { isMiddleIndexOfArray } from '../../utils/arrayUtils';
9
9
  import { getFirstVideoElement, isStoryFree, getStoryHeadline } from '../../utils/story';
10
10
  import { getImageSlug } from '../../utils';
11
11
  import { STORY_TYPES } from '../../utils/story-types';
12
+ import { FBCommentsRow } from '../FBCommentsRow';
12
13
  import { StoryContent } from '../StoryContent';
13
14
  import { StoryHeader } from '../StoryHeader';
14
15
  import { TagsRow } from '../TagsRow/TagsRow';
15
16
  import { ShareButton, Text } from '../index';
16
17
  import { storyStyles, modalStyles } from './styles';
17
18
  import { Player } from '../AudioPlayer';
18
- import TrackPlayer, { usePlaybackState, Capability, State, useProgress } from "react-native-track-player";
19
+ import Icon from 'react-native-vector-icons/AntDesign';
20
+ import TrackPlayer, { usePlaybackState, Capability, State, AppKilledPlaybackBehavior, useProgress } from "react-native-track-player";
19
21
  import MaterialIcon from "react-native-vector-icons/MaterialCommunityIcons";
20
- import {Comments} from '../Comments'
22
+ import FontAwesomeIcon from "react-native-vector-icons/FontAwesome";
23
+ import { isDetox } from 'react-native-is-detox';
21
24
 
22
25
  import Modal from 'react-native-modal';
23
- import { SCREEN_LIST } from '../../../../../../src/constants/screen-mapping';
26
+ import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants';
24
27
 
25
28
  const getLiveBlogTimeStamp = (card, DATE_FORMAT, story, styles, locale) => {
26
29
  const slug = `?cardId=${card.id}`;
@@ -135,31 +138,34 @@ export const Story = ({
135
138
  onAuthorPress,
136
139
  onTagsPress,
137
140
  onSectionPress,
141
+ onFbCommentPress,
138
142
  screenList,
139
143
  navigation,
140
144
  accessComponent,
141
145
  checkStoryAccess,
146
+ enableFbComments,
142
147
  storyHasAccess = 'loading',
143
148
  currentLayout,
144
149
  getAd,
145
150
  linkedStories,
146
151
  showWall,
147
152
  userObjectLength,
153
+ numberOfVisibleStoryCard,
148
154
  audioS3Key,
149
155
  ttsButtonState,
150
156
  setShowTTSPlayer,
151
- gaTrigerredTTS,
152
- commentData
157
+ gaTrigerredTTS
153
158
  }) => {
154
159
  const { theme } = useContext(AppTheme);
155
- const { COLORS, FONT_SIZE, locale, DARK_MODE,translate, enableComments } = theme;
160
+ const { COLORS, FONT_SIZE, locale, DARK_MODE,translate } = theme;
156
161
  const styles = storyStyles(COLORS, FONT_SIZE, DARK_MODE);
157
162
  const Modalstyles = modalStyles(COLORS, FONT_SIZE, DARK_MODE);
158
163
  const cards = story?.cards ?? [];
159
164
  const [showModal, setShowModal] = useState(false);
160
165
  const [audioRate, setAudioRate] = useState(1);
166
+ const [progressInterval, setProgressInterval] = useState(undefined);
161
167
  const playbackState = usePlaybackState();
162
- const progress = useProgress();
168
+ const progress = useProgress(progressInterval);
163
169
  const [isFinishedPlaying, setFinishedPlaying] = useState(false);
164
170
 
165
171
 
@@ -238,6 +244,14 @@ export const Story = ({
238
244
  return async() => await TrackPlayer.pause();
239
245
  }, []);
240
246
 
247
+ useEffect(() => {
248
+ const checkDetox = async () => {
249
+ const isRunningInDetox = await isDetox();
250
+ setProgressInterval(isRunningInDetox ? 2000 : undefined);
251
+ };
252
+ checkDetox();
253
+ }, []);
254
+
241
255
  useEffect(()=>{
242
256
  if(progress?.duration < progress.position + 1 && progress.position !== 0){
243
257
  setFinishedPlaying(true);
@@ -260,6 +274,7 @@ export const Story = ({
260
274
  }
261
275
 
262
276
  const togglePlayback = async () => {
277
+ console.log('risi - tts toggle playback', playbackState.state, TrackPlayer)
263
278
  if (playbackState?.state === State.Playing) {
264
279
  await TrackPlayer.pause();
265
280
  } else {
@@ -303,6 +318,20 @@ export const Story = ({
303
318
  : 'hh:mm, d MMM yyyy';
304
319
  const storyType = story['story-template'];
305
320
 
321
+ const shouldShowComments = () => {
322
+ if (!enableFbComments) return null;
323
+ if (
324
+ isStoryFree(story) === 0
325
+ || (storyHasAccess !== 'loading' && storyHasAccess === 'granted')
326
+ ) {
327
+ return (
328
+ <View>
329
+ <FBCommentsRow onPress={onFbCommentPress} />
330
+ </View>
331
+ );
332
+ }
333
+ return null;
334
+ };
306
335
 
307
336
  useEffect(() => {
308
337
  checkStoryAccess(story);
@@ -349,10 +378,6 @@ export const Story = ({
349
378
  </Text>
350
379
  }
351
380
 
352
- const navigateToComments = () => {
353
- navigation.navigate(SCREEN_LIST.commentsScreen, {storyUrl: story.url})
354
- }
355
-
356
381
  return (
357
382
  <>
358
383
  <View>
@@ -423,7 +448,8 @@ export const Story = ({
423
448
  </View>
424
449
  {accessComponent(story, storyHasAccess, showWall)}
425
450
 
426
- {enableComments && <Comments commentData={commentData} addCommentHandler={navigateToComments} readAllCommentHandler={navigateToComments}/>}
451
+
452
+ {shouldShowComments()}
427
453
 
428
454
  <View>
429
455
  <TagsRow tags={story.tags} onPress={onTagsPress} />
@@ -439,7 +465,7 @@ export const Story = ({
439
465
  <View style={[Modalstyles.modalContent, styles.modalBackgound]}>
440
466
  <View style={Modalstyles.header}>
441
467
  <Text style={[Modalstyles.title, styles.textStyle]}>{translate("Playback Speed")}</Text>
442
- <TouchableOpacity onPress={() => setShowModal(false)}>
468
+ <TouchableOpacity testID={COMP_GENERAL_CONSTANTS.ttsModalCloseButton} onPress={() => setShowModal(false)}>
443
469
  <MaterialIcon name="close" size={25} color={styles?.textStyle?.color} />
444
470
  </TouchableOpacity>
445
471
  </View>
@@ -44,5 +44,3 @@ export { StoryTemplateIcon } from './StoryTemplateIcon';
44
44
  export { StoryCardDetailsRow } from './StoryCardDetailsRow';
45
45
  export { TextA } from './TextA';
46
46
  export { TextQ } from './TextQ';
47
- export {Comments} from './Comments';
48
-
@@ -1,33 +0,0 @@
1
- import React, { useContext } from "react";
2
- import Svg, { G, Path, Circle } from "react-native-svg";
3
- import { AppTheme } from "@quintype/native-components";
4
-
5
- export const DarkModeUserIcon = () => (
6
- <Svg width="50px" height="50px" viewBox="0 0 64 64">
7
- <G fill="none" fill-rule="evenodd">
8
- <Circle cx="32" cy="32" r="32" fill="#383838" />
9
- <Path
10
- fill="#D8D8D8"
11
- d="M32.75 30.5c-1.64 0-3.152-.398-4.535-1.195a8.756 8.756 0 0 1-3.27-3.27c-.797-1.383-1.195-2.894-1.195-4.535 0-1.64.398-3.152 1.195-4.535a8.756 8.756 0 0 1 3.27-3.27c1.383-.796 2.894-1.195 4.535-1.195 1.64 0 3.152.399 4.535 1.195a8.756 8.756 0 0 1 3.27 3.27c.797 1.383 1.195 2.894 1.195 4.535 0 1.64-.398 3.152-1.195 4.535a8.756 8.756 0 0 1-3.27 3.27c-1.383.797-2.894 1.195-4.535 1.195zm6.328 2.25c1.688 0 3.258.422 4.711 1.266a9.344 9.344 0 0 1 3.445 3.445 9.222 9.222 0 0 1 1.266 4.71v2.954c0 .937-.328 1.734-.984 2.39-.657.657-1.454.985-2.391.985h-24.75c-.938 0-1.734-.328-2.39-.984-.657-.657-.985-1.454-.985-2.391v-2.953c0-1.688.422-3.258 1.266-4.711a9.344 9.344 0 0 1 3.445-3.445 9.222 9.222 0 0 1 4.71-1.266h1.196a12.21 12.21 0 0 0 5.133 1.125 12.21 12.21 0 0 0 5.133-1.125h1.195z"
12
- />
13
- </G>
14
- </Svg>
15
- );
16
-
17
- export const UserIconBase = () => (
18
- <Svg width="50px" height="50px" viewBox="0 0 64 64">
19
- <G fill="none" fill-rule="evenodd">
20
- <Circle cx="32" cy="32" r="32" fill="#F4F4F4" />
21
- <Path
22
- fill="#D8D8D8"
23
- d="M32.75 30.5c-1.64 0-3.152-.398-4.535-1.195a8.756 8.756 0 0 1-3.27-3.27c-.797-1.383-1.195-2.894-1.195-4.535 0-1.64.398-3.152 1.195-4.535a8.756 8.756 0 0 1 3.27-3.27c1.383-.796 2.894-1.195 4.535-1.195 1.64 0 3.152.399 4.535 1.195a8.756 8.756 0 0 1 3.27 3.27c.797 1.383 1.195 2.894 1.195 4.535 0 1.64-.398 3.152-1.195 4.535a8.756 8.756 0 0 1-3.27 3.27c-1.383.797-2.894 1.195-4.535 1.195zm6.328 2.25c1.688 0 3.258.422 4.711 1.266a9.344 9.344 0 0 1 3.445 3.445 9.222 9.222 0 0 1 1.266 4.71v2.954c0 .937-.328 1.734-.984 2.39-.657.657-1.454.985-2.391.985h-24.75c-.938 0-1.734-.328-2.39-.984-.657-.657-.985-1.454-.985-2.391v-2.953c0-1.688.422-3.258 1.266-4.711a9.344 9.344 0 0 1 3.445-3.445 9.222 9.222 0 0 1 4.71-1.266h1.196a12.21 12.21 0 0 0 5.133 1.125 12.21 12.21 0 0 0 5.133-1.125h1.195z"
24
- />
25
- </G>
26
- </Svg>
27
- );
28
-
29
- export const UserIcon = (props) => {
30
- const { theme } = useContext(AppTheme);
31
- const { DARK_MODE } = theme;
32
- return DARK_MODE ? <DarkModeUserIcon /> : <UserIconBase />;
33
- };
@@ -1,63 +0,0 @@
1
- import React, { useContext} from "react";
2
- import { TouchableOpacity, View, Image, useWindowDimensions } from 'react-native';
3
- import {Text} from '../Text';
4
- import { AppTheme, getTimeInFormat } from '../../utils';
5
- import { commentStyles } from './styles';
6
- import {UserIcon} from '../../Icons/UserIcon/UserIcon'
7
- export const Comments = ({commentData, addCommentHandler, readAllCommentHandler}) => {
8
-
9
- const comments = commentData?.comments && commentData?.comments[0]
10
- const comment = comments && comments?.body?.ops[0]?.insert;
11
- const author = comments && comments?.author;
12
- const created_at = comments && comments?.created_at;
13
- const totalComments = commentData?.total_count ?? 0;
14
- const imageUrl =
15
- comments && comments?.body?.ops.length >= 2 ? comments?.body?.ops[1]?.insert?.image : null;
16
- const isHidden = comments ? comments?.hidden : false;
17
-
18
-
19
- const {avatar, name} = author ?? {}
20
- const { theme } = useContext(AppTheme);
21
- const { COLORS, FONT_SIZE,FONT_FAMILY, locale, DARK_MODE,translate } = theme;
22
- const styles = commentStyles(COLORS, FONT_SIZE,FONT_FAMILY, DARK_MODE, useWindowDimensions);
23
-
24
- const Divider = () => {
25
- return <View style={styles.divider}></View>
26
- }
27
-
28
- const CommentImage = ({src}) => {
29
- return <Image
30
- source={{uri:`https:${src}`}}
31
- style={styles.commentImage}
32
- />
33
- }
34
-
35
- return <View>
36
- <Divider />
37
- <Text primary style={styles.commentSectionTitle}>{translate('Comments')}</Text>
38
- {(comment || isHidden) ? (<View style={styles.container}>
39
- {!isHidden ? <Image
40
- source={{ uri: avatar }}
41
- style={styles.avatar}
42
- /> : <UserIcon />}
43
- <View style={styles.content}>
44
- {comment && <Text style={styles.name}>{name}</Text>}
45
- <Text style={styles.timestamp}>{getTimeInFormat(created_at,`dd MMM yyyy 'at' hh:mm a`,locale)}</Text>
46
- {comment && comment !== '\n' && <Text style={styles.comment}>{comment}</Text>}
47
- {isHidden && <Text style={styles.deletedComment}>{translate('This comment has been deleted')}</Text>}
48
- {imageUrl && <CommentImage src={imageUrl}/>}
49
- </View>
50
-
51
- </View>) : (<View style={styles.noCommentContainer}>
52
- <Text style={{ color:COLORS.BRAND_BLACK}}>{translate('No comments yet. Be the first to share your thoughts!')}</Text>
53
- </View>)}
54
-
55
- <View style={styles.actionSection}>
56
- <TouchableOpacity onPress={addCommentHandler} style={[styles.addCommentButton,(comment || isHidden) ? {width:'43%'} : {width:'94%'}]}><Text style={{color:COLORS.DYNAMIC_SECONDARY_TEXT_COLOR}}>{translate('Add Comment')}</Text></TouchableOpacity>
57
- {(comment || isHidden) && <TouchableOpacity onPress={readAllCommentHandler} style={styles.readAllCommentsButton}><Text style={{color:COLORS.BRAND_BLACK}}>{`${translate('Read All Comments')} ${totalComments ? '('+totalComments+')' : ''}`}</Text></TouchableOpacity>}
58
- </View>
59
- <Divider />
60
- </View>
61
- }
62
-
63
-
@@ -1,103 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
-
3
- export const commentStyles = (COLORS, FONT_SIZE, FONT_FAMILY, DARK_MODE, useWindowDimensions) => StyleSheet.create({
4
- container: {
5
- flexDirection: "row",
6
- alignItems: "flex-start",
7
- padding: 10,
8
- borderRadius: 8,
9
- marginBottom: 10,
10
- margin:5,
11
- marginTop:0
12
- },
13
- avatar: {
14
- width: 50,
15
- height: 50,
16
- borderRadius: 25,
17
- marginRight: 10,
18
- },
19
- content: {
20
- flex: 1,
21
- marginLeft:5
22
- },
23
- header: {
24
- flexDirection: "row",
25
- alignItems: "center",
26
- marginBottom: 4,
27
- },
28
- name: {
29
- fontWeight: "bold",
30
- fontSize: FONT_SIZE.h4,
31
- marginRight: 8,
32
- color:COLORS.BRAND_BLACK
33
- },
34
- timestamp: {
35
- fontSize: FONT_SIZE.h5,
36
- color: COLORS.MONO4,
37
- marginTop:5,
38
- marginBottom:10
39
- },
40
- comment: {
41
- fontSize: FONT_SIZE.h5,
42
- color:COLORS.BRAND_BLACK
43
- },
44
- divider:{
45
- height:1.0,
46
- width:'96%',
47
- backgroundColor:COLORS.MONO5,
48
- marginTop:30,
49
- marginBottom:20,
50
- alignSelf:'center',
51
- shadowOpacity:0.1,
52
- shadowRadius:10,
53
- shadowColor:COLORS.MONO2,
54
- shadowOffset:
55
- {width: 0,
56
- height: 20
57
- }
58
- },
59
- commentImage:{
60
- width: useWindowDimensions().width * 0.7,
61
- height: useWindowDimensions().width * 0.7,
62
- marginTop: 10
63
- },
64
- commentSectionTitle:{
65
- alignSelf: 'flex-start',
66
- fontSize: FONT_SIZE.h3,
67
- fontFamily:FONT_FAMILY.primaryBold,
68
- marginBottom:10,
69
- marginLeft:15,
70
- color:COLORS.BRAND_BLACK
71
- },
72
- noCommentContainer:{
73
- marginLeft:15,
74
- marginBottom:20
75
- },
76
- actionSection:{
77
- display:'flex',
78
- flexDirection:'row',
79
- justifyContent:'space-around'
80
- },
81
- addCommentButton:{
82
- borderRadius:5,
83
- backgroundColor:COLORS.BRAND_1,
84
- height:40,
85
- display:'flex',
86
- justifyContent:'center',
87
- alignItems:'center'
88
- },
89
- readAllCommentsButton:{
90
- borderWidth:1,
91
- borderColor:COLORS.MONO4,
92
- width:'50%',
93
- height:40,
94
- display:'flex',
95
- justifyContent:'center',
96
- alignItems:'center',
97
- borderRadius:5
98
- },
99
- deletedComment:{
100
- fontStyle:'italic',
101
- color:COLORS.BRAND_BLACK
102
- }
103
- })