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

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.3",
3
+ "version": "2.29.4-beta.4",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,33 @@
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
+ };
@@ -0,0 +1,63 @@
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
+
@@ -0,0 +1,103 @@
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
+ })
@@ -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, useFocusEffect } from 'react';
4
- import { I18nManager, TouchableOpacity, View, StyleSheet, AppState } from 'react-native';
3
+ import React, { useContext, useEffect, useState } from 'react';
4
+ import { I18nManager, TouchableOpacity, View, 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,21 +9,18 @@ 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';
13
12
  import { StoryContent } from '../StoryContent';
14
13
  import { StoryHeader } from '../StoryHeader';
15
14
  import { TagsRow } from '../TagsRow/TagsRow';
16
15
  import { ShareButton, Text } from '../index';
17
16
  import { storyStyles, modalStyles } from './styles';
18
17
  import { Player } from '../AudioPlayer';
19
- import Icon from 'react-native-vector-icons/AntDesign';
20
- import TrackPlayer, { usePlaybackState, Capability, State, AppKilledPlaybackBehavior, useProgress } from "react-native-track-player";
18
+ import TrackPlayer, { usePlaybackState, Capability, State, useProgress } from "react-native-track-player";
21
19
  import MaterialIcon from "react-native-vector-icons/MaterialCommunityIcons";
22
- import FontAwesomeIcon from "react-native-vector-icons/FontAwesome";
23
- import { isDetox } from 'react-native-is-detox';
20
+ import {Comments} from '../Comments'
24
21
 
25
22
  import Modal from 'react-native-modal';
26
- import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants';
23
+ import { SCREEN_LIST } from '../../../../../../src/constants/screen-mapping';
27
24
 
28
25
  const getLiveBlogTimeStamp = (card, DATE_FORMAT, story, styles, locale) => {
29
26
  const slug = `?cardId=${card.id}`;
@@ -138,34 +135,31 @@ export const Story = ({
138
135
  onAuthorPress,
139
136
  onTagsPress,
140
137
  onSectionPress,
141
- onFbCommentPress,
142
138
  screenList,
143
139
  navigation,
144
140
  accessComponent,
145
141
  checkStoryAccess,
146
- enableFbComments,
147
142
  storyHasAccess = 'loading',
148
143
  currentLayout,
149
144
  getAd,
150
145
  linkedStories,
151
146
  showWall,
152
147
  userObjectLength,
153
- numberOfVisibleStoryCard,
154
148
  audioS3Key,
155
149
  ttsButtonState,
156
150
  setShowTTSPlayer,
157
- gaTrigerredTTS
151
+ gaTrigerredTTS,
152
+ commentData
158
153
  }) => {
159
154
  const { theme } = useContext(AppTheme);
160
- const { COLORS, FONT_SIZE, locale, DARK_MODE,translate } = theme;
155
+ const { COLORS, FONT_SIZE, locale, DARK_MODE,translate, enableComments } = theme;
161
156
  const styles = storyStyles(COLORS, FONT_SIZE, DARK_MODE);
162
157
  const Modalstyles = modalStyles(COLORS, FONT_SIZE, DARK_MODE);
163
158
  const cards = story?.cards ?? [];
164
159
  const [showModal, setShowModal] = useState(false);
165
160
  const [audioRate, setAudioRate] = useState(1);
166
- const [progressInterval, setProgressInterval] = useState(undefined);
167
161
  const playbackState = usePlaybackState();
168
- const progress = useProgress(progressInterval);
162
+ const progress = useProgress();
169
163
  const [isFinishedPlaying, setFinishedPlaying] = useState(false);
170
164
 
171
165
 
@@ -244,14 +238,6 @@ export const Story = ({
244
238
  return async() => await TrackPlayer.pause();
245
239
  }, []);
246
240
 
247
- useEffect(() => {
248
- const checkDetox = async () => {
249
- const isRunningInDetox = await isDetox();
250
- setProgressInterval(isRunningInDetox ? 2000 : undefined);
251
- };
252
- checkDetox();
253
- }, []);
254
-
255
241
  useEffect(()=>{
256
242
  if(progress?.duration < progress.position + 1 && progress.position !== 0){
257
243
  setFinishedPlaying(true);
@@ -274,7 +260,6 @@ export const Story = ({
274
260
  }
275
261
 
276
262
  const togglePlayback = async () => {
277
- console.log('risi - tts toggle playback', playbackState.state, TrackPlayer)
278
263
  if (playbackState?.state === State.Playing) {
279
264
  await TrackPlayer.pause();
280
265
  } else {
@@ -318,20 +303,6 @@ export const Story = ({
318
303
  : 'hh:mm, d MMM yyyy';
319
304
  const storyType = story['story-template'];
320
305
 
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
- };
335
306
 
336
307
  useEffect(() => {
337
308
  checkStoryAccess(story);
@@ -378,6 +349,10 @@ export const Story = ({
378
349
  </Text>
379
350
  }
380
351
 
352
+ const navigateToComments = () => {
353
+ navigation.navigate(SCREEN_LIST.commentsScreen, {storyUrl: story.url})
354
+ }
355
+
381
356
  return (
382
357
  <>
383
358
  <View>
@@ -448,8 +423,7 @@ export const Story = ({
448
423
  </View>
449
424
  {accessComponent(story, storyHasAccess, showWall)}
450
425
 
451
-
452
- {shouldShowComments()}
426
+ {enableComments && <Comments commentData={commentData} addCommentHandler={navigateToComments} readAllCommentHandler={navigateToComments}/>}
453
427
 
454
428
  <View>
455
429
  <TagsRow tags={story.tags} onPress={onTagsPress} />
@@ -465,7 +439,7 @@ export const Story = ({
465
439
  <View style={[Modalstyles.modalContent, styles.modalBackgound]}>
466
440
  <View style={Modalstyles.header}>
467
441
  <Text style={[Modalstyles.title, styles.textStyle]}>{translate("Playback Speed")}</Text>
468
- <TouchableOpacity testID={COMP_GENERAL_CONSTANTS.ttsModalCloseButton} onPress={() => setShowModal(false)}>
442
+ <TouchableOpacity onPress={() => setShowModal(false)}>
469
443
  <MaterialIcon name="close" size={25} color={styles?.textStyle?.color} />
470
444
  </TouchableOpacity>
471
445
  </View>
@@ -44,3 +44,5 @@ 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
+