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
@@ -10,10 +10,15 @@ import { useColors } from '../../constants/useColors';
10
10
  type FormattedTextInputProps = {
11
11
  onChangeText?: (data:{ text:string, formatted_text:any }) => void,
12
12
  submit_title?:string,
13
+ submit_caller?:string,
13
14
  submit_loading?:boolean,
14
15
  keep_on_submit?:boolean,
16
+ hide_border?:boolean,
17
+ disable_scroll?:boolean,
15
18
  icon_submit?:boolean,
19
+ width:number
16
20
  placeholder?:string,
21
+ tag_selector_location?:'bottom'|'top',
17
22
  onSelectInput?:() => void
18
23
  submit_placement?:'inline'|'bottom',
19
24
  onFocusPosition?:(position:{ height:number, width:number, x:number, y:number }) => void
@@ -21,7 +26,7 @@ type FormattedTextInputProps = {
21
26
  onSubmit:(data:{ text:string, formatted_text:any }, tags:TextTagProps[]) => void
22
27
  }
23
28
 
24
- const FormattedTextInput = ({ submit_title, icon_submit, keep_on_submit, submit_placement, placeholder, init_data, onSelectInput, onChangeText, onSubmit, onFocusPosition }:FormattedTextInputProps) => {
29
+ const FormattedTextInput = ({ width, disable_scroll, submit_title, hide_border, tag_selector_location, icon_submit, keep_on_submit, submit_caller, submit_placement, placeholder, init_data, onSelectInput, onChangeText, onSubmit, onFocusPosition }:FormattedTextInputProps) => {
25
30
  const Colors = useColors();
26
31
  const [ input_state, setInputState ] = useState<{
27
32
  height:number
@@ -56,13 +61,18 @@ const FormattedTextInput = ({ submit_title, icon_submit, keep_on_submit, submit_
56
61
  const [ action_loading, setActionLoading ] = useState(false);
57
62
  const [ working_tag, setWorkingTag ] = useState<TextTagProps | undefined>();
58
63
 
64
+ useEffect(() => {
65
+ if(!submit_caller){ return }
66
+ handleSubmit();
67
+ },[submit_caller])
68
+
59
69
  useEffect(() => {
60
70
  SocialComponentApi.setEnvironment();
61
71
  if(init_data){
62
72
  setData({ text: init_data.text, formatted_text: init_data.formatted_text });
63
73
  setValidTags(init_data.tags)
64
74
  }
65
- },[init_data])
75
+ },[JSON.stringify(init_data)])
66
76
 
67
77
  useEffect(() => {
68
78
  if(active_tag){ return setWorkingTag(active_tag) }
@@ -75,7 +85,7 @@ const FormattedTextInput = ({ submit_title, icon_submit, keep_on_submit, submit_
75
85
  },[active_tag]);
76
86
 
77
87
  const validateTag = async(tag:TextTagProps) => {
78
- let new_tags = valid_tags.filter(t => t.local_id != tag.local_id).concat(tag);
88
+ let new_tags = valid_tags.concat({ ...tag });
79
89
  setValidTags(new_tags);
80
90
  }
81
91
 
@@ -108,7 +118,7 @@ const FormattedTextInput = ({ submit_title, icon_submit, keep_on_submit, submit_
108
118
  const handleUpdateTag = async(tag:TextTagProps) => {
109
119
  setActionLoading(true);
110
120
  const new_text = SocialComponentHelpers.replaceText(text, tag.start, tag.end, `@${tag.tag}`);
111
- setValidTags(valid_tags.concat({ ...tag }));
121
+ validateTag(tag)
112
122
  setData({
113
123
  ...data,
114
124
  text: new_text
@@ -123,6 +133,7 @@ const FormattedTextInput = ({ submit_title, icon_submit, keep_on_submit, submit_
123
133
  onSubmit({ text, formatted_text }, new_tags);
124
134
  if(keep_on_submit){ return }
125
135
  setData({ text: '', formatted_text: JSON.stringify('') });
136
+ setInputState({ ...input_state, height: 50 })
126
137
  setValidTags([]);
127
138
  }
128
139
 
@@ -139,23 +150,24 @@ const FormattedTextInput = ({ submit_title, icon_submit, keep_on_submit, submit_
139
150
  return (
140
151
  <View transparent>
141
152
  <View transparent>
142
- {tag_selector.visible && tag_selector.working_tag ?
153
+ {tag_selector.visible && tag_selector.working_tag && tag_selector_location != 'bottom' ?
143
154
  <TagSelector
144
155
  working_tag={tag_selector.working_tag}
145
156
  type={tag_selector.type}
157
+ width={width}
146
158
  visible={tag_selector.visible}
147
159
  onCancel={() => setTagSelector({ visible: false, type: 'player' })}
148
160
  onSelectTag={(tag) => handleUpdateTag(tag)}
149
161
  />
150
162
  :<></>}
151
163
  </View>
152
- <View style={{ flexDirection:'row', alignItems:'flex-end' }}>
164
+ <View transparent style={{ flexDirection:'row', alignItems:'flex-end' }}>
153
165
  {onSelectInput ?
154
166
  <Button float style={{ padding:10, width:45, marginRight:5, borderRadius:8, justifyContent:'center', alignItems:'center' }} onPress={() => onSelectInput()}>
155
167
  <Icons.MoreIcon size={24} color={Colors.text.h1} />
156
168
  </Button>
157
169
  :<></>}
158
- <View type='input' style={{ flex:1, flexDirection:'row' }}>
170
+ <View type={hide_border?undefined:'input'} style={{ flex:1, flexDirection:'row' }}>
159
171
  <TextInput
160
172
  value={text}
161
173
  editable={!action_loading}
@@ -163,6 +175,7 @@ const FormattedTextInput = ({ submit_title, icon_submit, keep_on_submit, submit_
163
175
  loading={action_loading}
164
176
  focus_on_unload
165
177
  transparent
178
+ scrollEnabled={!disable_scroll}
166
179
  placeholder={placeholder ?? 'Start typing here...'}
167
180
  onFocusPosition={onFocusPosition}
168
181
  style={{ flex:1, height: Platform.OS == 'web' ? height : undefined }}
@@ -190,6 +203,18 @@ const FormattedTextInput = ({ submit_title, icon_submit, keep_on_submit, submit_
190
203
  </Button>
191
204
  :<></>}
192
205
  </View>
206
+ {tag_selector.visible && tag_selector.working_tag && tag_selector_location == 'bottom' ?
207
+ <View transparent style={{ height:100 }}>
208
+ <TagSelector
209
+ working_tag={tag_selector.working_tag}
210
+ type={tag_selector.type}
211
+ width={width}
212
+ visible={tag_selector.visible}
213
+ onCancel={() => setTagSelector({ visible: false, type: 'player' })}
214
+ onSelectTag={(tag) => handleUpdateTag(tag)}
215
+ />
216
+ </View>
217
+ :<></>}
193
218
  {submit_placement == 'bottom' ?
194
219
  <Button
195
220
  title={submit_title ?? 'Submit'}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { Text, View } from "../../Components/Themed"
3
+
4
+ const GifyNativeSelector = () => {
5
+ return (
6
+ <View>
7
+ <Text>Hey</Text>
8
+ </View>
9
+ )
10
+ }
11
+
12
+ export default GifyNativeSelector
13
+
@@ -0,0 +1,91 @@
1
+ import React, { useContext, useEffect, useState } from 'react';
2
+
3
+ import { GiphyFetch } from '@giphy/js-fetch-api'
4
+
5
+ import {
6
+ Grid, // our UI Component to display the results
7
+ SearchBar, // the search bar the user will type into
8
+ SearchContext, // the context that wraps and connects our components
9
+ SearchContextManager, // the context manager, includes the Context.Provider
10
+ SuggestionBar, // an optional UI component that displays trending searches and channel / username results
11
+ } from '@giphy/react-components';
12
+
13
+ const gf = new GiphyFetch('MPKLmL5j0G3TesyhtNeDTE0nZ3F8CKCB')
14
+ import { Button, View } from '../../Components/Themed';
15
+ import { Modal, Platform, ScrollView } from 'react-native';
16
+
17
+ // the search experience consists of the manager and its child components that use SearchContext
18
+ type GifySelectModalProps = {
19
+ isVisible:boolean,
20
+ width:number,
21
+ view_mode:'desktop'|'mobile',
22
+ gifSelect:any,
23
+ closeModal:any
24
+ }
25
+
26
+ const WebGifySelector = ({ isVisible, gifSelect, closeModal, view_mode, width }:GifySelectModalProps) => {
27
+ if(!isVisible){ return (<></>) }
28
+ if(Platform.OS != 'web'){ return <></> }
29
+ return (
30
+ <Modal
31
+ transparent
32
+ style={{ flex:1 }}
33
+ animationType={view_mode == 'desktop' ? 'fade' : 'slide'}
34
+ >
35
+ <View type='blur' style={{ flex:1, padding:10 }}>
36
+ <View float style={{flex:1, padding:10}}>
37
+ <ScrollView style={{flex:1, paddingTop:10, borderTopRightRadius:2, borderTopLeftRadius:2}}>
38
+ <SearchContextManager apiKey={'MPKLmL5j0G3TesyhtNeDTE0nZ3F8CKCB'}>
39
+ <Components width={width - 20} gifSelect={gifSelect} />
40
+ </SearchContextManager>
41
+ </ScrollView>
42
+ <View type='footer' style={{ flexDirection:'row', padding:10 }}>
43
+ <Button
44
+ type='close'
45
+ title='CLOSE'
46
+ style={{ flex:1 }}
47
+ onPress={() => closeModal()}
48
+ />
49
+ </View>
50
+ </View>
51
+ </View>
52
+ </Modal>
53
+ )
54
+ }
55
+
56
+ // define the components in a separate function so we can
57
+ // use the context hook. You could also use the render props pattern
58
+ const Components = ({ gifSelect, width }: { gifSelect:any, width:number }) => {
59
+ const { fetchGifs, searchKey } = useContext(SearchContext)
60
+ const [ initGifs, setInitGifs ] = useState<any>()
61
+ useEffect(() => {
62
+ getInitGifs()
63
+ },[])
64
+ const getInitGifs = async() => {
65
+ const fetchedGifs = await gf.trending({ offset: 0, limit: 10 })
66
+ setInitGifs(fetchedGifs.data)
67
+ }
68
+
69
+ if(!initGifs){ return (<></>) }
70
+ return (
71
+ <>
72
+ <SearchBar />
73
+ <View style={{paddingTop:10, paddingLeft:2}}>
74
+ <SuggestionBar />
75
+ <Grid noLink onGifClick={(gif) => gifSelect(gif)} initialGifs={searchKey===''?initGifs:[]} key={searchKey} columns={3} width={width} fetchGifs={fetchGifs} />
76
+ </View>
77
+ </>
78
+ )
79
+ }
80
+
81
+
82
+ const areEqual = (prevProps:GifySelectModalProps, nextProps:GifySelectModalProps) => {
83
+ let allEqual = true
84
+ if(prevProps.isVisible !== nextProps.isVisible){ return false }
85
+ return allEqual
86
+ }
87
+
88
+ export default React.memo(WebGifySelector, areEqual)
89
+
90
+
91
+
@@ -0,0 +1,84 @@
1
+ import React from 'react';
2
+ import { Text, View } from "../../../Components/Themed";
3
+ import { useColors } from "../../../constants/useColors";
4
+ import type { GroupMessageProps, MyPlayerProps, 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
+
11
+
12
+ type GroupMessageCardProps = {
13
+ group_message:GroupMessageProps,
14
+ me?:MyPlayerProps,
15
+ player?:PublicPlayerProps,
16
+ mine?:boolean,
17
+ width: number,
18
+ onSelectImage:(image:{ url:string, height?:number, width?:number }) => void,
19
+ onSelectTag:(tag:TextTagProps) => void
20
+ }
21
+
22
+ const GroupMessageCard = ({group_message, mine, player, width, onSelectImage, onSelectTag}:GroupMessageCardProps) => {
23
+ const Colors = useColors();
24
+ const image = group_message.message_images ? group_message.message_images[0] : undefined
25
+ const url = group_message.message_urls ? group_message.message_urls[0] : undefined
26
+ return (
27
+ <View>
28
+ <View style={{ flexDirection:'row', alignItems:'flex-end' }}>
29
+ {mine ?
30
+ <View style={{ flex:1 }} transparent />
31
+ :
32
+ <View float style={{ borderRadius:100, padding:2 }}>
33
+ <Image
34
+ source={{ uri:player?.profile_pic }}
35
+ style={{ height:36, width:36, borderRadius:100 }}
36
+ resizeMode='cover'
37
+ />
38
+ </View>
39
+ }
40
+ <View float style={{
41
+ width: width - 90,
42
+ padding:14,
43
+ marginLeft:10,
44
+ borderRadius:22,
45
+ marginBottom:15,
46
+ borderBottomLeftRadius: !mine? 0:22,
47
+ borderBottomRightRadius: mine? 0:22,
48
+ backgroundColor:mine?Colors.absolutes.brand.midnight:Colors.absolutes.highlights.highlight200
49
+ }}>
50
+ {url ?
51
+ <UrlPreviewCard
52
+ url={url}
53
+ width={width - 120}
54
+ color={Colors.text.white}
55
+ />
56
+ :<></>}
57
+ {image ?
58
+ <ImageRenderer
59
+ image={image}
60
+ width={width - 120}
61
+ onSelectImage={onSelectImage}
62
+ />
63
+ :<></>}
64
+ {group_message.formatted_text ?
65
+ <FormattedText
66
+ text={group_message.formatted_text}
67
+ tags={group_message.tags ?? []}
68
+ text_color={Colors.text.white}
69
+ onSelectTag={(tag) => onSelectTag(tag)}
70
+ />
71
+ : group_message.message ?
72
+ <Text size={12} color={Colors.text.white}>{group_message.message}</Text>
73
+ :<></>}
74
+ </View>
75
+ {!mine ?
76
+ <View transparent />
77
+ :<></>}
78
+ </View>
79
+ <Text theme="light" textAlign={mine?'right':'left'}>{!mine && player ?`@${player?.username} - `: ''}Delivered {moment(group_message.create_datetime).format('hh:mm a')}</Text>
80
+ </View>
81
+ )
82
+ }
83
+
84
+ export default GroupMessageCard
@@ -0,0 +1,333 @@
1
+ import React from 'react';
2
+ import moment from "moment-mini";
3
+ import { useEffect, useMemo, 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, PublicPlayerProps, TextTagProps } from "../../types";
7
+ import { SocialComponentApi, SocialComponentHelpers } from "../api";
8
+ import { 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
+
14
+ type GroupChatProps = {
15
+ group_id?:string,
16
+ my_id?:string,
17
+ player_id?:string,
18
+ access_token?:string,
19
+ width:number,
20
+ distinct_id:string,
21
+ onSelectTag: (tag:TextTagProps) => void,
22
+ onSelectImage:(image: { url:string, height?:number, width?:number }) => void,
23
+ onFocusPosition?:(position:{ height:number, width:number, x:number, y:number }) => void
24
+ }
25
+
26
+ const GroupChat = ({ my_id, player_id, width, group_id, access_token, distinct_id, onFocusPosition, onSelectImage, onSelectTag }:GroupChatProps) => {
27
+ const Colors = useColors();
28
+ const [ chat_size, setChatSize ] = useState({ height:0, width:0 });
29
+ const [ show_input_bar, setShowInputBar ] = useState(false);
30
+ const [ needs_reload, setNeedsReload ] = useState(false);
31
+ const [ message_loading, setMessageLoading ] = useState(false);
32
+ const [ socket_message, setSocketMessage ] = useState<GroupMessageProps|undefined>(undefined);
33
+ const [ my_data, setMyData ] = useState<{
34
+ me?: MyPlayerProps
35
+ }>({});
36
+ const { me } = my_data;
37
+ const [ screen_data, setData ] = useState<{
38
+ loading:boolean,
39
+ players:PublicPlayerProps[],
40
+ group?:GroupProps,
41
+ group_players:GroupPlayerProps[]
42
+ }>({
43
+ loading:false,
44
+ players:[],
45
+ group_players: []
46
+ })
47
+ const { loading, players, group } = screen_data;
48
+
49
+ const [ message_data, setMessageData ] = useState<{
50
+ messages_loading:boolean,
51
+ messages: GroupMessageProps[]
52
+ }>({
53
+ messages_loading: false,
54
+ messages:[]
55
+ });
56
+ const { messages } = message_data
57
+ const chat_ref = useRef(null);
58
+
59
+ const unique_dates = useMemo(() => [ ...new Set(messages.map(m => moment(m.create_datetime).format('MMM DD YYYY')))],[messages.length, socket_message]);
60
+
61
+ useEffect(() => {
62
+ SocialComponentApi.setEnvironment();
63
+ if(group_id){
64
+ getGroupFromServer(group_id);
65
+ return
66
+ }
67
+ if(player_id){
68
+ getChatFromServer(player_id);
69
+ return
70
+ }
71
+ },[group_id, player_id]);
72
+
73
+ useEffect(() => {
74
+ if(!my_id){ return }
75
+ getMyData();
76
+ },[my_id]);
77
+
78
+ const getMyData = async() => {
79
+ const player = await SocialComponentApi.getMyDetails();
80
+ setMyData({ me:player })
81
+ }
82
+
83
+ useEffect(() => {
84
+ if(!socket_message){ return }
85
+ setMessageData({
86
+ ...message_data,
87
+ messages: messages.filter(m => m.group_message_id != socket_message.group_message_id).concat(socket_message)
88
+ })
89
+ },[socket_message]);
90
+
91
+ const chat_player = group?.type == 'direct' ? players.find(p => p.player_id == player_id) : undefined
92
+
93
+ const getChatFromServer = async(id:string) => {
94
+ setData({ ...screen_data, loading:true });
95
+ if(!my_id){ return }
96
+ setMessageData({ ...message_data, messages_loading:true });
97
+ const group_response = await SocialComponentApi.getChat(id);
98
+ if(!group_response){ return setData({ ...screen_data, loading:false }) }
99
+ let player_ids:string[] = []
100
+ if(player_id){ player_ids.push(player_id) }
101
+ if(my_id){ player_ids.push(my_id) }
102
+ const players = await SocialComponentApi.getPlayersByIds(player_ids);
103
+
104
+ let group_messages_with_tags = await SocialComponentHelpers.addTagsToMessages(group_response.group_messages);
105
+
106
+ setData({
107
+ ...screen_data,
108
+ players: players,
109
+ group: group_response.group,
110
+ group_players: group_response.group_players,
111
+ loading: false
112
+ });
113
+ setMessageData({
114
+ ...message_data,
115
+ messages_loading:false,
116
+ messages: group_messages_with_tags
117
+ });
118
+ }
119
+
120
+ const getGroupFromServer = async(id:string) => {
121
+ setData({ ...screen_data, loading:true });
122
+ setMessageData({ ...message_data, messages_loading:true });
123
+ const group_response = await SocialComponentApi.getGroupById(id);
124
+ if(!group_response){ return setData({ ...screen_data, loading:false }) }
125
+ const players = await SocialComponentApi.getPlayersByIds(group_response.group_messages.map(p => p.player_id));
126
+
127
+ let group_messages_with_tags = await SocialComponentHelpers.addTagsToMessages(group_response.group_messages);
128
+
129
+ setData({
130
+ ...screen_data,
131
+ players: players,
132
+ group: group_response.group,
133
+ group_players: group_response.group_players,
134
+ loading: false
135
+ });
136
+ setMessageData({
137
+ ...message_data,
138
+ messages_loading:false,
139
+ messages: group_messages_with_tags
140
+ });
141
+ }
142
+
143
+ //const message_valid = message_text != '' ? true : false
144
+
145
+ const handleSendImage = async(image:any) => {
146
+ if(!group || message_loading){ return }
147
+ setMessageLoading(true);
148
+ const group_message = SocialComponentHelpers.getEmptyMessage();
149
+ const gm = await SocialComponentApi.sendChat({
150
+ ...group_message,
151
+ formatted_text: '',
152
+ tags: [],
153
+ message_images: [image],
154
+ group_id: group.group_id,
155
+ message: ''
156
+ });
157
+ if(!gm){
158
+ setMessageLoading(false);
159
+ return
160
+ }
161
+ setMessageData({
162
+ ...message_data,
163
+ messages: messages.filter(m => m.group_message_id != gm.group_message_id).concat(gm)
164
+ })
165
+ setMessageLoading(false);
166
+
167
+ }
168
+
169
+ const handleSendMessage = async(data: { formatted_text: string, text:string }, tags:TextTagProps[]) => {
170
+ if(!group || message_loading){ return }
171
+ setMessageLoading(true);
172
+
173
+ //Find urls!
174
+ const url = SocialComponentHelpers.getUrlsFromString(data.text);
175
+ let message_urls:string[] = []
176
+ if(url){ message_urls.push(url) }
177
+ const group_message = SocialComponentHelpers.getEmptyMessage();
178
+ const gm = await SocialComponentApi.sendChat({
179
+ ...group_message,
180
+ formatted_text: data.formatted_text,
181
+ tags: tags.map(t => { return { ...t, data:undefined } }), //Drop the data!
182
+ group_id: group.group_id,
183
+ message_urls: message_urls,
184
+ message: data.text
185
+ });
186
+ if(!gm){
187
+ setMessageLoading(false);
188
+ return
189
+ }
190
+ setMessageData({
191
+ ...message_data,
192
+ messages: messages.filter(m => m.group_message_id != gm.group_message_id).concat(gm)
193
+ })
194
+ setMessageLoading(false);
195
+ }
196
+
197
+ const renderMessages = (data:{item:GroupMessageProps, index:number}) => {
198
+ const player = players.find(p => p.player_id == data.item.player_id)
199
+ const mine = player?.player_id == me?.player_id ? true: false
200
+ return (
201
+ <View style={{ margin:5 }}>
202
+ <GroupMessageCard
203
+ player={player}
204
+ me={me}
205
+ width={chat_size.width}
206
+ mine={mine}
207
+ onSelectImage={onSelectImage}
208
+ group_message={data.item}
209
+ onSelectTag={onSelectTag}
210
+ />
211
+ </View>
212
+ )
213
+ }
214
+
215
+ const renderDates = (data:{ item:string, index:number }) => {
216
+ const date_messages = messages.filter(m => moment(m.create_datetime).format('MMM DD YYYY') == data.item);
217
+
218
+ return (
219
+ <View>
220
+ <View style={{ padding:10 }}>
221
+ <Text size={16} theme="light" textAlign="center">{data.item}</Text>
222
+ </View>
223
+ <FlatList
224
+ key={'date_messages'}
225
+ keyExtractor={(item) => item.group_message_id.toString()}
226
+ data={date_messages.sort((a,b) => moment(a.create_datetime).unix() - moment(b.create_datetime).unix())}
227
+ renderItem={renderMessages}
228
+ />
229
+ </View>
230
+ )
231
+ }
232
+
233
+ return (
234
+ <View style={{ flex:1 }} onLayout={(ev) => {
235
+ const { height, width } = ev.nativeEvent.layout;
236
+ setChatSize({ height, width });
237
+ }}>
238
+ {group?.type == 'direct' && chat_player ?
239
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
240
+ <View transparent>
241
+ <Image
242
+ source={{ uri: chat_player.profile_pic }}
243
+ style={{ height:40, width:40, borderRadius:100 }}
244
+ resizeMode="cover"
245
+ />
246
+ </View>
247
+ <View transparent style={{ flex:1, marginLeft:10 }}>
248
+ <Text theme="h1">@{chat_player.username}</Text>
249
+ <Text style={{ marginTop:3 }} theme="description">Joined {moment(chat_player.create_datetime).fromNow()}</Text>
250
+ </View>
251
+ </View>
252
+ :group ?
253
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
254
+ <View transparent>
255
+ <Image
256
+ source={{ uri: group.group_image?.url }}
257
+ style={{ height:40, width:40, borderRadius:100 }}
258
+ resizeMode="cover"
259
+ />
260
+ </View>
261
+ <View transparent style={{ flex:1, marginLeft:10 }}>
262
+ <Text theme="h1">{group.name}</Text>
263
+ <Text style={{ marginTop:3 }} theme="description">{moment(group.last_update_datetime).format('YYYY MM DD')}</Text>
264
+ </View>
265
+ </View>
266
+ :<></>}
267
+ <View style={{ flex:1 }}>
268
+ <FlatList
269
+ ref={chat_ref}
270
+ data={unique_dates}
271
+ inverted
272
+ style={{ flex:1 }}
273
+ renderItem={renderDates}
274
+ key={`chat_${group_id}dates`}
275
+ keyExtractor={(item) => item}
276
+ />
277
+
278
+ </View>
279
+ {show_input_bar ?
280
+ <View type='header' style={{ padding:5 }}>
281
+ <InputBar
282
+ actions={['image']}
283
+ width={200}
284
+ onImageUpload={(image) => handleSendImage(image)}
285
+ />
286
+ </View>
287
+ :<></>}
288
+ <View type='footer' style={{ padding:5 }}>
289
+ <FormattedTextInput
290
+ submit_placement='inline'
291
+ icon_submit
292
+ width={width}
293
+ onSelectInput={() => setShowInputBar(!show_input_bar)}
294
+ onSubmit={(data, tags) => handleSendMessage(data, tags)}
295
+ onFocusPosition={onFocusPosition}
296
+ />
297
+ </View>
298
+ {group ?
299
+ <SocketManager
300
+ distinct_id={distinct_id}
301
+ access_token={access_token}
302
+ group_id={group.group_id}
303
+ subscribed_events={['V1_UPDATE_GROUP_MESSAGE']}
304
+ onConnect={() => {
305
+ if(!needs_reload){ return }
306
+ if(group_id){ return getGroupFromServer(group_id) }
307
+ if(player_id){ return getChatFromServer(player_id) }
308
+ return
309
+ }}
310
+ onDisconnect={() => {
311
+ setNeedsReload(true)
312
+ }}
313
+ onSocketEvent={(ev) => {
314
+ if(!ev.data){ return }
315
+ let gm:GroupMessageProps = ev.data;
316
+ if(gm.group_id != group.group_id){ return }
317
+ setSocketMessage(gm);
318
+ }}
319
+ />
320
+ :<></>}
321
+ {loading ?
322
+ <View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0, alignItems:'center', padding:20 }}>
323
+ <ActivityIndicator
324
+ size='large'
325
+ color={Colors.text.h1}
326
+ />
327
+ </View>
328
+ :<></>}
329
+ </View>
330
+ )
331
+ }
332
+
333
+ 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