be-components 5.1.8 → 5.2.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.
Files changed (219) hide show
  1. package/lib/commonjs/Components/Icons.js +28 -1
  2. package/lib/commonjs/Components/Icons.js.map +1 -1
  3. package/lib/commonjs/Components/Themed.js +13 -1
  4. package/lib/commonjs/Components/Themed.js.map +1 -1
  5. package/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.js +80 -21
  6. package/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.js.map +1 -1
  7. package/lib/commonjs/SocialComponents/FormattedTextInput/index.js +49 -11
  8. package/lib/commonjs/SocialComponents/FormattedTextInput/index.js.map +1 -1
  9. package/lib/commonjs/SocialComponents/GifSelector/NativeSelector.js +14 -0
  10. package/lib/commonjs/SocialComponents/GifSelector/NativeSelector.js.map +1 -0
  11. package/lib/commonjs/SocialComponents/GifSelector/WebSelector.js +123 -0
  12. package/lib/commonjs/SocialComponents/GifSelector/WebSelector.js.map +1 -0
  13. package/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.js +112 -0
  14. package/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.js.map +1 -0
  15. package/lib/commonjs/SocialComponents/GroupChat/index.js +501 -0
  16. package/lib/commonjs/SocialComponents/GroupChat/index.js.map +1 -0
  17. package/lib/commonjs/SocialComponents/ImageRenderer.js +55 -0
  18. package/lib/commonjs/SocialComponents/ImageRenderer.js.map +1 -0
  19. package/lib/commonjs/SocialComponents/InputBar/components/ActionSelector.js +219 -0
  20. package/lib/commonjs/SocialComponents/InputBar/components/ActionSelector.js.map +1 -0
  21. package/lib/commonjs/SocialComponents/InputBar/index.js +59 -5
  22. package/lib/commonjs/SocialComponents/InputBar/index.js.map +1 -1
  23. package/lib/commonjs/SocialComponents/PostCard/components/ArticleCard.js +2 -0
  24. package/lib/commonjs/SocialComponents/PostCard/components/ArticleCard.js.map +1 -0
  25. package/lib/commonjs/SocialComponents/PostCard/components/ImageList.js +37 -25
  26. package/lib/commonjs/SocialComponents/PostCard/components/ImageList.js.map +1 -1
  27. package/lib/commonjs/SocialComponents/PostCard/index.js +148 -70
  28. package/lib/commonjs/SocialComponents/PostCard/index.js.map +1 -1
  29. package/lib/commonjs/SocialComponents/Poster/index.js +325 -0
  30. package/lib/commonjs/SocialComponents/Poster/index.js.map +1 -0
  31. package/lib/commonjs/SocialComponents/SocialOrderCard.js +16 -6
  32. package/lib/commonjs/SocialComponents/SocialOrderCard.js.map +1 -1
  33. package/lib/commonjs/SocialComponents/SocialOrdersList.js +20 -2
  34. package/lib/commonjs/SocialComponents/SocialOrdersList.js.map +1 -1
  35. package/lib/commonjs/SocialComponents/UrlPreviewCard.js +115 -0
  36. package/lib/commonjs/SocialComponents/UrlPreviewCard.js.map +1 -0
  37. package/lib/commonjs/SocialComponents/api/index.js +437 -0
  38. package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
  39. package/lib/commonjs/SocialComponents/index.js +14 -0
  40. package/lib/commonjs/SocialComponents/index.js.map +1 -1
  41. package/lib/module/Components/Icons.js +28 -1
  42. package/lib/module/Components/Icons.js.map +1 -1
  43. package/lib/module/Components/Themed.js +13 -1
  44. package/lib/module/Components/Themed.js.map +1 -1
  45. package/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.js +79 -21
  46. package/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.js.map +1 -1
  47. package/lib/module/SocialComponents/FormattedTextInput/index.js +49 -11
  48. package/lib/module/SocialComponents/FormattedTextInput/index.js.map +1 -1
  49. package/lib/module/SocialComponents/GifSelector/NativeSelector.js +7 -0
  50. package/lib/module/SocialComponents/GifSelector/NativeSelector.js.map +1 -0
  51. package/lib/module/SocialComponents/GifSelector/WebSelector.js +125 -0
  52. package/lib/module/SocialComponents/GifSelector/WebSelector.js.map +1 -0
  53. package/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.js +105 -0
  54. package/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.js.map +1 -0
  55. package/lib/module/SocialComponents/GroupChat/index.js +493 -0
  56. package/lib/module/SocialComponents/GroupChat/index.js.map +1 -0
  57. package/lib/module/SocialComponents/ImageRenderer.js +48 -0
  58. package/lib/module/SocialComponents/ImageRenderer.js.map +1 -0
  59. package/lib/module/SocialComponents/InputBar/components/ActionSelector.js +210 -0
  60. package/lib/module/SocialComponents/InputBar/components/ActionSelector.js.map +1 -0
  61. package/lib/module/SocialComponents/InputBar/index.js +58 -6
  62. package/lib/module/SocialComponents/InputBar/index.js.map +1 -1
  63. package/lib/module/SocialComponents/PostCard/components/ArticleCard.js +2 -0
  64. package/lib/module/SocialComponents/PostCard/components/ArticleCard.js.map +1 -0
  65. package/lib/module/SocialComponents/PostCard/components/ImageList.js +37 -25
  66. package/lib/module/SocialComponents/PostCard/components/ImageList.js.map +1 -1
  67. package/lib/module/SocialComponents/PostCard/index.js +148 -70
  68. package/lib/module/SocialComponents/PostCard/index.js.map +1 -1
  69. package/lib/module/SocialComponents/Poster/index.js +316 -0
  70. package/lib/module/SocialComponents/Poster/index.js.map +1 -0
  71. package/lib/module/SocialComponents/SocialOrderCard.js +16 -6
  72. package/lib/module/SocialComponents/SocialOrderCard.js.map +1 -1
  73. package/lib/module/SocialComponents/SocialOrdersList.js +21 -3
  74. package/lib/module/SocialComponents/SocialOrdersList.js.map +1 -1
  75. package/lib/module/SocialComponents/UrlPreviewCard.js +106 -0
  76. package/lib/module/SocialComponents/UrlPreviewCard.js.map +1 -0
  77. package/lib/module/SocialComponents/api/index.js +437 -0
  78. package/lib/module/SocialComponents/api/index.js.map +1 -1
  79. package/lib/module/SocialComponents/index.js +3 -1
  80. package/lib/module/SocialComponents/index.js.map +1 -1
  81. package/lib/typescript/lib/commonjs/Components/Icons.d.ts +5 -0
  82. package/lib/typescript/lib/commonjs/Components/Icons.d.ts.map +1 -1
  83. package/lib/typescript/lib/commonjs/Components/Themed.d.ts.map +1 -1
  84. package/lib/typescript/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.d.ts +3 -1
  85. package/lib/typescript/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.d.ts.map +1 -1
  86. package/lib/typescript/lib/commonjs/SocialComponents/FormattedTextInput/index.d.ts +6 -1
  87. package/lib/typescript/lib/commonjs/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
  88. package/lib/typescript/lib/commonjs/SocialComponents/GifSelector/NativeSelector.d.ts +4 -0
  89. package/lib/typescript/lib/commonjs/SocialComponents/GifSelector/NativeSelector.d.ts.map +1 -0
  90. package/lib/typescript/lib/commonjs/SocialComponents/GifSelector/WebSelector.d.ts +4 -0
  91. package/lib/typescript/lib/commonjs/SocialComponents/GifSelector/WebSelector.d.ts.map +1 -0
  92. package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.d.ts +14 -0
  93. package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.d.ts.map +1 -0
  94. package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/index.d.ts +18 -0
  95. package/lib/typescript/lib/commonjs/SocialComponents/GroupChat/index.d.ts.map +1 -0
  96. package/lib/typescript/lib/commonjs/SocialComponents/ImageRenderer.d.ts +11 -0
  97. package/lib/typescript/lib/commonjs/SocialComponents/ImageRenderer.d.ts.map +1 -0
  98. package/lib/typescript/lib/commonjs/SocialComponents/InputBar/components/ActionSelector.d.ts +9 -0
  99. package/lib/typescript/lib/commonjs/SocialComponents/InputBar/components/ActionSelector.d.ts.map +1 -0
  100. package/lib/typescript/lib/commonjs/SocialComponents/InputBar/index.d.ts +3 -1
  101. package/lib/typescript/lib/commonjs/SocialComponents/InputBar/index.d.ts.map +1 -1
  102. package/lib/typescript/lib/commonjs/SocialComponents/PostCard/components/ArticleCard.d.ts +1 -0
  103. package/lib/typescript/lib/commonjs/SocialComponents/PostCard/components/ArticleCard.d.ts.map +1 -0
  104. package/lib/typescript/lib/commonjs/SocialComponents/PostCard/components/ImageList.d.ts +1 -2
  105. package/lib/typescript/lib/commonjs/SocialComponents/PostCard/components/ImageList.d.ts.map +1 -1
  106. package/lib/typescript/lib/commonjs/SocialComponents/PostCard/index.d.ts +4 -1
  107. package/lib/typescript/lib/commonjs/SocialComponents/PostCard/index.d.ts.map +1 -1
  108. package/lib/typescript/lib/commonjs/SocialComponents/Poster/index.d.ts +9 -0
  109. package/lib/typescript/lib/commonjs/SocialComponents/Poster/index.d.ts.map +1 -0
  110. package/lib/typescript/lib/commonjs/SocialComponents/SocialOrderCard.d.ts +3 -1
  111. package/lib/typescript/lib/commonjs/SocialComponents/SocialOrderCard.d.ts.map +1 -1
  112. package/lib/typescript/lib/commonjs/SocialComponents/SocialOrdersList.d.ts +2 -1
  113. package/lib/typescript/lib/commonjs/SocialComponents/SocialOrdersList.d.ts.map +1 -1
  114. package/lib/typescript/lib/commonjs/SocialComponents/UrlPreviewCard.d.ts +9 -0
  115. package/lib/typescript/lib/commonjs/SocialComponents/UrlPreviewCard.d.ts.map +1 -0
  116. package/lib/typescript/lib/commonjs/SocialComponents/api/index.d.ts +94 -0
  117. package/lib/typescript/lib/commonjs/SocialComponents/api/index.d.ts.map +1 -1
  118. package/lib/typescript/lib/commonjs/SocialComponents/index.d.ts +2 -0
  119. package/lib/typescript/lib/module/Components/Icons.d.ts +5 -0
  120. package/lib/typescript/lib/module/Components/Icons.d.ts.map +1 -1
  121. package/lib/typescript/lib/module/Components/Themed.d.ts.map +1 -1
  122. package/lib/typescript/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.d.ts +3 -1
  123. package/lib/typescript/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.d.ts.map +1 -1
  124. package/lib/typescript/lib/module/SocialComponents/FormattedTextInput/index.d.ts +6 -1
  125. package/lib/typescript/lib/module/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
  126. package/lib/typescript/lib/module/SocialComponents/GifSelector/NativeSelector.d.ts +4 -0
  127. package/lib/typescript/lib/module/SocialComponents/GifSelector/NativeSelector.d.ts.map +1 -0
  128. package/lib/typescript/lib/module/SocialComponents/GifSelector/WebSelector.d.ts +13 -0
  129. package/lib/typescript/lib/module/SocialComponents/GifSelector/WebSelector.d.ts.map +1 -0
  130. package/lib/typescript/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.d.ts +14 -0
  131. package/lib/typescript/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.d.ts.map +1 -0
  132. package/lib/typescript/lib/module/SocialComponents/GroupChat/index.d.ts +18 -0
  133. package/lib/typescript/lib/module/SocialComponents/GroupChat/index.d.ts.map +1 -0
  134. package/lib/typescript/lib/module/SocialComponents/ImageRenderer.d.ts +11 -0
  135. package/lib/typescript/lib/module/SocialComponents/ImageRenderer.d.ts.map +1 -0
  136. package/lib/typescript/lib/module/SocialComponents/InputBar/components/ActionSelector.d.ts +10 -0
  137. package/lib/typescript/lib/module/SocialComponents/InputBar/components/ActionSelector.d.ts.map +1 -0
  138. package/lib/typescript/lib/module/SocialComponents/InputBar/index.d.ts +3 -1
  139. package/lib/typescript/lib/module/SocialComponents/InputBar/index.d.ts.map +1 -1
  140. package/lib/typescript/lib/module/SocialComponents/PostCard/components/ArticleCard.d.ts +1 -0
  141. package/lib/typescript/lib/module/SocialComponents/PostCard/components/ArticleCard.d.ts.map +1 -0
  142. package/lib/typescript/lib/module/SocialComponents/PostCard/components/ImageList.d.ts +1 -2
  143. package/lib/typescript/lib/module/SocialComponents/PostCard/components/ImageList.d.ts.map +1 -1
  144. package/lib/typescript/lib/module/SocialComponents/PostCard/index.d.ts +4 -1
  145. package/lib/typescript/lib/module/SocialComponents/PostCard/index.d.ts.map +1 -1
  146. package/lib/typescript/lib/module/SocialComponents/Poster/index.d.ts +11 -0
  147. package/lib/typescript/lib/module/SocialComponents/Poster/index.d.ts.map +1 -0
  148. package/lib/typescript/lib/module/SocialComponents/SocialOrderCard.d.ts +4 -2
  149. package/lib/typescript/lib/module/SocialComponents/SocialOrderCard.d.ts.map +1 -1
  150. package/lib/typescript/lib/module/SocialComponents/SocialOrdersList.d.ts +2 -1
  151. package/lib/typescript/lib/module/SocialComponents/SocialOrdersList.d.ts.map +1 -1
  152. package/lib/typescript/lib/module/SocialComponents/UrlPreviewCard.d.ts +9 -0
  153. package/lib/typescript/lib/module/SocialComponents/UrlPreviewCard.d.ts.map +1 -0
  154. package/lib/typescript/lib/module/SocialComponents/api/index.d.ts +94 -0
  155. package/lib/typescript/lib/module/SocialComponents/api/index.d.ts.map +1 -1
  156. package/lib/typescript/lib/module/SocialComponents/index.d.ts +3 -1
  157. package/lib/typescript/lib/module/SocialComponents/index.d.ts.map +1 -1
  158. package/lib/typescript/src/Components/Icons.d.ts +1 -0
  159. package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
  160. package/lib/typescript/src/Components/Themed.d.ts +1 -0
  161. package/lib/typescript/src/Components/Themed.d.ts.map +1 -1
  162. package/lib/typescript/src/SocialComponents/FormattedTextInput/components/TagSelector.d.ts +8 -1
  163. package/lib/typescript/src/SocialComponents/FormattedTextInput/components/TagSelector.d.ts.map +1 -1
  164. package/lib/typescript/src/SocialComponents/FormattedTextInput/index.d.ts +6 -1
  165. package/lib/typescript/src/SocialComponents/FormattedTextInput/index.d.ts.map +1 -1
  166. package/lib/typescript/src/SocialComponents/GifSelector/NativeSelector.d.ts +4 -0
  167. package/lib/typescript/src/SocialComponents/GifSelector/NativeSelector.d.ts.map +1 -0
  168. package/lib/typescript/src/SocialComponents/GifSelector/WebSelector.d.ts +11 -0
  169. package/lib/typescript/src/SocialComponents/GifSelector/WebSelector.d.ts.map +1 -0
  170. package/lib/typescript/src/SocialComponents/GroupChat/components/GroupMessageCard.d.ts +21 -0
  171. package/lib/typescript/src/SocialComponents/GroupChat/components/GroupMessageCard.d.ts.map +1 -0
  172. package/lib/typescript/src/SocialComponents/GroupChat/index.d.ts +34 -0
  173. package/lib/typescript/src/SocialComponents/GroupChat/index.d.ts.map +1 -0
  174. package/lib/typescript/src/SocialComponents/ImageRenderer.d.ts +21 -0
  175. package/lib/typescript/src/SocialComponents/ImageRenderer.d.ts.map +1 -0
  176. package/lib/typescript/src/SocialComponents/InputBar/components/ActionSelector.d.ts +16 -0
  177. package/lib/typescript/src/SocialComponents/InputBar/components/ActionSelector.d.ts.map +1 -0
  178. package/lib/typescript/src/SocialComponents/InputBar/index.d.ts +10 -1
  179. package/lib/typescript/src/SocialComponents/InputBar/index.d.ts.map +1 -1
  180. package/lib/typescript/src/SocialComponents/PostCard/components/ArticleCard.d.ts +1 -0
  181. package/lib/typescript/src/SocialComponents/PostCard/components/ArticleCard.d.ts.map +1 -0
  182. package/lib/typescript/src/SocialComponents/PostCard/components/ImageList.d.ts +1 -1
  183. package/lib/typescript/src/SocialComponents/PostCard/components/ImageList.d.ts.map +1 -1
  184. package/lib/typescript/src/SocialComponents/PostCard/index.d.ts +4 -2
  185. package/lib/typescript/src/SocialComponents/PostCard/index.d.ts.map +1 -1
  186. package/lib/typescript/src/SocialComponents/Poster/index.d.ts +16 -0
  187. package/lib/typescript/src/SocialComponents/Poster/index.d.ts.map +1 -0
  188. package/lib/typescript/src/SocialComponents/SocialOrderCard.d.ts +3 -1
  189. package/lib/typescript/src/SocialComponents/SocialOrderCard.d.ts.map +1 -1
  190. package/lib/typescript/src/SocialComponents/SocialOrdersList.d.ts +2 -1
  191. package/lib/typescript/src/SocialComponents/SocialOrdersList.d.ts.map +1 -1
  192. package/lib/typescript/src/SocialComponents/UrlPreviewCard.d.ts +10 -0
  193. package/lib/typescript/src/SocialComponents/UrlPreviewCard.d.ts.map +1 -0
  194. package/lib/typescript/src/SocialComponents/api/index.d.ts +42 -1
  195. package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
  196. package/lib/typescript/src/SocialComponents/index.d.ts +3 -1
  197. package/lib/typescript/src/SocialComponents/index.d.ts.map +1 -1
  198. package/package.json +5 -1
  199. package/src/Components/Icons.tsx +18 -1
  200. package/src/Components/Themed.tsx +11 -1
  201. package/src/SocialComponents/FormattedTextInput/components/TagSelector.tsx +56 -15
  202. package/src/SocialComponents/FormattedTextInput/index.tsx +36 -9
  203. package/src/SocialComponents/GifSelector/NativeSelector.tsx +13 -0
  204. package/src/SocialComponents/GifSelector/WebSelector.tsx +91 -0
  205. package/src/SocialComponents/GroupChat/components/GroupMessageCard.tsx +105 -0
  206. package/src/SocialComponents/GroupChat/index.tsx +403 -0
  207. package/src/SocialComponents/ImageRenderer.tsx +42 -0
  208. package/src/SocialComponents/InputBar/components/ActionSelector.tsx +165 -0
  209. package/src/SocialComponents/InputBar/index.tsx +40 -6
  210. package/src/SocialComponents/PostCard/components/ArticleCard.tsx +2 -0
  211. package/src/SocialComponents/PostCard/components/ImageList.tsx +28 -21
  212. package/src/SocialComponents/PostCard/index.tsx +122 -56
  213. package/src/SocialComponents/Poster/index.tsx +264 -0
  214. package/src/SocialComponents/SocialOrderCard.tsx +9 -8
  215. package/src/SocialComponents/SocialOrdersList.tsx +14 -8
  216. package/src/SocialComponents/UrlPreviewCard.tsx +75 -0
  217. package/src/SocialComponents/api/index.ts +385 -3
  218. package/src/SocialComponents/index.tsx +4 -0
  219. package/src/types.d.ts +58 -0
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+ import { Text, View } from "../../../Components/Themed";
3
+ import { useColors } from "../../../constants/useColors";
4
+ import type { GroupMessageProps, MyPlayerProps, OrderProps, PublicPlayerProps, TextTagProps } from "../../../types";
5
+ import { FormattedText } from '../../FormattedTextInput/FormattedText';
6
+ import moment from 'moment-mini';
7
+ import { Image } from 'react-native';
8
+ import ImageRenderer from '../../ImageRenderer';
9
+ import UrlPreviewCard from '../../UrlPreviewCard';
10
+ import SocialOrdersList from '../../SocialOrdersList';
11
+
12
+
13
+ type GroupMessageCardProps = {
14
+ group_message:GroupMessageProps,
15
+ me?:MyPlayerProps,
16
+ orders:OrderProps[],
17
+ player?:PublicPlayerProps,
18
+ mine?:boolean,
19
+ onCopyOrder?:(order:OrderProps) => void,
20
+ onFadeOrder?:(order:OrderProps) => void,
21
+ width: number,
22
+ onSelectImage:(image:{ url:string, height?:number, width?:number }) => void,
23
+ onSelectTag:(tag:TextTagProps) => void
24
+ }
25
+
26
+ const GroupMessageCard = ({group_message, orders, mine, player, width, onSelectImage, onSelectTag, onCopyOrder, onFadeOrder}:GroupMessageCardProps) => {
27
+ const Colors = useColors();
28
+ const image = group_message.message_images ? group_message.message_images[0] : undefined
29
+ const url = group_message.message_urls ? group_message.message_urls[0] : undefined
30
+
31
+ return (
32
+ <View>
33
+ <View style={{ flexDirection:'row', alignItems:'flex-end' }}>
34
+ {mine ?
35
+ <View style={{ flex:1 }} transparent />
36
+ :
37
+ <View float style={{ borderRadius:100, padding:2 }}>
38
+ <Image
39
+ source={{ uri:player?.profile_pic }}
40
+ style={{ height:36, width:36, borderRadius:100 }}
41
+ resizeMode='cover'
42
+ />
43
+ </View>
44
+ }
45
+ <View float style={{
46
+ width: mine ? width - 45 : width - 90,
47
+ padding:14,
48
+ marginLeft:10,
49
+ borderRadius:22,
50
+ marginBottom:15,
51
+ borderBottomLeftRadius: !mine? 0:22,
52
+ borderBottomRightRadius: mine? 0:22,
53
+ backgroundColor:mine?Colors.absolutes.brand.midnight:Colors.absolutes.highlights.highlight200
54
+ }}>
55
+ {group_message.formatted_text ?
56
+ <FormattedText
57
+ text={group_message.formatted_text}
58
+ tags={group_message.tags ?? []}
59
+ text_color={Colors.text.white}
60
+ onSelectTag={(tag) => onSelectTag(tag)}
61
+ />
62
+ : group_message.message ?
63
+ <Text size={12} color={Colors.text.white}>{group_message.message}</Text>
64
+ :<></>}
65
+ {url ?
66
+ <View transparent style={{ marginTop:10 }}>
67
+ <UrlPreviewCard
68
+ url={url}
69
+ max_height={120}
70
+ width={width - 120}
71
+ color={Colors.text.white}
72
+ />
73
+ </View>
74
+ :<></>}
75
+ {image ?
76
+ <ImageRenderer
77
+ image={image}
78
+ width={width - 120}
79
+ onSelectImage={onSelectImage}
80
+ />
81
+ :<></>}
82
+ {player && orders && orders.length > 0 ?
83
+ <View float style={{ padding:4, marginTop:10 }}>
84
+ <SocialOrdersList
85
+ orders={orders}
86
+ onCopyOrder={onCopyOrder}
87
+ onFadeOrder={onFadeOrder}
88
+ maxWidth={width - 120}
89
+ players={[player]}
90
+ direction='horizontal'
91
+
92
+ />
93
+ </View>
94
+ :<></>}
95
+ </View>
96
+ {!mine ?
97
+ <View transparent />
98
+ :<></>}
99
+ </View>
100
+ <Text theme="light" textAlign={mine?'right':'left'}>{!mine && player ?`@${player?.username} - `: ''}Delivered {moment(group_message.create_datetime).format('hh:mm a')}</Text>
101
+ </View>
102
+ )
103
+ }
104
+
105
+ export default GroupMessageCard
@@ -0,0 +1,403 @@
1
+ import React from 'react';
2
+ import moment from "moment-mini";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { ActivityIndicator, FlatList, Image } from "react-native"
5
+ import { useColors } from "../../constants/useColors";
6
+ import type { GroupMessageProps, GroupPlayerProps, GroupProps, MyPlayerProps, OrderProps, PublicPlayerProps, TextTagProps } from "../../types";
7
+ import { SocialComponentApi, SocialComponentHelpers } from "../api";
8
+ import { Button, Text, View } from "../../Components/Themed";
9
+ import GroupMessageCard from './components/GroupMessageCard';
10
+ import InputBar from '../InputBar';
11
+ import FormattedTextInput from '../FormattedTextInput';
12
+ import SocketManager from '../../Socket';
13
+ import SocialOrdersList from '../SocialOrdersList';
14
+
15
+ type GroupChatProps = {
16
+ group_id?:string,
17
+ my_id?:string,
18
+ player_id?:string,
19
+ access_token?:string,
20
+ onClose?:() => void,
21
+ width:number,
22
+ onCopyOrder?:(order:OrderProps) => void,
23
+ onFadeOrder?:(order:OrderProps) => void
24
+ insets?:{ top:number, bottom:number, left:number, right:number }
25
+ distinct_id:string,
26
+ onSelectTag: (tag:TextTagProps) => void,
27
+ onSelectImage:(image: { url:string, height?:number, width?:number }) => void,
28
+ onFocusPosition?:(position:{ height:number, width:number, x:number, y:number }) => void
29
+ }
30
+ const sections = ['orders','input_bar','input']
31
+ const GroupChat = ({ my_id, player_id, width, group_id, access_token, insets, distinct_id, onCopyOrder, onFadeOrder, onClose, onFocusPosition, onSelectImage, onSelectTag }:GroupChatProps) => {
32
+ const Colors = useColors();
33
+ const [ chat_size, setChatSize ] = useState({ height:0, width:0 });
34
+ const [ show_input_bar, setShowInputBar ] = useState(false);
35
+ const [ needs_reload, setNeedsReload ] = useState(false);
36
+ const [ message_loading, setMessageLoading ] = useState(false);
37
+ const [ socket_message, setSocketMessage ] = useState<GroupMessageProps|undefined>(undefined);
38
+ const [ draft_orders, setDraftOrders ] = useState<OrderProps[]>([]);
39
+ const [ my_data, setMyData ] = useState<{
40
+ me?: MyPlayerProps
41
+ }>({});
42
+ const { me } = my_data;
43
+ const [ screen_data, setData ] = useState<{
44
+ loading:boolean,
45
+ group?:GroupProps,
46
+ group_players:GroupPlayerProps[]
47
+ }>({
48
+ loading:false,
49
+ group_players: []
50
+ })
51
+ const { loading, group } = screen_data;
52
+
53
+ const [ message_data, setMessageData ] = useState<{
54
+ messages_loading:boolean,
55
+ messages: GroupMessageProps[],
56
+ players:PublicPlayerProps[],
57
+
58
+ orders:OrderProps[]
59
+ }>({
60
+ messages_loading: false,
61
+ messages:[],
62
+ players:[],
63
+ orders:[]
64
+ });
65
+ const { messages, players, orders } = message_data
66
+ const chat_ref = useRef(null);
67
+
68
+ const unique_dates = [ ...new Set(messages.map(m => moment(m.create_datetime).format('MMM DD YYYY')))]
69
+
70
+ useEffect(() => {
71
+ SocialComponentApi.setEnvironment();
72
+ if(group_id){
73
+ getGroupFromServer(group_id);
74
+ return
75
+ }
76
+ if(player_id){
77
+ getChatFromServer(player_id);
78
+ return
79
+ }
80
+ },[group_id, player_id]);
81
+
82
+ useEffect(() => {
83
+ if(!my_id){ return }
84
+ getMyData();
85
+ },[my_id]);
86
+
87
+ const getMyData = async() => {
88
+ const player = await SocialComponentApi.getMyDetails();
89
+ setMyData({ me:player })
90
+ }
91
+
92
+ useEffect(() => {
93
+ if(!socket_message){ return }
94
+ getNewData(socket_message)
95
+ },[socket_message]);
96
+
97
+ const getNewData = async(message:GroupMessageProps) => {
98
+ const new_resp = await SocialComponentHelpers.addDataToMessages([message]);
99
+ setMessageData({
100
+ ...message_data,
101
+ messages: messages.filter(m => m.group_message_id != message.group_message_id).concat(new_resp.group_messages),
102
+ players: players.filter(p => !new_resp.players.find(np => np.player_id == p.player_id)).concat(new_resp.players),
103
+ orders: orders.filter(p => !new_resp.orders.find(np => np.order_id == p.order_id)).concat(new_resp.orders),
104
+ });
105
+ }
106
+
107
+ const chat_player = group?.type == 'direct' ? players.find(p => p.player_id == player_id) : undefined
108
+
109
+ const getChatFromServer = async(id:string) => {
110
+ setData({ ...screen_data, loading:true });
111
+ if(!my_id){ return }
112
+ setMessageData({ ...message_data, messages_loading:true });
113
+ const group_response = await SocialComponentApi.getChat(id);
114
+ if(!group_response){ return setData({ ...screen_data, loading:false }) }
115
+ const gm_data = await SocialComponentHelpers.addDataToMessages(group_response.group_messages);
116
+
117
+ setData({
118
+ ...screen_data,
119
+ group: group_response.group,
120
+ group_players: group_response.group_players,
121
+ loading: false
122
+ });
123
+ setMessageData({
124
+ ...message_data,
125
+ messages_loading:false,
126
+ players: gm_data.players,
127
+ messages: gm_data.group_messages,
128
+ orders: gm_data.orders
129
+ });
130
+ }
131
+
132
+ const getGroupFromServer = async(id:string) => {
133
+ setData({ ...screen_data, loading:true });
134
+ setMessageData({ ...message_data, messages_loading:true });
135
+ const group_response = await SocialComponentApi.getGroupById(id);
136
+ if(!group_response){ return setData({ ...screen_data, loading:false }) }
137
+ const gm_data = await SocialComponentHelpers.addDataToMessages(group_response.group_messages);
138
+ setData({
139
+ ...screen_data,
140
+ group: group_response.group,
141
+ group_players: group_response.group_players,
142
+ loading: false
143
+ });
144
+ setMessageData({
145
+ ...message_data,
146
+ messages_loading:false,
147
+ players: gm_data.players,
148
+ messages: gm_data.group_messages,
149
+ orders: gm_data.orders
150
+ });
151
+ }
152
+
153
+ //const message_valid = message_text != '' ? true : false
154
+
155
+ const handleSendImage = async(image:any) => {
156
+ if(!group || message_loading){ return }
157
+ setMessageLoading(true);
158
+ const group_message = SocialComponentHelpers.getEmptyMessage();
159
+ const gm = await SocialComponentApi.sendChat({
160
+ ...group_message,
161
+ formatted_text: '',
162
+ tags: [],
163
+ message_images: [image],
164
+ group_id: group.group_id,
165
+ message: ''
166
+ });
167
+ if(!gm){
168
+ setMessageLoading(false);
169
+ return
170
+ }
171
+ setMessageData({
172
+ ...message_data,
173
+ messages: messages.filter(m => m.group_message_id != gm.group_message_id).concat(gm)
174
+ })
175
+ setMessageLoading(false);
176
+
177
+ }
178
+
179
+ const handleSendMessage = async(data: { formatted_text: string, text:string }, tags:TextTagProps[]) => {
180
+ if(!group || message_loading){ return }
181
+ setMessageLoading(true);
182
+
183
+ //Find urls!
184
+ const url = SocialComponentHelpers.getUrlsFromString(data.text);
185
+ let message_urls:string[] = []
186
+ if(url){ message_urls.push(url) }
187
+ const group_message = SocialComponentHelpers.getEmptyMessage();
188
+ const gm = await SocialComponentApi.sendChat({
189
+ ...group_message,
190
+ formatted_text: data.formatted_text,
191
+ tags: tags.map(t => { return { ...t, data:undefined } }), //Drop the data!
192
+ group_id: group.group_id,
193
+ message_urls: message_urls,
194
+ message_orders:draft_orders.map(o => o.order_id),
195
+ message: data.text
196
+ });
197
+ if(!gm){
198
+ setMessageLoading(false);
199
+ return
200
+ }
201
+ setMessageData({
202
+ ...message_data,
203
+ messages: messages.filter(m => m.group_message_id != gm.group_message_id).concat(gm)
204
+ })
205
+ setMessageLoading(false);
206
+ }
207
+
208
+ const renderMessages = (data:{item:GroupMessageProps, index:number}) => {
209
+ const player = players.find(p => p.player_id == data.item.player_id)
210
+ const mine = player?.player_id == me?.player_id ? true: false
211
+ let post_orders = data.item.message_orders ? orders.filter(o => data.item.message_orders?.includes(o.order_id)) : []
212
+ return (
213
+ <View style={{ margin:5 }}>
214
+ <GroupMessageCard
215
+ player={player}
216
+ me={me}
217
+ width={chat_size.width}
218
+ mine={mine}
219
+ onCopyOrder={onCopyOrder}
220
+ onFadeOrder={onFadeOrder}
221
+ orders={post_orders}
222
+ onSelectImage={onSelectImage}
223
+ group_message={data.item}
224
+ onSelectTag={onSelectTag}
225
+ />
226
+
227
+ </View>
228
+ )
229
+ }
230
+
231
+ const renderDates = (data:{ item:string, index:number }) => {
232
+ const date_messages = messages.filter(m => moment(m.create_datetime).format('MMM DD YYYY') == data.item);
233
+
234
+ return (
235
+ <View>
236
+ <View style={{ padding:10 }}>
237
+ <Text size={16} theme="light" textAlign="center">{data.item}</Text>
238
+ </View>
239
+ <FlatList
240
+ key={'date_messages'}
241
+ keyExtractor={(item) => item.group_message_id.toString()}
242
+ data={date_messages.sort((a,b) => moment(a.create_datetime).unix() - moment(b.create_datetime).unix())}
243
+ renderItem={renderMessages}
244
+ />
245
+ </View>
246
+ )
247
+ }
248
+
249
+
250
+ const renderSections = (data: { item:string, index:number }) => {
251
+ switch(data.item){
252
+ case 'orders':
253
+ if(draft_orders.length == 0){ return <></> }
254
+ return (
255
+ <View >
256
+ <SocialOrdersList
257
+ players={players}
258
+ orders={draft_orders}
259
+ onUntagOrder={(order) => setDraftOrders(draft_orders.filter(o => o.order_id != order.order_id))}
260
+ direction='horizontal'
261
+ />
262
+ </View>
263
+ )
264
+ case 'input_bar':
265
+ if(!show_input_bar){ return <></> }
266
+ return (
267
+ <View type='header' style={{ padding:5 }}>
268
+ <InputBar
269
+ actions={['image','action']}
270
+ width={width}
271
+ insets={insets}
272
+ onTagOrder={(order) => {
273
+ setDraftOrders(draft_orders.filter(o => o.order_id != order.order_id).concat(order))
274
+ }}
275
+ onImageUpload={(image) => handleSendImage(image)}
276
+ />
277
+ </View>
278
+ )
279
+ case 'input':
280
+ return (
281
+ <View type='footer' style={{ padding:5, paddingBottom:(insets?.bottom ?? 0) + 5 }}>
282
+ <FormattedTextInput
283
+ submit_placement='inline'
284
+ icon_submit
285
+ width={chat_size.width}
286
+ onSelectInput={() => setShowInputBar(!show_input_bar)}
287
+ onSubmit={(data, tags) => handleSendMessage(data, tags)}
288
+ onFocusPosition={onFocusPosition}
289
+ />
290
+ </View>
291
+ )
292
+ default: return <></>
293
+ }
294
+ }
295
+
296
+ return (
297
+ <View style={{ flex:1 }} onLayout={(ev) => {
298
+ const { height, width } = ev.nativeEvent.layout;
299
+ setChatSize({ height, width });
300
+ }}>
301
+ {group?.type == 'direct' && chat_player ?
302
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, paddingTop:(insets?.top ?? 0) + 10 }}>
303
+ <View transparent>
304
+ <Image
305
+ source={{ uri: chat_player.profile_pic }}
306
+ style={{ height:40, width:40, borderRadius:100 }}
307
+ resizeMode="cover"
308
+ />
309
+ </View>
310
+ <View transparent style={{ flex:1, marginLeft:10 }}>
311
+ <Text theme="h1">@{chat_player.username}</Text>
312
+ <Text style={{ marginTop:3 }} theme="description">Joined {moment(chat_player.create_datetime).fromNow()}</Text>
313
+ </View>
314
+ {onClose ?
315
+ <Button
316
+ type="close"
317
+ title="X"
318
+ float
319
+ style={{ padding:0, borderRadius:100, justifyContent:'center', alignItems:'center', height:30, width:30 }}
320
+ onPress={() => onClose()}
321
+ />
322
+ :<></>}
323
+ </View>
324
+ :group ?
325
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, paddingTop:(insets?.top ?? 0) + 10 }}>
326
+ <View transparent>
327
+ <Image
328
+ source={{ uri: group.group_image?.url }}
329
+ style={{ height:40, width:40, borderRadius:100 }}
330
+ resizeMode="cover"
331
+ />
332
+ </View>
333
+ <View transparent style={{ flex:1, marginLeft:10 }}>
334
+ <Text theme="h1">{group.name}</Text>
335
+ <Text style={{ marginTop:3 }} theme="description">{moment(group.last_update_datetime).format('YYYY MM DD')}</Text>
336
+ </View>
337
+ {onClose ?
338
+ <Button
339
+ type="close"
340
+ title="X"
341
+ float
342
+ style={{ padding:0, borderRadius:100, justifyContent:'center', alignItems:'center', height:30, width:30 }}
343
+ onPress={() => onClose()}
344
+ />
345
+ :<></>}
346
+ </View>
347
+ :<></>}
348
+ <View style={{ flex:1 }}>
349
+ <FlatList
350
+ ref={chat_ref}
351
+ data={unique_dates}
352
+ inverted
353
+ style={{ flex:1 }}
354
+ renderItem={renderDates}
355
+ key={`chat_${group_id}dates`}
356
+ keyExtractor={(item) => item}
357
+ />
358
+ </View>
359
+ <View>
360
+ <FlatList
361
+ data={sections}
362
+ key={'chat_sections'}
363
+ scrollEnabled={false}
364
+ keyExtractor={item => item}
365
+ renderItem={renderSections}
366
+ />
367
+ </View>
368
+ {group ?
369
+ <SocketManager
370
+ distinct_id={distinct_id}
371
+ access_token={access_token}
372
+ group_id={group.group_id}
373
+ subscribed_events={['V1_UPDATE_GROUP_MESSAGE']}
374
+ onConnect={() => {
375
+ if(!needs_reload){ return }
376
+ if(group_id){ return getGroupFromServer(group_id) }
377
+ if(player_id){ return getChatFromServer(player_id) }
378
+ return
379
+ }}
380
+ onDisconnect={() => {
381
+ setNeedsReload(true)
382
+ }}
383
+ onSocketEvent={(ev) => {
384
+ if(!ev.data){ return }
385
+ let gm:GroupMessageProps = ev.data;
386
+ if(gm.group_id != group.group_id){ return }
387
+ setSocketMessage(gm);
388
+ }}
389
+ />
390
+ :<></>}
391
+ {loading ?
392
+ <View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0, alignItems:'center', padding:20 }}>
393
+ <ActivityIndicator
394
+ size='large'
395
+ color={Colors.text.h1}
396
+ />
397
+ </View>
398
+ :<></>}
399
+ </View>
400
+ )
401
+ }
402
+
403
+ export default GroupChat
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { Image } from "react-native"
3
+ import { Button } from "../Components/Themed";
4
+
5
+ type ImageRendererProps = {
6
+ image: { url:string, height?:number, width?:number },
7
+ style?:any,
8
+ width: number,
9
+ max_height?:number,
10
+ allow_aspect_change?:boolean,
11
+ onSelectImage?:(image:{ url:string, height?:number, width?:number, [key:string]:any }) => void
12
+ }
13
+ const ImageRenderer = ({ image, width, onSelectImage, max_height, style, allow_aspect_change }:ImageRendererProps) => {
14
+ const getImageRatio = () => {
15
+ let ratio = 1
16
+ if(image.width && image.height){
17
+ ratio = image.width / image.height
18
+ }
19
+ return ratio
20
+ }
21
+ const ratio = getImageRatio();
22
+
23
+ let image_width = width
24
+ let image_height = width * ratio
25
+
26
+ if(max_height && image_height > max_height){
27
+ image_height = max_height
28
+ if(!allow_aspect_change){ image_width = image_height / ratio }
29
+ }
30
+
31
+ return (
32
+ <Button disabled={!onSelectImage} transparent style={{ padding:0 }} onPress={() => onSelectImage ? onSelectImage(image) : console.log('')}>
33
+ <Image
34
+ source={{ uri: image.url }}
35
+ style={{ height: image_height, width: image_width, ...style }}
36
+ resizeMode="cover"
37
+ />
38
+ </Button>
39
+ )
40
+ }
41
+
42
+ export default ImageRenderer