be-components 5.1.8 → 5.1.9

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 +47 -24
  6. package/lib/commonjs/SocialComponents/FormattedTextInput/components/TagSelector.js.map +1 -1
  7. package/lib/commonjs/SocialComponents/FormattedTextInput/index.js +41 -8
  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 +89 -0
  14. package/lib/commonjs/SocialComponents/GroupChat/components/GroupMessageCard.js.map +1 -0
  15. package/lib/commonjs/SocialComponents/GroupChat/index.js +426 -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 +8 -3
  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 +383 -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 +48 -25
  46. package/lib/module/SocialComponents/FormattedTextInput/components/TagSelector.js.map +1 -1
  47. package/lib/module/SocialComponents/FormattedTextInput/index.js +41 -8
  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 +82 -0
  54. package/lib/module/SocialComponents/GroupChat/components/GroupMessageCard.js.map +1 -0
  55. package/lib/module/SocialComponents/GroupChat/index.js +418 -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 +8 -3
  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 +383 -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 +2 -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 +11 -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 +14 -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 +2 -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 +89 -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 -2
  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 +11 -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 +14 -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 +3 -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 +89 -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 +2 -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 +18 -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 +25 -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 +2 -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 +37 -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 +24 -17
  202. package/src/SocialComponents/FormattedTextInput/index.tsx +32 -7
  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 +84 -0
  206. package/src/SocialComponents/GroupChat/index.tsx +333 -0
  207. package/src/SocialComponents/ImageRenderer.tsx +42 -0
  208. package/src/SocialComponents/InputBar/components/ActionSelector.tsx +164 -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 +4 -6
  215. package/src/SocialComponents/SocialOrdersList.tsx +14 -8
  216. package/src/SocialComponents/UrlPreviewCard.tsx +75 -0
  217. package/src/SocialComponents/api/index.ts +345 -3
  218. package/src/SocialComponents/index.tsx +4 -0
  219. package/src/types.d.ts +58 -0
@@ -0,0 +1,264 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Button, Text, TextInput, View } from "../../Components/Themed"
3
+ import FormattedTextInput from '../FormattedTextInput';
4
+ import InputBar from '../InputBar';
5
+ import type { OrderProps, PostProps, PublicPlayerProps, TextTagProps } from '../../types';
6
+ import { SocialComponentApi, SocialComponentHelpers } from '../api';
7
+ import ImageList from '../PostCard/components/ImageList';
8
+ import { useColors } from '../../constants/useColors';
9
+ import { Icons } from '../../Components';
10
+ import { FlatList } from 'react-native';
11
+ import SocialOrdersList from '../SocialOrdersList';
12
+
13
+ type PosterProps = {
14
+ width:number,
15
+ post_id?:string,
16
+ insets?:{ top:number, left:number, right:number, bottom:number },
17
+ onCreatePost:(post:PostProps) => void
18
+ }
19
+
20
+ const sections = ['input_bar','title','post','orders','images']
21
+ const Poster = ({ width, post_id, insets, onCreatePost }: PosterProps) => {
22
+ const Colors = useColors();
23
+ const [ submit_caller, setSubmitCaller ] = useState<string|undefined>(undefined);
24
+ const [ post_data, setPostData ] = useState<{
25
+ draft_post?:PostProps,
26
+ players:PublicPlayerProps[],
27
+ post?:PostProps,
28
+ orders:OrderProps[],
29
+ action_loading:boolean
30
+ }>({
31
+ action_loading: false,
32
+ players:[],
33
+ orders:[]
34
+ });
35
+
36
+ const { post, draft_post, action_loading, orders } = post_data;
37
+ const valid = SocialComponentHelpers.isPostValid(draft_post);
38
+
39
+ useEffect(() => {
40
+ SocialComponentApi.setEnvironment();
41
+ setUpPost(post_id);
42
+ },[post_id]);
43
+
44
+ const setUpPost = async(post_id?:string) => {
45
+ let existing_post:PostProps | undefined
46
+ let ords:OrderProps[] = []
47
+ let playrs:PublicPlayerProps[] = []
48
+ if(post_id){
49
+ existing_post = await SocialComponentApi.getPostById(post_id);
50
+ if(existing_post){
51
+ const set_up_data = await SocialComponentHelpers.getPostsData([existing_post]);
52
+ ords = set_up_data.orders
53
+ playrs = set_up_data.players
54
+ }
55
+
56
+ } //Not set up to handle this yet!
57
+ setPostData({
58
+ ...post_data,
59
+ orders: ords,
60
+ players: playrs,
61
+ draft_post: existing_post ?? SocialComponentHelpers.getEmptyPost(),
62
+ post: existing_post
63
+ })
64
+ }
65
+
66
+ const handlePublishPost = async(data:{ text:string, formatted_text:string }, tags:TextTagProps[]) => {
67
+ if(!draft_post || action_loading || !valid){ return }
68
+ setPostData({
69
+ ...post_data,
70
+ action_loading:true
71
+ });
72
+ //Drop data on tags
73
+ tags = tags.map(t => { return { ...t, data: undefined } });
74
+ let saved_post:PostProps | undefined = undefined
75
+
76
+ //Lets check for urls
77
+ const url = SocialComponentHelpers.getUrlsFromString(data.text.toLowerCase());
78
+ console.log(url)
79
+ let memo_urls:string[] = []
80
+ if(url){ memo_urls.push(url) }
81
+
82
+ if(draft_post.memo_post_id){
83
+ saved_post = await SocialComponentApi.updatePost({ ...draft_post, memo_urls, tags: tags, body: data.text, formatted_text: data.formatted_text });
84
+ } else {
85
+ saved_post = await SocialComponentApi.createPost({ ...draft_post, memo_urls, tags: tags, body: data.text, formatted_text: data.formatted_text });
86
+ }
87
+ setPostData({
88
+ ...post_data,
89
+ action_loading:false
90
+ });
91
+ if(!saved_post){ return }
92
+ onCreatePost(saved_post);
93
+ }
94
+
95
+ const renderSections = (data:{ item:string, index:number }) => {
96
+ switch(data.item){
97
+ case 'input_bar':
98
+ return (
99
+ <View style={{ borderBottomWidth:1, borderColor:Colors.borders.light }}>
100
+ <InputBar
101
+ actions={['image','action']}
102
+ insets={insets}
103
+ width={width}
104
+ onTagOrder={(order) => {
105
+ if(!draft_post){ return }
106
+ let exists = draft_post.memo_orders.find(o => o == order.order_id);
107
+ if(exists){
108
+ setPostData({
109
+ ...post_data,
110
+ orders: orders.filter(o => o.order_id != order.order_id),
111
+ draft_post: {
112
+ ...draft_post,
113
+ memo_orders: draft_post.memo_orders.filter(o => o != order.order_id)
114
+ }
115
+ })
116
+ } else {
117
+ //Lets check if its already included!
118
+ setPostData({
119
+ ...post_data,
120
+ orders: orders.filter(o => o.order_id != order.order_id).concat(order),
121
+ draft_post: {
122
+ ...draft_post,
123
+ memo_orders: draft_post.memo_orders.filter(o => o != order.order_id).concat(order.order_id)
124
+ }
125
+ })
126
+ }
127
+ }}
128
+ onImageUpload={(image) => {
129
+ if(!draft_post){ return }
130
+ setPostData({
131
+ ...post_data,
132
+ draft_post: {
133
+ ...draft_post,
134
+ memo_images: draft_post.memo_images.concat(image)
135
+ }
136
+ })
137
+ }}
138
+ />
139
+ </View>
140
+ )
141
+ case 'title':
142
+ if(!draft_post){ return <></> }
143
+ return (
144
+ <View nativeID='title'>
145
+ <TextInput
146
+ style={{ borderWidth:0, fontSize:14 }}
147
+ placeholder='Title'
148
+ value={draft_post.title}
149
+ weight='bold'
150
+ onChangeText={(text) => {
151
+ if(!draft_post){ return }
152
+ setPostData({
153
+ ...post_data,
154
+ draft_post: {
155
+ ...draft_post,
156
+ title: text
157
+ }
158
+
159
+ })
160
+ }}
161
+ />
162
+ </View>
163
+ )
164
+ case 'post':
165
+ if(!draft_post){ return <></> }
166
+ return (
167
+ <View nativeID='post_body'>
168
+ <FormattedTextInput
169
+ hide_border
170
+ width={width}
171
+ disable_scroll
172
+ tag_selector_location='bottom'
173
+ submit_caller={submit_caller}
174
+ init_data={{ text: post?.body ?? '', formatted_text: post?.formatted_text ?? '', tags: post?.tags ?? [] }}
175
+ placeholder='Start typing here ...'
176
+ onSubmit={(data, tags) => handlePublishPost(data, tags)}
177
+ onChangeText={(data) => {
178
+ if(!draft_post){ return }
179
+ setPostData({
180
+ ...post_data,
181
+ draft_post: {
182
+ ...draft_post,
183
+ body: data.text,
184
+ formatted_text: data.formatted_text
185
+ }
186
+
187
+ })
188
+ }}
189
+ />
190
+ </View>
191
+ )
192
+ case 'orders':
193
+ if(!draft_post){ return <></> }
194
+ if(!draft_post.memo_orders){ return <></> }
195
+ return (
196
+ <View style={{ padding:10 }}>
197
+ <SocialOrdersList
198
+ orders={orders.filter(o => draft_post.memo_orders.includes(o.order_id))}
199
+ players={[]}
200
+ onUntagOrder={(order) => {
201
+ if(!draft_post){ return }
202
+ setPostData({
203
+ ...post_data,
204
+ orders: orders.filter(o => o.order_id != order.order_id),
205
+ draft_post: {
206
+ ...draft_post,
207
+ memo_orders: draft_post.memo_orders.filter(o => o != order.order_id)
208
+ }
209
+ })
210
+ }}
211
+ maxWidth={width}
212
+ direction='horizontal'
213
+ />
214
+ </View>
215
+ )
216
+ case 'images':
217
+ if(!draft_post){ return <></> }
218
+ if(!draft_post.memo_images){ return <></> }
219
+ return (
220
+ <View>
221
+ <ImageList
222
+ images={draft_post.memo_images}
223
+ width={width-10}
224
+ post_id=''
225
+ />
226
+ </View>
227
+ )
228
+
229
+ default: return <></>
230
+ }
231
+ }
232
+
233
+
234
+ if(!draft_post){ return <></> }
235
+
236
+ return (
237
+ <View style={{ flex:1 }}>
238
+ <View nativeID='actions' type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, paddingTop:(insets?.top ?? 0) + 10 }}>
239
+ <Button transparent style={{ flexDirection:'row', alignItems:'center' }}>
240
+ <Icons.CloseIcon size={10} color={Colors.text.h1} />
241
+ <Text theme='description' style={{ marginLeft:10 }}>Close</Text>
242
+ </Button>
243
+ <View transparent style={{ flex:1 }} />
244
+ <Button
245
+ title='Publish'
246
+ type='success'
247
+ disabled={!valid}
248
+ loading={action_loading}
249
+ style={{ padding:10, opacity: valid && !action_loading ? 1 : 0.5 }}
250
+ onPress={() => setSubmitCaller(Math.random().toString())}
251
+ />
252
+ </View>
253
+ <FlatList
254
+ data={sections}
255
+ key={`poster_sections`}
256
+ renderItem={renderSections}
257
+ keyExtractor={item => item}
258
+ />
259
+
260
+ </View>
261
+ )
262
+ }
263
+
264
+ export default Poster
@@ -18,14 +18,14 @@ type SocialOrderCardProps = {
18
18
  maxWidth?:number,
19
19
  team?:TeamProps,
20
20
  league?:LeagueProps,
21
+ onTagOrder?:(order:OrderProps) => void,
21
22
  onCopyOrder?:(order:OrderProps) => void,
22
23
  onFadeOrder?:(order:OrderProps) => void
23
24
  }
24
- const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete, order, contest_title, contest_time, onCopyOrder, onFadeOrder }:SocialOrderCardProps) => {
25
+ const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete, order, contest_title, contest_time, onTagOrder, onCopyOrder, onFadeOrder }:SocialOrderCardProps) => {
25
26
  const Colors = useColors();
26
27
  const [ fade_loading, setFadeLoading ] = useState(false);
27
28
  const { result_label, color } = SocialOrderHelpers.getResultDetails(order)
28
-
29
29
  const handleFadeOrder = async() => {
30
30
  if(!onFadeOrder){ return }
31
31
  if(fade_loading){ return }
@@ -49,9 +49,8 @@ const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete,
49
49
  })
50
50
  setFadeLoading(false);
51
51
  }
52
-
53
52
  return (
54
- <View float style={{ minWidth:275, maxWidth }}>
53
+ <Button disabled={!onTagOrder} float style={{ minWidth:275, maxWidth, padding:0, flex:1 }} onPress={() => onTagOrder ? onTagOrder(order) : console.log('')}>
55
54
  {show_player && player ?
56
55
  <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
57
56
  <Image
@@ -67,7 +66,6 @@ const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete,
67
66
  </View>
68
67
  :<></>}
69
68
  <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
70
-
71
69
  <View transparent style={{ flex:1, marginRight:10 }}>
72
70
  <Text theme='description'>{contest_title}</Text>
73
71
  <Text style={{ marginTop:3 }} size={12} theme='light' weight='regular'>{contest_time}</Text>
@@ -147,7 +145,7 @@ const SocialOrderCard = ({ player, show_player, maxWidth, league, team, athlete,
147
145
  :<></>}
148
146
  </View>
149
147
  :<></>}
150
- </View>
148
+ </Button>
151
149
  )
152
150
  }
153
151
 
@@ -3,7 +3,7 @@ import { FlatList } from 'react-native';
3
3
  import type { AthleteProps, EventProps, LeagueProps, MatchProps, OrderProps, PublicPlayerProps, TeamProps, TournamentProps } from '../types';
4
4
  import SocialOrderCard from './SocialOrderCard';
5
5
  import { SocialComponentApi, SocialOrderHelpers } from './api';
6
- import { View } from '../Components/Themed';
6
+ import { Button, View } from '../Components/Themed';
7
7
 
8
8
  type SocialOrdersListProps = {
9
9
  players:PublicPlayerProps[],
@@ -11,10 +11,11 @@ type SocialOrdersListProps = {
11
11
  orders:OrderProps[],
12
12
  maxWidth?:number,
13
13
  direction: 'vertical'|'horizontal',
14
+ onUntagOrder?:(order:OrderProps) => void,
14
15
  onCopyOrder?:(order:OrderProps) => void,
15
16
  onFadeOrder?:(order:OrderProps) => void
16
17
  }
17
- const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, onCopyOrder, onFadeOrder }:SocialOrdersListProps) => {
18
+ const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, onUntagOrder, onCopyOrder, onFadeOrder }:SocialOrdersListProps) => {
18
19
  const [list_data, setListData] = useState<{
19
20
  loading:boolean,
20
21
  leagues:LeagueProps[],
@@ -33,13 +34,11 @@ const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, o
33
34
  teams:[]
34
35
  });
35
36
  const { leagues, events, tournaments, matches, athletes, teams } = list_data;
36
-
37
37
  useEffect(() => {
38
38
  SocialComponentApi.setEnvironment()
39
39
  getDataFromServer();
40
40
  },[orders.length])
41
41
 
42
-
43
42
  const getDataFromServer = async() => {
44
43
  setListData({ ...list_data, loading:true });
45
44
  //Get event_ids
@@ -61,7 +60,6 @@ const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, o
61
60
  athletes: a,
62
61
  teams: tm
63
62
  })
64
-
65
63
  }
66
64
 
67
65
 
@@ -69,7 +67,7 @@ const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, o
69
67
  let { title, time, league, team, athlete } = SocialOrderHelpers.getContestDetails(data.item, events, tournaments, matches, athletes, teams, leagues);
70
68
  let player = players.find(p => p.player_id == data.item.player_id)
71
69
  return (
72
- <View style={{ margin:5 }}>
70
+ <View transparent style={{ margin:5 }}>
73
71
  <SocialOrderCard
74
72
  show_player={show_player}
75
73
  player={player}
@@ -83,12 +81,20 @@ const SocialOrdersList = ({ maxWidth, players, show_player, orders, direction, o
83
81
  onFadeOrder={onFadeOrder}
84
82
  onCopyOrder={onCopyOrder}
85
83
  />
84
+ {onUntagOrder ?
85
+ <Button
86
+ float
87
+ type='error'
88
+ style={{ padding:0, justifyContent:'center', alignItems:'center', height:30, width:30, borderRadius:100, position:'absolute', top:5, left:5 }}
89
+ title='X'
90
+ onPress={() => onUntagOrder(data.item)}
91
+ />
92
+ :<></>}
86
93
  </View>
87
94
  )
88
95
  }
89
-
90
96
  return (
91
- <View style={{ justifyContent:'center' }}>
97
+ <View style={{ flex:1 }}>
92
98
  <FlatList
93
99
  data={orders}
94
100
  renderItem={renderOrders}
@@ -0,0 +1,75 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Button, Text, View } from "../Components/Themed"
3
+ import type { URLMetadataProps } from '../types';
4
+ import { SocialComponentApi } from './api';
5
+ import { ActivityIndicator, Linking } from 'react-native';
6
+ import { useColors } from '../constants/useColors';
7
+ import ImageRenderer from './ImageRenderer';
8
+
9
+ type UrlPreviewCardProps = {
10
+ url:string,
11
+ width:number,
12
+ max_height?:number
13
+ color?:string
14
+ }
15
+ const UrlPreviewCard = ({ url, color, width, max_height }:UrlPreviewCardProps) => {
16
+ const Colors = useColors();
17
+ const [ data, setData ] = useState<{
18
+ loading:boolean,
19
+ url_metadata?: URLMetadataProps
20
+ }>({
21
+ loading: false
22
+ });
23
+ const { loading, url_metadata } = data;
24
+
25
+ useEffect(() => {
26
+ if(!url){ return }
27
+ getMetadata(url)
28
+ },[url])
29
+
30
+ const getMetadata = async(url:string) => {
31
+ setData({ ...data, loading:true })
32
+ const metadata = await SocialComponentApi.getUrlMetadata(url);
33
+ setData({
34
+ ...data,
35
+ loading: false,
36
+ url_metadata: metadata
37
+ })
38
+
39
+ }
40
+
41
+ return (
42
+ <Button float transparent style={{ padding:0, width, marginBottom:10 }} onPress={() => Linking.openURL(url)}>
43
+ {loading ?
44
+ <ActivityIndicator
45
+ style={{ padding:20, alignSelf:'center' }}
46
+ size={'large'}
47
+ color={color ?? Colors.text.h1}
48
+ />
49
+ :<></>}
50
+ {url_metadata?.ogTitle ?
51
+ <View transparent nativeID='CARD' style={{ borderTopRightRadius:8, borderTopLeftRadius:8 }}>
52
+ {url_metadata.ogImage?.url ?
53
+ <ImageRenderer
54
+ image={{ url: url_metadata.ogImage.url, width: parseFloat(url_metadata.ogImage.width), height: parseFloat(url_metadata.ogImage.height) }}
55
+ width={width - 1}
56
+ allow_aspect_change
57
+ max_height={max_height}
58
+ style={{ borderTopRightRadius:8, borderTopLeftRadius:8 }}
59
+ />
60
+ :<></>}
61
+ <View type='footer' style={{ padding:10, borderBottomRightRadius: 8, borderBottomLeftRadius:8 }}>
62
+ <Text theme='h2' style={{ paddingBottom:2, borderBottomWidth:1, borderColor:Colors.borders.light }}>{url_metadata?.ogTitle}</Text>
63
+ <Text theme='description' style={{ marginTop:4 }}>{url_metadata?.ogDescription}</Text>
64
+ </View>
65
+ </View>
66
+ :
67
+ <View type='header' nativeID='CARD' style={{ borderRadius:8, padding:10 }}>
68
+ <Text theme='action'>{url}</Text>
69
+ </View>
70
+ }
71
+ </Button>
72
+ )
73
+ }
74
+
75
+ export default UrlPreviewCard