@plusscommunities/pluss-core-app 6.1.7 → 6.1.8-auth.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 (320) hide show
  1. package/dist/module/actions/FollowerActions.js +4 -4
  2. package/dist/module/actions/FollowerActions.js.map +1 -1
  3. package/dist/module/actions/MediaActions.js +1 -1
  4. package/dist/module/actions/MediaActions.js.map +1 -1
  5. package/dist/module/actions/ResidentActions.js +1 -1
  6. package/dist/module/actions/ResidentActions.js.map +1 -1
  7. package/dist/module/actions/UserActions.js +1 -1
  8. package/dist/module/actions/UserActions.js.map +1 -1
  9. package/dist/module/actions/UserSettingsActions.js +1 -1
  10. package/dist/module/actions/UserSettingsActions.js.map +1 -1
  11. package/dist/module/actions/index.js +5 -5
  12. package/dist/module/actions/index.js.map +1 -1
  13. package/dist/module/actions/types.js +16 -16
  14. package/dist/module/actions/types.js.map +1 -1
  15. package/dist/module/apis/analyticsActions.js +5 -5
  16. package/dist/module/apis/analyticsActions.js.map +1 -1
  17. package/dist/module/apis/contactActions.js +6 -6
  18. package/dist/module/apis/contactActions.js.map +1 -1
  19. package/dist/module/apis/eventActions.js +28 -28
  20. package/dist/module/apis/eventActions.js.map +1 -1
  21. package/dist/module/apis/fileActions.js +21 -28
  22. package/dist/module/apis/fileActions.js.map +1 -1
  23. package/dist/module/apis/followerActions.js +8 -8
  24. package/dist/module/apis/followerActions.js.map +1 -1
  25. package/dist/module/apis/index.js +12 -12
  26. package/dist/module/apis/index.js.map +1 -1
  27. package/dist/module/apis/notificationActions.js +17 -17
  28. package/dist/module/apis/notificationActions.js.map +1 -1
  29. package/dist/module/apis/profileActions.js +4 -4
  30. package/dist/module/apis/profileActions.js.map +1 -1
  31. package/dist/module/apis/reactionActions.js +15 -15
  32. package/dist/module/apis/reactionActions.js.map +1 -1
  33. package/dist/module/apis/settingActions.js +6 -6
  34. package/dist/module/apis/settingActions.js.map +1 -1
  35. package/dist/module/apis/stringActions.js +8 -8
  36. package/dist/module/apis/stringActions.js.map +1 -1
  37. package/dist/module/apis/typeActions.js +4 -4
  38. package/dist/module/apis/typeActions.js.map +1 -1
  39. package/dist/module/apis/userActions.js +8 -8
  40. package/dist/module/apis/userActions.js.map +1 -1
  41. package/dist/module/assets/icons/fontawesome/fa-brands-400.ttf +0 -0
  42. package/dist/module/assets/icons/fontawesome/fa-light-300.ttf +0 -0
  43. package/dist/module/assets/icons/fontawesome/fa-regular-400.ttf +0 -0
  44. package/dist/module/assets/icons/fontawesome/fa-solid-900.ttf +0 -0
  45. package/dist/module/assets/icons/fontawesome/fa-thin-100.ttf +0 -0
  46. package/dist/module/assets/icons/fontawesome/fa7-glyphmap.json +4205 -0
  47. package/dist/module/colours.js +26 -29
  48. package/dist/module/colours.js.map +1 -1
  49. package/dist/module/components/AddButton.js +8 -8
  50. package/dist/module/components/AddButton.js.map +1 -1
  51. package/dist/module/components/AddToCalendarButton.js +30 -29
  52. package/dist/module/components/AddToCalendarButton.js.map +1 -1
  53. package/dist/module/components/Attachment.js +10 -9
  54. package/dist/module/components/Attachment.js.map +1 -1
  55. package/dist/module/components/AudienceSelectorLauncher.js +11 -11
  56. package/dist/module/components/AudienceSelectorLauncher.js.map +1 -1
  57. package/dist/module/components/AudienceSelectorPage.js +45 -44
  58. package/dist/module/components/AudienceSelectorPage.js.map +1 -1
  59. package/dist/module/components/AutoOffsetImage.js +13 -13
  60. package/dist/module/components/AutoOffsetImage.js.map +1 -1
  61. package/dist/module/components/BackButton.js +10 -10
  62. package/dist/module/components/BackButton.js.map +1 -1
  63. package/dist/module/components/CalendarPopup.js +21 -21
  64. package/dist/module/components/CalendarPopup.js.map +1 -1
  65. package/dist/module/components/CategoryTabs.js +30 -29
  66. package/dist/module/components/CategoryTabs.js.map +1 -1
  67. package/dist/module/components/CommentReply.js +36 -34
  68. package/dist/module/components/CommentReply.js.map +1 -1
  69. package/dist/module/components/CommentSection.js +74 -74
  70. package/dist/module/components/CommentSection.js.map +1 -1
  71. package/dist/module/components/ConfirmPopup.js +21 -20
  72. package/dist/module/components/ConfirmPopup.js.map +1 -1
  73. package/dist/module/components/ConfirmationPopup.js +11 -11
  74. package/dist/module/components/ConfirmationPopup.js.map +1 -1
  75. package/dist/module/components/DocumentUploader.js +253 -0
  76. package/dist/module/components/DocumentUploader.js.map +1 -0
  77. package/dist/module/components/DropDownItem.js +14 -13
  78. package/dist/module/components/DropDownItem.js.map +1 -1
  79. package/dist/module/components/DropDownMenu.js +5 -5
  80. package/dist/module/components/DropDownMenu.js.map +1 -1
  81. package/dist/module/components/EmptyStateMain.js +10 -9
  82. package/dist/module/components/EmptyStateMain.js.map +1 -1
  83. package/dist/module/components/EmptyStateWidget.js +7 -6
  84. package/dist/module/components/EmptyStateWidget.js.map +1 -1
  85. package/dist/module/components/FontScaleButton.js +5 -4
  86. package/dist/module/components/FontScaleButton.js.map +1 -1
  87. package/dist/module/components/FontScalePopup.js +11 -10
  88. package/dist/module/components/FontScalePopup.js.map +1 -1
  89. package/dist/module/components/Forbidden.js +13 -13
  90. package/dist/module/components/Forbidden.js.map +1 -1
  91. package/dist/module/components/FormCard.js +4 -4
  92. package/dist/module/components/FormCard.js.map +1 -1
  93. package/dist/module/components/FormCardSection.js +20 -18
  94. package/dist/module/components/FormCardSection.js.map +1 -1
  95. package/dist/module/components/FormCardSectionOptionLauncher.js +13 -12
  96. package/dist/module/components/FormCardSectionOptionLauncher.js.map +1 -1
  97. package/dist/module/components/FormattedText.js +18 -16
  98. package/dist/module/components/FormattedText.js.map +1 -1
  99. package/dist/module/components/GenericInput.js +24 -21
  100. package/dist/module/components/GenericInput.js.map +1 -1
  101. package/dist/module/components/GenericInputSection.js +27 -26
  102. package/dist/module/components/GenericInputSection.js.map +1 -1
  103. package/dist/module/components/Header.js +70 -69
  104. package/dist/module/components/Header.js.map +1 -1
  105. package/dist/module/components/Icon.js +109 -0
  106. package/dist/module/components/Icon.js.map +1 -0
  107. package/dist/module/components/ImagePopup.js +237 -77
  108. package/dist/module/components/ImagePopup.js.map +1 -1
  109. package/dist/module/components/ImageUploadProgress.js +10 -9
  110. package/dist/module/components/ImageUploadProgress.js.map +1 -1
  111. package/dist/module/components/ImageUploader.js +22 -13
  112. package/dist/module/components/ImageUploader.js.map +1 -1
  113. package/dist/module/components/InlineButton.js +9 -8
  114. package/dist/module/components/InlineButton.js.map +1 -1
  115. package/dist/module/components/Input.js +28 -26
  116. package/dist/module/components/Input.js.map +1 -1
  117. package/dist/module/components/LoadingCircles.js +20 -20
  118. package/dist/module/components/LoadingCircles.js.map +1 -1
  119. package/dist/module/components/LoadingIndicator.js +11 -11
  120. package/dist/module/components/LoadingIndicator.js.map +1 -1
  121. package/dist/module/components/LoadingStateWidget.js +5 -5
  122. package/dist/module/components/LoadingStateWidget.js.map +1 -1
  123. package/dist/module/components/MediaPlayer.js +32 -32
  124. package/dist/module/components/MediaPlayer.js.map +1 -1
  125. package/dist/module/components/MiddlePopup.js +9 -9
  126. package/dist/module/components/MiddlePopup.js.map +1 -1
  127. package/dist/module/components/PDFPopup.js +36 -36
  128. package/dist/module/components/PDFPopup.js.map +1 -1
  129. package/dist/module/components/PlussChat.js +234 -146
  130. package/dist/module/components/PlussChat.js.map +1 -1
  131. package/dist/module/components/PlussChatMessage.js +75 -38
  132. package/dist/module/components/PlussChatMessage.js.map +1 -1
  133. package/dist/module/components/PlussChatTime.js +18 -17
  134. package/dist/module/components/PlussChatTime.js.map +1 -1
  135. package/dist/module/components/Popup.js +20 -19
  136. package/dist/module/components/Popup.js.map +1 -1
  137. package/dist/module/components/PopupMenu.js +15 -14
  138. package/dist/module/components/PopupMenu.js.map +1 -1
  139. package/dist/module/components/PositionedImage.js +20 -20
  140. package/dist/module/components/PositionedImage.js.map +1 -1
  141. package/dist/module/components/ProfilePic.js +10 -10
  142. package/dist/module/components/ProfilePic.js.map +1 -1
  143. package/dist/module/components/RadioButton.js +10 -9
  144. package/dist/module/components/RadioButton.js.map +1 -1
  145. package/dist/module/components/Reaction.js +18 -17
  146. package/dist/module/components/Reaction.js.map +1 -1
  147. package/dist/module/components/Reactions.js +7 -7
  148. package/dist/module/components/Reactions.js.map +1 -1
  149. package/dist/module/components/SharingTools.js +29 -28
  150. package/dist/module/components/SharingTools.js.map +1 -1
  151. package/dist/module/components/Spinner.js +5 -5
  152. package/dist/module/components/Spinner.js.map +1 -1
  153. package/dist/module/components/StickyFooter.js +6 -6
  154. package/dist/module/components/StickyFooter.js.map +1 -1
  155. package/dist/module/components/Text.js +57 -0
  156. package/dist/module/components/Text.js.map +1 -0
  157. package/dist/module/components/TickIcon.js +6 -6
  158. package/dist/module/components/TickIcon.js.map +1 -1
  159. package/dist/module/components/Toggle.js +10 -9
  160. package/dist/module/components/Toggle.js.map +1 -1
  161. package/dist/module/components/TouchableSearchBar.js +18 -17
  162. package/dist/module/components/TouchableSearchBar.js.map +1 -1
  163. package/dist/module/components/UserListPopup.js +20 -19
  164. package/dist/module/components/UserListPopup.js.map +1 -1
  165. package/dist/module/components/UserListing.js +41 -40
  166. package/dist/module/components/UserListing.js.map +1 -1
  167. package/dist/module/components/VideoPopup.js +20 -20
  168. package/dist/module/components/VideoPopup.js.map +1 -1
  169. package/dist/module/components/WarningPopup.js +21 -20
  170. package/dist/module/components/WarningPopup.js.map +1 -1
  171. package/dist/module/components/expo-image-picker-multiple/ImageBrowser.js +13 -13
  172. package/dist/module/components/expo-image-picker-multiple/ImageBrowser.js.map +1 -1
  173. package/dist/module/components/expo-image-picker-multiple/ImageTile.js +24 -23
  174. package/dist/module/components/expo-image-picker-multiple/ImageTile.js.map +1 -1
  175. package/dist/module/components/index.js +59 -57
  176. package/dist/module/components/index.js.map +1 -1
  177. package/dist/module/components/react-native-expo-image-cropper/ExpoImageManipulator.js +90 -58
  178. package/dist/module/components/react-native-expo-image-cropper/ExpoImageManipulator.js.map +1 -1
  179. package/dist/module/components/react-native-expo-image-cropper/ImageCropOverlay.js +64 -64
  180. package/dist/module/components/react-native-expo-image-cropper/ImageCropOverlay.js.map +1 -1
  181. package/dist/module/config.js +6 -1
  182. package/dist/module/config.js.map +1 -1
  183. package/dist/module/constants.js +3 -3
  184. package/dist/module/constants.js.map +1 -1
  185. package/dist/module/helper.js +83 -82
  186. package/dist/module/helper.js.map +1 -1
  187. package/dist/module/index.js +12 -12
  188. package/dist/module/index.js.map +1 -1
  189. package/dist/module/js/images/detectFaces.js +6 -6
  190. package/dist/module/js/images/detectFaces.js.map +1 -1
  191. package/dist/module/js/images/findLandmarkRange.js +8 -8
  192. package/dist/module/js/images/findLandmarkRange.js.map +1 -1
  193. package/dist/module/js/images/getScaledOffset.js.map +1 -1
  194. package/dist/module/js/site/getSiteLevelFromState.js +2 -2
  195. package/dist/module/js/site/getSiteLevelFromState.js.map +1 -1
  196. package/dist/module/js/site/isTVEnabled.js +2 -2
  197. package/dist/module/js/site/isTVEnabled.js.map +1 -1
  198. package/dist/module/session.js +2 -2
  199. package/dist/module/session.js.map +1 -1
  200. package/dist/module/styles.js +17 -17
  201. package/dist/module/styles.js.map +1 -1
  202. package/dist/module/withNavigationFocus.js +30 -0
  203. package/dist/module/withNavigationFocus.js.map +1 -0
  204. package/package.json +4 -1
  205. package/src/actions/FollowerActions.js +36 -32
  206. package/src/actions/MediaActions.js +25 -20
  207. package/src/actions/ResidentActions.js +26 -21
  208. package/src/actions/UserActions.js +22 -22
  209. package/src/actions/UserSettingsActions.js +11 -11
  210. package/src/actions/index.js +5 -5
  211. package/src/actions/types.js +16 -16
  212. package/src/apis/analyticsActions.js +17 -17
  213. package/src/apis/contactActions.js +20 -20
  214. package/src/apis/eventActions.js +153 -144
  215. package/src/apis/fileActions.js +19 -27
  216. package/src/apis/followerActions.js +29 -29
  217. package/src/apis/index.js +12 -12
  218. package/src/apis/notificationActions.js +44 -44
  219. package/src/apis/profileActions.js +8 -8
  220. package/src/apis/reactionActions.js +81 -73
  221. package/src/apis/settingActions.js +15 -15
  222. package/src/apis/stringActions.js +29 -25
  223. package/src/apis/typeActions.js +10 -10
  224. package/src/apis/userActions.js +93 -93
  225. package/src/assets/icons/fontawesome/fa-brands-400.ttf +0 -0
  226. package/src/assets/icons/fontawesome/fa-light-300.ttf +0 -0
  227. package/src/assets/icons/fontawesome/fa-regular-400.ttf +0 -0
  228. package/src/assets/icons/fontawesome/fa-solid-900.ttf +0 -0
  229. package/src/assets/icons/fontawesome/fa-thin-100.ttf +0 -0
  230. package/src/assets/icons/fontawesome/fa7-glyphmap.json +4205 -0
  231. package/src/colours.js +116 -96
  232. package/src/components/AddButton.js +32 -27
  233. package/src/components/AddToCalendarButton.js +236 -202
  234. package/src/components/Attachment.js +59 -36
  235. package/src/components/AudienceSelectorLauncher.js +52 -48
  236. package/src/components/AudienceSelectorPage.js +353 -311
  237. package/src/components/AutoOffsetImage.js +237 -196
  238. package/src/components/BackButton.js +57 -41
  239. package/src/components/CalendarPopup.js +127 -97
  240. package/src/components/CategoryTabs.js +208 -163
  241. package/src/components/CommentReply.js +363 -309
  242. package/src/components/CommentSection.js +974 -782
  243. package/src/components/ConfirmPopup.js +141 -110
  244. package/src/components/ConfirmationPopup.js +80 -69
  245. package/src/components/DocumentUploader.js +255 -0
  246. package/src/components/DropDownItem.js +70 -60
  247. package/src/components/DropDownMenu.js +31 -27
  248. package/src/components/EmptyStateMain.js +51 -44
  249. package/src/components/EmptyStateWidget.js +47 -38
  250. package/src/components/FontScaleButton.js +29 -25
  251. package/src/components/FontScalePopup.js +67 -56
  252. package/src/components/Forbidden.js +48 -46
  253. package/src/components/FormCard.js +21 -17
  254. package/src/components/FormCardSection.js +284 -233
  255. package/src/components/FormCardSectionOptionLauncher.js +72 -46
  256. package/src/components/FormattedText.js +128 -111
  257. package/src/components/GenericInput.js +168 -136
  258. package/src/components/GenericInputSection.js +209 -161
  259. package/src/components/Header.js +620 -474
  260. package/src/components/Icon.js +119 -0
  261. package/src/components/ImagePopup.js +425 -206
  262. package/src/components/ImageUploadProgress.js +49 -41
  263. package/src/components/ImageUploader.js +23 -13
  264. package/src/components/InlineButton.js +79 -69
  265. package/src/components/Input.js +190 -156
  266. package/src/components/LoadingCircles.js +233 -233
  267. package/src/components/LoadingIndicator.js +87 -76
  268. package/src/components/LoadingStateWidget.js +47 -37
  269. package/src/components/MediaPlayer.js +416 -387
  270. package/src/components/MiddlePopup.js +50 -32
  271. package/src/components/PDFPopup.js +198 -159
  272. package/src/components/PlussChat.js +1271 -986
  273. package/src/components/PlussChatMessage.js +330 -262
  274. package/src/components/PlussChatTime.js +57 -53
  275. package/src/components/Popup.js +138 -116
  276. package/src/components/PopupMenu.js +140 -110
  277. package/src/components/PositionedImage.js +281 -237
  278. package/src/components/ProfilePic.js +122 -113
  279. package/src/components/RadioButton.js +76 -52
  280. package/src/components/Reaction.js +134 -96
  281. package/src/components/Reactions.js +65 -63
  282. package/src/components/SharingTools.js +136 -122
  283. package/src/components/Spinner.js +13 -13
  284. package/src/components/StickyFooter.js +36 -26
  285. package/src/components/Text.js +62 -0
  286. package/src/components/TickIcon.js +20 -20
  287. package/src/components/Toggle.js +74 -73
  288. package/src/components/TouchableSearchBar.js +68 -50
  289. package/src/components/UserListPopup.js +161 -124
  290. package/src/components/UserListing.js +273 -238
  291. package/src/components/VideoPopup.js +110 -96
  292. package/src/components/WarningPopup.js +92 -71
  293. package/src/components/expo-image-picker-multiple/ImageBrowser.js +288 -256
  294. package/src/components/expo-image-picker-multiple/ImageTile.js +108 -84
  295. package/src/components/index.js +59 -57
  296. package/src/components/react-native-expo-image-cropper/ExpoImageManipulator.js +442 -358
  297. package/src/components/react-native-expo-image-cropper/ImageCropOverlay.js +420 -324
  298. package/src/config.js +5 -0
  299. package/src/constants.js +8 -8
  300. package/src/helper.js +469 -438
  301. package/src/index.js +24 -12
  302. package/src/js/images/detectFaces.js +27 -20
  303. package/src/js/images/findLandmarkRange.js +97 -90
  304. package/src/js/images/getScaledOffset.js +80 -75
  305. package/src/js/site/getSiteLevelFromState.js +26 -26
  306. package/src/js/site/isTVEnabled.js +10 -10
  307. package/src/session.js +2 -2
  308. package/src/styles.js +61 -61
  309. package/src/withNavigationFocus.js +28 -0
  310. package/dist/module/components/TextStyle.js +0 -45
  311. package/dist/module/components/TextStyle.js.map +0 -1
  312. package/dist/module/fonts/index.js +0 -2
  313. package/dist/module/fonts/index.js.map +0 -1
  314. package/dist/module/fonts/pluss60-icons.js +0 -5
  315. package/dist/module/fonts/pluss60-icons.js.map +0 -1
  316. package/dist/module/fonts/pluss60-icons.json +0 -1097
  317. package/src/components/TextStyle.js +0 -48
  318. package/src/fonts/index.js +0 -1
  319. package/src/fonts/pluss60-icons.js +0 -6
  320. package/src/fonts/pluss60-icons.json +0 -1097
@@ -1,33 +1,58 @@
1
- import React, { Component } from 'react';
2
- import { View, Image, ImageBackground, TouchableOpacity, Text, KeyboardAvoidingView, Platform, ScrollView } from 'react-native';
3
- import { GiftedChat, Bubble, MessageText, Send, InputToolbar, Composer } from 'react-native-gifted-chat';
4
- import { connect } from 'react-redux';
5
- import _ from 'lodash';
6
- import moment from 'moment';
7
- import { Icon } from 'react-native-elements';
8
- import { getBottomSpace } from 'react-native-iphone-x-helper';
9
- import { Spinner } from './Spinner';
10
- import { ProfilePic } from './ProfilePic';
11
- import PlussChatTime from './PlussChatTime';
12
- import { PDFPopup } from './PDFPopup';
13
- import { Attachment } from './Attachment';
14
- import PlussChatMessage from './PlussChatMessage';
15
- import { TextStyle } from './TextStyle';
1
+ import React, { Component } from "react";
16
2
  import {
17
- TEXT_DARK,
18
- LINEGREY,
19
- TEXT_DARKEST,
20
- getMainBrandingColourFromState,
21
- getLightBrandingColourFromState,
22
- BG_GREY,
23
- TEXT_BLUEGREY,
24
- } from '../colours';
25
- import { getEnabledTabsFromState, get1400, getThumb300, imageExists, isVideo, getImageSource, getFileName } from '../helper';
26
- import Config, { Services } from '../config';
27
- import ImageUploader from './ImageUploader';
28
- import ImageUploadProgress from './ImageUploadProgress';
29
- import { ImagePopup } from './ImagePopup';
30
- import { VideoPopup } from './VideoPopup';
3
+ View,
4
+ Image,
5
+ ImageBackground,
6
+ TouchableOpacity,
7
+ KeyboardAvoidingView,
8
+ Platform,
9
+ ScrollView,
10
+ Alert,
11
+ TextInput,
12
+ } from "react-native";
13
+ import {
14
+ GiftedChat,
15
+ Bubble,
16
+ MessageText,
17
+ Send,
18
+ InputToolbar,
19
+ } from "react-native-gifted-chat";
20
+ import { connect } from "react-redux";
21
+ import _ from "lodash";
22
+ import moment from "moment";
23
+ import { Icon } from "@rneui/themed";
24
+ import { getBottomSpace } from "react-native-iphone-x-helper";
25
+ import { Spinner } from "./Spinner";
26
+ import { ProfilePic } from "./ProfilePic";
27
+ import PlussChatTime from "./PlussChatTime";
28
+ import { PDFPopup } from "./PDFPopup";
29
+ import { Attachment } from "./Attachment";
30
+ import PlussChatMessage from "./PlussChatMessage";
31
+ import { Text } from ".";
32
+ import { ConfirmPopup } from "./ConfirmPopup";
33
+ import {
34
+ TEXT_DARK,
35
+ LINEGREY,
36
+ TEXT_DARKEST,
37
+ getMainBrandingColourFromState,
38
+ getLightBrandingColourFromState,
39
+ BG_GREY,
40
+ TEXT_BLUEGREY,
41
+ } from "../colours";
42
+ import {
43
+ getEnabledTabsFromState,
44
+ get1400,
45
+ getThumb300,
46
+ imageExists,
47
+ isVideo,
48
+ getImageSource,
49
+ getFileName,
50
+ } from "../helper";
51
+ import Config, { Services } from "../config";
52
+ import ImageUploader from "./ImageUploader";
53
+ import ImageUploadProgress from "./ImageUploadProgress";
54
+ import { ImagePopup } from "./ImagePopup";
55
+ import { VideoPopup } from "./VideoPopup";
31
56
 
32
57
  const IMAGE_SIZE_SMALL = 55;
33
58
  const IMAGE_SIZE_LARGE = 110;
@@ -37,968 +62,1228 @@ const IMAGE_PREVIEW_AREA_HEIGHT = 105;
37
62
  const IMAGE_PREVIEW_SIZE = IMAGE_PREVIEW_AREA_HEIGHT - 25;
38
63
 
39
64
  class PlussChat extends Component {
40
- constructor(props) {
41
- super(props);
42
- const isSingleTab = this.props.tabCount === 1 && getBottomSpace() > 0;
43
- this.MIN_COMPOSER_HEIGHT = Platform.select({
44
- ios: isSingleTab ? 42 : 33,
45
- android: 41,
46
- });
47
-
48
- this.state = {
49
- currentUser: {
50
- _id: this.props.user.uid,
51
- name: this.props.user.displayName,
52
- avatar:
53
- !_.isUndefined(this.props.user.profilePic) && !_.isEmpty(this.props.user.profilePic)
54
- ? this.props.user.profilePic
55
- : Config.env.tinyChatDefault,
56
- },
57
-
58
- messages: [],
59
- imagePopupSource: [],
60
- imagePopupIndex: 0,
61
- imagePopupOpen: false,
62
- imagesToUpload: [],
63
- showFullscreenVideo: false,
64
- currentVideoUrl: '',
65
- };
66
- this.checkThumb = null;
67
- }
68
-
69
- UNSAFE_componentWillMount() {
70
- this.updateMessages(this.props);
71
- }
72
-
73
- UNSAFE_componentWillReceiveProps(nextProps) {
74
- this.updateMessages(nextProps);
75
- }
76
-
77
- updateMessages(props) {
78
- const newState = {};
79
- if (!_.isUndefined(props.messages)) {
80
- newState.messages = props.messages;
81
- }
82
- this.setState(newState);
83
- }
84
-
85
- /***
86
- *
87
- * Messaging functionality
88
- */
89
- onSend(messages = []) {
90
- // if (this.chatKey) {
91
- // this.sendMessage(messages[0]);
92
- // }
93
- }
94
-
95
- onPressEvent = event => {
96
- Services.navigation.navigate('eventDetail', { event });
97
- };
98
- onPressAttachment = attachment => {
99
- switch (attachment.Type) {
100
- case 'Event':
101
- Services.navigation.navigate('eventDetail', { event: attachment });
102
- break;
103
- case 'Place':
104
- Services.navigation.navigate('placeDetail', { place: attachment });
105
- break;
106
- default:
107
- return;
108
- }
109
- };
110
-
111
- hasImagesAttached = (imagesToUpload = null) => {
112
- return !_.isEmpty(imagesToUpload || this.state.imagesToUpload);
113
- };
114
-
115
- hasImagesReady = (imagesToUpload = null) => {
116
- const upload = imagesToUpload || this.state.imagesToUpload;
117
- return this.hasImagesAttached(upload) && upload.every(i => !i.uploading && i.thumbNailExists);
118
- };
119
-
120
- waitForThumbnails = () => {
121
- if (this.checkThumb) return;
122
-
123
- this.checkThumb = setInterval(async () => {
124
- const imagesToUpload = [];
125
- await Promise.all(
126
- this.state.imagesToUpload.map(image => {
127
- return new Promise(async resolve => {
128
- const newImage = { ...image };
129
- imagesToUpload.push(newImage);
130
- if (newImage.url && !newImage.thumbNailExists) {
131
- newImage.uploading = false;
132
- newImage.allowRetry = false;
133
- newImage.thumbNailExists = await imageExists(newImage.thumbNailUrl);
134
- resolve(newImage.thumbNailExists);
135
- }
136
- resolve(true);
137
- });
138
- }),
139
- );
140
- const thumbnailsExist = imagesToUpload.every(image => !image.url || image.thumbNailExists);
141
- if (thumbnailsExist) {
142
- clearInterval(this.checkThumb);
143
- this.checkThumb = null;
144
- this.setState({ imagesToUpload });
145
- }
146
- }, 2000);
147
- };
148
-
149
- onOpenAttachment = a => {
150
- this.setState({
151
- selectedPDF: a,
152
- });
153
- };
154
-
155
- onCloseAttachment = () => {
156
- this.setState({
157
- selectedPDF: null,
158
- });
159
- };
160
-
161
- showUploadMenu() {
162
- this.imageUploader.showUploadMenu();
163
- }
164
-
165
- onFocusInput = () => {
166
- this.setState({
167
- keyboardOpen: true,
168
- });
169
- if (this.props.keyboardOpen) {
170
- this.props.keyboardOpen();
171
- }
172
- };
173
-
174
- onBlurInput = () => {
175
- this.setState({
176
- keyboardOpen: false,
177
- });
178
- };
179
-
180
- onUploadStarted = (uploadUri, imageUri) => {
181
- const imagesToUpload = [
182
- ...this.state.imagesToUpload,
183
- {
184
- uploading: true,
185
- uploadProgress: '0%',
186
- uploadUri,
187
- imageUri,
188
- allowRetry: true,
189
- },
190
- ];
191
- this.setState({ imagesToUpload });
192
- };
193
-
194
- onUploadProgress = progress => {
195
- const imagesToUpload = [...this.state.imagesToUpload];
196
- imagesToUpload.map(img => {
197
- if (img.uploadUri === progress.uri) {
198
- img.uploadProgress = progress.percentage;
199
- img.uploading = true;
200
- img.allowRetry = true;
201
- }
202
- });
203
- this.setState({ imagesToUpload });
204
- };
205
-
206
- onUploadSuccess = async (uri, uploadUri) => {
207
- const imagesToUpload = [...this.state.imagesToUpload];
208
- imagesToUpload.map(img => {
209
- if (img.uploadUri === uploadUri && img.uploading) {
210
- img.url = uri.replace('/general/', '/general1400/');
211
- img.thumbNailExists = false;
212
- img.thumbNailUrl = getThumb300(img.url);
213
- img.allowRetry = true;
214
- }
215
- });
216
- this.setState({ imagesToUpload }, () => this.waitForThumbnails());
217
- };
218
-
219
- onUploadFailed = uploadUri => {
220
- const imagesToUpload = [...this.state.imagesToUpload];
221
- imagesToUpload.map(img => {
222
- if (img.uploadUri === uploadUri) {
223
- img.uploading = true; // Requried for retry
224
- img.uploadProgress = '';
225
- img.allowRetry = true;
226
- }
227
- });
228
- this.setState({ imagesToUpload });
229
- };
230
-
231
- onLibrarySelected = uri => {
232
- const imagesToUpload = [
233
- ...this.state.imagesToUpload,
234
- {
235
- uploading: false,
236
- allowRetry: false,
237
- url: get1400(uri),
238
- thumbNailExists: true,
239
- thumbNailUrl: getThumb300(uri),
240
- },
241
- ];
242
- this.setState({ imagesToUpload });
243
- };
244
-
245
- onPressImage = (images, selected) => {
246
- this.setState({
247
- imagePopupSource: images,
248
- imagePopupIndex: images.indexOf(selected),
249
- imagePopupOpen: true,
250
- });
251
- };
252
-
253
- onReply = message => {
254
- this.setState({
255
- replyingTo: message,
256
- });
257
- };
258
-
259
- closeGallery() {
260
- this.setState({
261
- imagePopupSource: [],
262
- imagePopupIndex: 0,
263
- imagePopupOpen: false,
264
- });
265
- }
266
-
267
- onRemoveImage = url => {
268
- const imagesToUpload = this.state.imagesToUpload.filter(image => image.url !== url);
269
- this.setState({ imagesToUpload });
270
- };
271
-
272
- toggleFullscreenVideo = url => {
273
- if (typeof url !== 'string') url = '';
274
- this.setState({ showFullscreenVideo: url.length > 0, currentVideoUrl: url });
275
- };
276
-
277
- sendMessages(messages) {
278
- if (this.hasImagesAttached()) {
279
- // Don't allow send if attached images aren't ready
280
- if (!this.hasImagesReady()) return;
281
- messages[0].image = this.state.imagesToUpload.map(image => image.url);
282
- }
283
- if (_.isEmpty(messages[0].text)) {
284
- messages[0].text = '';
285
- }
286
- if (!messages[0].text && !messages[0].image) return;
287
-
288
- if (this.state.replyingTo) {
289
- messages[0].replyingTo = this.state.replyingTo;
290
- }
291
-
292
- this.props.onSend(messages);
293
- this.setState({ imagesToUpload: [], replyingTo: null });
294
- }
295
-
296
- /**
297
- *
298
- * Render Functions
299
- */
300
- renderBubble(bubbleProps) {
301
- const wrapperStyle = {};
302
- if (!_.isEmpty(bubbleProps.currentMessage.text) && !_.isEmpty(bubbleProps.currentMessage.image)) {
303
- wrapperStyle.paddingTop = 8;
304
- wrapperStyle.paddingBottom = 16;
305
- wrapperStyle.minWidth = 142; // 110 image width + 16 padding either side
306
- }
307
- if (!_.isEmpty(bubbleProps.currentMessage.attachments)) {
308
- wrapperStyle.paddingTop = 8;
309
- wrapperStyle.paddingBottom = 16;
310
- wrapperStyle.paddingHorizontal = 16;
311
- }
312
- return (
313
- <Bubble
314
- {...bubbleProps}
315
- renderMessageImage={() => null}
316
- isCustomViewBottom={true}
317
- wrapperStyle={{
318
- left: {
319
- backgroundColor: LINEGREY,
320
- borderRadius: 25,
321
- ...wrapperStyle,
322
- },
323
- right: {
324
- backgroundColor: this.props.colourBrandingLight,
325
- borderRadius: 25,
326
- ...wrapperStyle,
327
- },
328
- }}
329
- containerToNextStyle={{
330
- left: {
331
- borderBottomLeftRadius: 5,
332
- },
333
- right: {
334
- borderBottomRightRadius: 5,
335
- },
336
- }}
337
- containerToPreviousStyle={{
338
- left: {
339
- borderTopLeftRadius: 5,
340
- },
341
- right: {
342
- borderTopRightRadius: 5,
343
- },
344
- }}
345
- />
346
- );
347
- }
348
- renderMessage(props) {
349
- return (
350
- <PlussChatMessage
351
- key={props.RowId}
352
- colourBrandingMain={this.props.colourBrandingMain}
353
- onPressReply={() => {
354
- this.onReply(props.currentMessage);
355
- }}
356
- {...props}
357
- />
358
- );
359
- }
360
- renderMessageText(messageTextProps) {
361
- return (
362
- <MessageText
363
- {...messageTextProps}
364
- textStyle={{
365
- left: {
366
- fontFamily: 'sf-regular',
367
- fontSize: 16,
368
- color: TEXT_DARKEST,
369
- marginTop: 10,
370
- marginBottom: 10,
371
- marginLeft: 15,
372
- marginRight: 15,
373
- },
374
- right: {
375
- fontFamily: 'sf-regular',
376
- fontSize: 16,
377
- color: this.props.colourBrandingMain,
378
- marginTop: 10,
379
- marginBottom: 10,
380
- marginLeft: 15,
381
- marginRight: 15,
382
- },
383
- }}
384
- linkStyle={{
385
- left: {
386
- color: TEXT_DARKEST,
387
- },
388
- right: {
389
- color: this.props.colourBrandingMain,
390
- },
391
- }}
392
- />
393
- );
394
- }
395
- renderTime() {
396
- return null;
397
- }
398
- renderDay(dayProps) {
399
- return (
400
- <PlussChatTime
401
- {...dayProps}
402
- textStyle={{
403
- fontFamily: 'sf-semibold',
404
- color: TEXT_DARK,
405
- fontSize: 12,
406
- }}
407
- />
408
- );
409
- }
410
- renderCustomView({ currentMessage, position }) {
411
- if (currentMessage.image) {
412
- const images = typeof currentMessage.image === 'string' ? [currentMessage.image] : currentMessage.image;
413
- const containerWidth = (() => {
414
- if (images.length === 0) return 0;
415
- if (images.length === 1) return IMAGE_SIZE_LARGE;
416
- if (images.length <= IMAGES_PER_ROW) return (IMAGE_SIZE_SMALL + IMAGE_MARGIN) * images.length;
417
- return (IMAGE_SIZE_SMALL + IMAGE_MARGIN) * IMAGES_PER_ROW;
418
- })();
419
- return (
420
- <View style={[styles.imagesContainer, { width: containerWidth, paddingVertical: currentMessage.text ? 0 : 20 }]}>
421
- {images.map(img => {
422
- const thumb = getThumb300(img);
423
- if (isVideo(img)) {
424
- return (
425
- <TouchableOpacity key={thumb} onPress={this.toggleFullscreenVideo.bind(this, img)}>
426
- <ImageBackground style={images.length > 1 ? styles.messageImageSmall : styles.messageImageLarge} source={{ uri: thumb }}>
427
- <View style={styles.imagePlayContainer}>
428
- <Icon name="play" type="font-awesome" iconStyle={styles.imageControlIcon} />
429
- </View>
430
- </ImageBackground>
431
- </TouchableOpacity>
432
- );
433
- }
434
- return (
435
- <TouchableOpacity key={thumb} onPress={() => this.onPressImage(images, img)}>
436
- <Image source={{ uri: thumb }} style={images.length > 1 ? styles.messageImageSmall : styles.messageImageLarge} />
437
- </TouchableOpacity>
438
- );
439
- })}
440
- </View>
441
- );
442
- }
443
- if (!_.isEmpty(currentMessage.attachments)) {
444
- return (
445
- <View>
446
- {currentMessage.attachments.map((url, i) => {
447
- return (
448
- <Attachment
449
- onPress={() => {
450
- this.onOpenAttachment(url);
451
- }}
452
- key={i}
453
- title={getFileName(url)}
454
- />
455
- );
456
- })}
457
- </View>
458
- );
459
- }
460
- if (currentMessage.event) {
461
- return (
462
- <TouchableOpacity onPress={this.onPressEvent.bind(this, currentMessage.event)}>
463
- <View style={styles.eventContainer[position]}>
464
- <Image style={[styles.eventImage, styles.eventImageMargin[position]]} source={{ uri: currentMessage.event.Thumbnail }} />
465
- <View style={styles.eventInfo}>
466
- <Text
467
- numberOfLines={3}
468
- style={[styles.eventTitle, styles.eventInfoAlign[position], { color: this.props.colourBrandingMain }]}
469
- >
470
- {currentMessage.event.Title}
471
- </Text>
472
- <Text style={[styles.eventDate, styles.eventInfoAlign[position], { color: this.props.colourBrandingMain }]}>
473
- {moment
474
- .utc(currentMessage.event.StartTime)
475
- .local()
476
- .format('ddd D MMM')}
477
- </Text>
478
- </View>
479
- </View>
480
- </TouchableOpacity>
481
- );
482
- }
483
- if (currentMessage.attachment) {
484
- return (
485
- <TouchableOpacity onPress={this.onPressAttachment.bind(this, currentMessage.attachment)}>
486
- <View style={styles.eventContainer[position]}>
487
- <Image style={[styles.eventImage, styles.eventImageMargin[position]]} source={{ uri: currentMessage.attachment.Thumbnail }} />
488
- <View style={styles.eventInfo}>
489
- <Text
490
- numberOfLines={3}
491
- style={[styles.eventTitle, styles.eventInfoAlign[position], { color: this.props.colourBrandingMain }]}
492
- >
493
- {currentMessage.attachment.Title}
494
- </Text>
495
- {currentMessage.attachment.StartTime && (
496
- <Text style={[styles.eventDate, styles.eventInfoAlign[position], { color: this.props.colourBrandingMain }]}>
497
- {moment
498
- .utc(currentMessage.attachment.StartTime)
499
- .local()
500
- .format('ddd D MMM')}
501
- </Text>
502
- )}
503
- </View>
504
- </View>
505
- </TouchableOpacity>
506
- );
507
- }
508
- return null;
509
- }
510
-
511
- renderSend(props) {
512
- return (
513
- <View style={[{ position: 'absolute', top: 0, right: 0 }, !!this.state.replyingTo && { marginTop: 38 }]}>
514
- {(!_.isEmpty(props.text) || this.hasImagesReady(props.imagesToUpload)) && (
515
- <Send
516
- {...props}
517
- alwaysShowSend={true}
518
- containerStyle={[
519
- styles.sendContainer,
520
- {
521
- width: this.MIN_COMPOSER_HEIGHT,
522
- height: this.MIN_COMPOSER_HEIGHT,
523
- },
524
- ]}
525
- >
526
- <Icon name={'paper-plane'} type="font-awesome" iconStyle={[styles.send, { width: this.MIN_COMPOSER_HEIGHT }]} />
527
- </Send>
528
- )}
529
- <TouchableOpacity
530
- onPress={this.showUploadMenu.bind(this)}
531
- style={[
532
- styles.sendContainer,
533
- {
534
- right: _.isEmpty(props.text) && !this.hasImagesReady(props.imagesToUpload) ? 0 : 8 + this.MIN_COMPOSER_HEIGHT,
535
- width: this.MIN_COMPOSER_HEIGHT,
536
- height: this.MIN_COMPOSER_HEIGHT,
537
- },
538
- ]}
539
- >
540
- <Icon name={'picture-o'} type="font-awesome" iconStyle={[styles.send, { width: this.MIN_COMPOSER_HEIGHT }]} />
541
- </TouchableOpacity>
542
- </View>
543
- );
544
- }
545
-
546
- renderAccessory(props) {
547
- const hasAttachment = this.hasImagesAttached(props.imagesToUpload);
548
- if (!hasAttachment) {
549
- return null;
550
- }
551
- return (
552
- <ScrollView horizontal style={styles.uploadImagesContainer}>
553
- {props.imagesToUpload.map(image => {
554
- if (image.uploading) {
555
- return (
556
- <ImageUploadProgress
557
- key={image.uploadUri}
558
- uploader={this.imageUploader}
559
- image={image}
560
- color={this.props.colourBrandingMain}
561
- style={{ width: IMAGE_PREVIEW_SIZE, marginRight: 10 }}
562
- progressTextStyle={{ fontSize: 10 }}
563
- />
564
- );
565
- }
566
- const isVideoUrl = isVideo(image.url);
567
- return (
568
- <View key={image.url} style={styles.accessoryImageContainer}>
569
- <ImageBackground
570
- style={styles.accessoryImage}
571
- imageStyle={styles.accessoryImageBorder}
572
- source={getImageSource(image.thumbNailExists ? image.thumbNailUrl : image.url)}
573
- >
574
- {isVideoUrl && (
575
- <View style={styles.imagePlayContainer}>
576
- <TouchableOpacity onPress={this.toggleFullscreenVideo.bind(this, image.url)}>
577
- <Icon name="play" type="font-awesome" iconStyle={styles.imageControlIcon} />
578
- </TouchableOpacity>
579
- </View>
580
- )}
581
- </ImageBackground>
582
- <TouchableOpacity
583
- style={styles.previewItemRemoveButton}
584
- onPress={() => this.onRemoveImage(image.url)}
585
- hitSlop={{ top: 8, right: 8, bottom: 8, left: 8 }}
586
- >
587
- <View style={[styles.previewItemRemoveContainer, { backgroundColor: this.props.colourBrandingMain }]}>
588
- <Icon name="times" type="font-awesome" iconStyle={styles.previewItemRemoveIcon} />
589
- </View>
590
- </TouchableOpacity>
591
- </View>
592
- );
593
- })}
594
- </ScrollView>
595
- );
596
- }
597
-
598
- renderInputToolbar(props) {
599
- const hasAttachment = this.hasImagesAttached(props.imagesToUpload);
600
- return (
601
- <InputToolbar
602
- {...props}
603
- containerStyle={styles.inputContainer}
604
- renderComposer={this.renderComposer.bind(this)}
605
- renderAccessory={hasAttachment ? this.renderAccessory.bind(this) : null}
606
- accessoryStyle={hasAttachment && styles.accessory}
607
- />
608
- );
609
- }
610
- renderFooter() {
611
- // if (this.state.keyboardOpen) {
612
- // return null;
613
- // }
614
- // fixes an issue where there's no gap between bottom message and reply container
615
- return <View style={{ height: 10 }} />;
616
- }
617
- renderLoading() {
618
- return (
619
- <View style={{ marginTop: 15, justifyContent: 'center', alignContent: 'center' }}>
620
- <Spinner size={'small'} color={this.props.colourBrandingMain} />
621
- </View>
622
- );
623
- }
624
- renderAvatar(props) {
625
- return (
626
- <View style={{ marginRight: 2 }}>
627
- <ProfilePic ProfilePic={props.currentMessage.user.avatar} Diameter={28} />
628
- </View>
629
- );
630
- }
631
- renderComposer(props) {
632
- return (
633
- <View style={styles.composerContainer}>
634
- {this.state.replyingTo && (
635
- <View style={styles.replyingTo}>
636
- <TextStyle type="body">
637
- Replying to {_.isEmpty(this.state.replyingTo?.user?.name) ? 'message' : this.state.replyingTo?.user?.name}
638
- </TextStyle>
639
- <TouchableOpacity
640
- style={styles.replyingRemoveButton}
641
- onPress={() => this.onReply(null)}
642
- hitSlop={{ top: 8, right: 8, bottom: 8, left: 8 }}
643
- >
644
- <View style={[styles.replyingRemoveContainer, { backgroundColor: this.props.colourBrandingMain }]}>
645
- <Icon name="times" type="font-awesome" iconStyle={styles.replyingRemoveIcon} />
646
- </View>
647
- </TouchableOpacity>
648
- </View>
649
- )}
650
- <View style={styles.composerInputWrapper}>
651
- <View
652
- style={[
653
- styles.input,
654
- {
655
- //height: props.composerHeight + 10,
656
- //borderRadius: (this.MIN_COMPOSER_HEIGHT + 10) / 2,
657
- marginRight:
658
- _.isEmpty(props.text) && !this.hasImagesReady(props.imagesToUpload)
659
- ? 8 + this.MIN_COMPOSER_HEIGHT
660
- : 2 * (this.MIN_COMPOSER_HEIGHT + 8),
661
- justifyContent: 'center',
662
- },
663
- Platform.OS === 'ios' && {
664
- height: props.composerHeight + 10,
665
- },
666
- ]}
667
- >
668
- <Composer
669
- {...props}
670
- //composerHeight={props.composerHeight}
671
- placeholder="Type a message..."
672
- textInputStyle={styles.inputText}
673
- textInputProps={{
674
- onFocus: this.onFocusInput.bind(this),
675
- onBlur: this.onBlurInput.bind(this),
676
- }}
677
- />
678
- </View>
679
- </View>
680
- </View>
681
- );
682
- }
683
-
684
- /***
685
- * Main Render
686
- */
687
- renderChat() {
688
- const { tabCount, noTab } = this.props;
689
- const iosBottomOffset = (tabCount === 1 || noTab ? -10 : 52) + getBottomSpace();
690
- const minInputToolbarHeight =
691
- this.MIN_COMPOSER_HEIGHT + 16 + (this.state.replyingTo ? 30 : 0) + (this.hasImagesAttached() ? IMAGE_PREVIEW_AREA_HEIGHT : 0);
692
-
693
- return (
694
- <GiftedChat
695
- alwaysShowSend={false}
696
- keyboardShouldPersistTaps={'never'}
697
- renderAvatarOnTop
698
- minInputToolbarHeight={minInputToolbarHeight}
699
- bottomOffset={Platform.OS === 'android' ? 0 : iosBottomOffset}
700
- onSend={this.sendMessages.bind(this)}
701
- messages={this.state.messages}
702
- user={this.state.currentUser}
703
- renderBubble={this.renderBubble.bind(this)}
704
- renderMessage={this.renderMessage.bind(this)}
705
- renderMessageText={this.renderMessageText.bind(this)}
706
- renderTime={this.renderTime.bind(this)}
707
- renderDay={this.renderDay.bind(this)}
708
- renderCustomView={this.renderCustomView.bind(this)}
709
- renderSend={this.renderSend.bind(this)}
710
- renderInputToolbar={this.renderInputToolbar.bind(this)}
711
- renderFooter={this.renderFooter.bind(this)}
712
- renderLoading={this.renderLoading.bind(this)}
713
- renderAvatar={this.renderAvatar.bind(this)}
714
- imagesToUpload={this.state.imagesToUpload}
715
- />
716
- );
717
- }
718
-
719
- renderImageUploader() {
720
- return (
721
- <ImageUploader
722
- ref={ref => (this.imageUploader = ref)}
723
- onUploadStarted={this.onUploadStarted}
724
- onUploadProgress={this.onUploadProgress}
725
- onUploadSuccess={this.onUploadSuccess}
726
- onUploadFailed={this.onUploadFailed}
727
- onLibrarySelected={this.onLibrarySelected}
728
- quality={0.8}
729
- allowsEditing={false}
730
- fileName={'imageInput'}
731
- popupTitle={'Add Image'}
732
- userId={this.props.user.uid}
733
- multiple
734
- allowVideo
735
- />
736
- );
737
- }
738
-
739
- renderImagePopup() {
740
- const { imagePopupOpen, imagePopupSource, imagePopupIndex } = this.state;
741
- return (
742
- <ImagePopup
743
- visible={imagePopupOpen}
744
- images={imagePopupSource}
745
- index={imagePopupIndex}
746
- onClose={this.closeGallery.bind(this)}
747
- ref="imagePopup"
748
- />
749
- );
750
- }
751
-
752
- renderVideoPlayerPopup() {
753
- const { showFullscreenVideo, currentVideoUrl } = this.state;
754
- if (!currentVideoUrl) return;
755
-
756
- return <VideoPopup uri={currentVideoUrl} visible={showFullscreenVideo} onClose={this.toggleFullscreenVideo} />;
757
- }
758
-
759
- renderPDF() {
760
- if (_.isEmpty(this.state.selectedPDF)) {
761
- return null;
762
- }
763
- return (
764
- <PDFPopup source={this.state.selectedPDF} onClose={this.onCloseAttachment} title={getFileName(this.state.selectedPDF)} pdfCount={1} />
765
- );
766
- }
767
-
768
- render() {
769
- if (Platform.OS === 'android' && !this.props.noAndroidAvoid) {
770
- return (
771
- <KeyboardAvoidingView behavior={Platform.OS === 'ios' && 'padding'} style={styles.chatContainer}>
772
- {this.renderChat()}
773
- {this.renderImageUploader()}
774
- {this.renderImagePopup()}
775
- {this.renderVideoPlayerPopup()}
776
- {this.renderPDF()}
777
- </KeyboardAvoidingView>
778
- );
779
- }
780
- return (
781
- <View style={styles.chatContainer}>
782
- {this.renderChat()}
783
- {this.renderImageUploader()}
784
- {this.renderImagePopup()}
785
- {this.renderVideoPlayerPopup()}
786
- {this.renderPDF()}
787
- </View>
788
- );
789
- }
65
+ constructor(props) {
66
+ super(props);
67
+ const isSingleTab = this.props.tabCount === 1 && getBottomSpace() > 0;
68
+ this.MIN_COMPOSER_HEIGHT = Platform.select({
69
+ ios: isSingleTab ? 42 : 33,
70
+ android: 41,
71
+ });
72
+
73
+ this.state = {
74
+ currentUser: {
75
+ _id: this.props.user.uid,
76
+ name: this.props.user.displayName,
77
+ avatar:
78
+ !_.isUndefined(this.props.user.profilePic) &&
79
+ !_.isEmpty(this.props.user.profilePic)
80
+ ? this.props.user.profilePic
81
+ : Config.env.tinyChatDefault,
82
+ },
83
+
84
+ messages: [],
85
+ imagePopupSource: [],
86
+ imagePopupIndex: 0,
87
+ imagePopupOpen: false,
88
+ imagesToUpload: [],
89
+ showFullscreenVideo: false,
90
+ currentVideoUrl: "",
91
+ showDeleteMessageConfirm: false,
92
+ messageToDelete: null,
93
+ composerHeight: this.MIN_COMPOSER_HEIGHT,
94
+ };
95
+ this.checkThumb = null;
96
+ }
97
+
98
+ UNSAFE_componentWillMount() {
99
+ this.updateMessages(this.props);
100
+ }
101
+
102
+ UNSAFE_componentWillReceiveProps(nextProps) {
103
+ // Only update if messages actually changed
104
+ if (nextProps.messages !== this.props.messages) {
105
+ this.updateMessages(nextProps);
106
+ }
107
+ }
108
+
109
+ updateMessages(props) {
110
+ // Only update if messages actually changed
111
+ if (
112
+ !_.isUndefined(props.messages) &&
113
+ !_.isEqual(props.messages, this.state.messages)
114
+ ) {
115
+ this.setState({ messages: props.messages });
116
+ }
117
+ }
118
+
119
+ /***
120
+ *
121
+ * Messaging functionality
122
+ */
123
+ onSend(messages = []) {
124
+ // if (this.chatKey) {
125
+ // this.sendMessage(messages[0]);
126
+ // }
127
+ }
128
+
129
+ onPressEvent = (event) => {
130
+ Services.navigation.navigate("eventDetail", { event });
131
+ };
132
+ onPressAttachment = (attachment) => {
133
+ switch (attachment.Type) {
134
+ case "Event":
135
+ Services.navigation.navigate("eventDetail", { event: attachment });
136
+ break;
137
+ case "Place":
138
+ Services.navigation.navigate("placeDetail", { place: attachment });
139
+ break;
140
+ default:
141
+ return;
142
+ }
143
+ };
144
+
145
+ hasImagesAttached = (imagesToUpload = null) => {
146
+ return !_.isEmpty(imagesToUpload || this.state.imagesToUpload);
147
+ };
148
+
149
+ hasImagesReady = (imagesToUpload = null) => {
150
+ const upload = imagesToUpload || this.state.imagesToUpload;
151
+ return (
152
+ this.hasImagesAttached(upload) &&
153
+ upload.every((i) => !i.uploading && i.thumbNailExists)
154
+ );
155
+ };
156
+
157
+ waitForThumbnails = () => {
158
+ if (this.checkThumb) return;
159
+
160
+ this.checkThumb = setInterval(async () => {
161
+ const imagesToUpload = [];
162
+ await Promise.all(
163
+ this.state.imagesToUpload.map((image) => {
164
+ return new Promise(async (resolve) => {
165
+ const newImage = { ...image };
166
+ imagesToUpload.push(newImage);
167
+ if (newImage.url && !newImage.thumbNailExists) {
168
+ newImage.uploading = false;
169
+ newImage.allowRetry = false;
170
+ newImage.thumbNailExists = await imageExists(
171
+ newImage.thumbNailUrl,
172
+ );
173
+ resolve(newImage.thumbNailExists);
174
+ }
175
+ resolve(true);
176
+ });
177
+ }),
178
+ );
179
+ const thumbnailsExist = imagesToUpload.every(
180
+ (image) => !image.url || image.thumbNailExists,
181
+ );
182
+ if (thumbnailsExist) {
183
+ clearInterval(this.checkThumb);
184
+ this.checkThumb = null;
185
+ this.setState({ imagesToUpload });
186
+ }
187
+ }, 2000);
188
+ };
189
+
190
+ onOpenAttachment = (a) => {
191
+ this.setState({
192
+ selectedPDF: a,
193
+ });
194
+ };
195
+
196
+ onCloseAttachment = () => {
197
+ this.setState({
198
+ selectedPDF: null,
199
+ });
200
+ };
201
+
202
+ showUploadMenu() {
203
+ this.imageUploader.showUploadMenu();
204
+ }
205
+
206
+ onFocusInput = () => {
207
+ this.setState({
208
+ keyboardOpen: true,
209
+ });
210
+ if (this.props.keyboardOpen) {
211
+ this.props.keyboardOpen();
212
+ }
213
+ };
214
+
215
+ onBlurInput = () => {
216
+ this.setState({
217
+ keyboardOpen: false,
218
+ });
219
+ };
220
+
221
+ onUploadStarted = (uploadUri, imageUri) => {
222
+ const imagesToUpload = [
223
+ ...this.state.imagesToUpload,
224
+ {
225
+ uploading: true,
226
+ uploadProgress: "0%",
227
+ uploadUri,
228
+ imageUri,
229
+ allowRetry: true,
230
+ },
231
+ ];
232
+ this.setState({ imagesToUpload });
233
+ };
234
+
235
+ onUploadProgress = (progress) => {
236
+ const imagesToUpload = [...this.state.imagesToUpload];
237
+ imagesToUpload.map((img) => {
238
+ if (img.uploadUri === progress.uri) {
239
+ img.uploadProgress = progress.percentage;
240
+ img.uploading = true;
241
+ img.allowRetry = true;
242
+ }
243
+ });
244
+ this.setState({ imagesToUpload });
245
+ };
246
+
247
+ onUploadSuccess = async (uri, uploadUri) => {
248
+ const imagesToUpload = [...this.state.imagesToUpload];
249
+ imagesToUpload.map((img) => {
250
+ if (img.uploadUri === uploadUri && img.uploading) {
251
+ img.url = uri.replace("/general/", "/general1400/");
252
+ img.thumbNailExists = false;
253
+ img.thumbNailUrl = getThumb300(img.url);
254
+ img.allowRetry = true;
255
+ }
256
+ });
257
+ this.setState({ imagesToUpload }, () => this.waitForThumbnails());
258
+ };
259
+
260
+ onUploadFailed = (uploadUri) => {
261
+ const imagesToUpload = [...this.state.imagesToUpload];
262
+ imagesToUpload.map((img) => {
263
+ if (img.uploadUri === uploadUri) {
264
+ img.uploading = true; // Requried for retry
265
+ img.uploadProgress = "";
266
+ img.allowRetry = true;
267
+ }
268
+ });
269
+ this.setState({ imagesToUpload });
270
+ };
271
+
272
+ onLibrarySelected = (uri) => {
273
+ const imagesToUpload = [
274
+ ...this.state.imagesToUpload,
275
+ {
276
+ uploading: false,
277
+ allowRetry: false,
278
+ url: get1400(uri),
279
+ thumbNailExists: true,
280
+ thumbNailUrl: getThumb300(uri),
281
+ },
282
+ ];
283
+ this.setState({ imagesToUpload });
284
+ };
285
+
286
+ onPressImage = (images, selected) => {
287
+ this.setState({
288
+ imagePopupSource: images,
289
+ imagePopupIndex: images.indexOf(selected),
290
+ imagePopupOpen: true,
291
+ });
292
+ };
293
+
294
+ onReply = (message) => {
295
+ this.setState({
296
+ replyingTo: message,
297
+ });
298
+ };
299
+
300
+ onDelete = (message) => {
301
+ // Only proceed if delete handler is provided
302
+ if (!this.props.onDeleteMessage) {
303
+ return;
304
+ }
305
+
306
+ // Only allow deletion of own messages
307
+ if (message.user._id !== this.props.user.uid) {
308
+ return;
309
+ }
310
+
311
+ this.setState({
312
+ showDeleteMessageConfirm: true,
313
+ messageToDelete: message,
314
+ });
315
+ };
316
+
317
+ onCancelDeleteMessage = () => {
318
+ this.setState({
319
+ showDeleteMessageConfirm: false,
320
+ messageToDelete: null,
321
+ });
322
+ };
323
+
324
+ onConfirmDeleteMessage = async () => {
325
+ const { messageToDelete } = this.state;
326
+ if (!messageToDelete) return;
327
+
328
+ this.setState({
329
+ showDeleteMessageConfirm: false,
330
+ });
331
+
332
+ try {
333
+ // Call the parent's delete handler if provided
334
+ if (this.props.onDeleteMessage) {
335
+ await this.props.onDeleteMessage(messageToDelete);
336
+ }
337
+
338
+ this.setState({
339
+ messageToDelete: null,
340
+ });
341
+ } catch (error) {
342
+ // Handle error gracefully if parent handler fails
343
+ console.log("onConfirmDeleteMessage error", error);
344
+ // Error is already handled by parent component
345
+ this.setState({ messageToDelete: null });
346
+ }
347
+ };
348
+
349
+ closeGallery() {
350
+ this.setState({
351
+ imagePopupSource: [],
352
+ imagePopupIndex: 0,
353
+ imagePopupOpen: false,
354
+ });
355
+ }
356
+
357
+ onRemoveImage = (url) => {
358
+ const imagesToUpload = this.state.imagesToUpload.filter(
359
+ (image) => image.url !== url,
360
+ );
361
+ this.setState({ imagesToUpload });
362
+ };
363
+
364
+ toggleFullscreenVideo = (url) => {
365
+ if (typeof url !== "string") url = "";
366
+ this.setState({
367
+ showFullscreenVideo: url.length > 0,
368
+ currentVideoUrl: url,
369
+ });
370
+ };
371
+
372
+ sendMessages(messages) {
373
+ if (this.hasImagesAttached()) {
374
+ // Don't allow send if attached images aren't ready
375
+ if (!this.hasImagesReady()) return;
376
+ messages[0].image = this.state.imagesToUpload.map((image) => image.url);
377
+ }
378
+ if (_.isEmpty(messages[0].text)) {
379
+ messages[0].text = "";
380
+ }
381
+ if (!messages[0].text && !messages[0].image) return;
382
+
383
+ if (this.state.replyingTo) {
384
+ messages[0].replyingTo = this.state.replyingTo;
385
+ }
386
+
387
+ this.props.onSend(messages);
388
+ this.setState({ imagesToUpload: [], replyingTo: null });
389
+ }
390
+
391
+ /**
392
+ *
393
+ * Render Functions
394
+ */
395
+ renderBubble(bubbleProps) {
396
+ const wrapperStyle = {};
397
+ if (
398
+ !_.isEmpty(bubbleProps.currentMessage.text) &&
399
+ !_.isEmpty(bubbleProps.currentMessage.image)
400
+ ) {
401
+ wrapperStyle.paddingTop = 8;
402
+ wrapperStyle.paddingBottom = 16;
403
+ wrapperStyle.minWidth = 142; // 110 image width + 16 padding either side
404
+ }
405
+ if (!_.isEmpty(bubbleProps.currentMessage.attachments)) {
406
+ wrapperStyle.paddingTop = 8;
407
+ wrapperStyle.paddingBottom = 16;
408
+ wrapperStyle.paddingHorizontal = 16;
409
+ }
410
+ return (
411
+ <Bubble
412
+ {...bubbleProps}
413
+ renderMessageImage={() => null}
414
+ isCustomViewBottom={true}
415
+ wrapperStyle={{
416
+ left: {
417
+ backgroundColor: LINEGREY,
418
+ borderRadius: 25,
419
+ ...wrapperStyle,
420
+ },
421
+ right: {
422
+ backgroundColor: this.props.colourBrandingLight,
423
+ borderRadius: 25,
424
+ ...wrapperStyle,
425
+ },
426
+ }}
427
+ containerToNextStyle={{
428
+ left: {
429
+ borderBottomLeftRadius: 5,
430
+ },
431
+ right: {
432
+ borderBottomRightRadius: 5,
433
+ },
434
+ }}
435
+ containerToPreviousStyle={{
436
+ left: {
437
+ borderTopLeftRadius: 5,
438
+ },
439
+ right: {
440
+ borderTopRightRadius: 5,
441
+ },
442
+ }}
443
+ />
444
+ );
445
+ }
446
+ renderMessage(props) {
447
+ return (
448
+ <PlussChatMessage
449
+ key={props.RowId}
450
+ colourBrandingMain={this.props.colourBrandingMain}
451
+ onPressReply={() => {
452
+ this.onReply(props.currentMessage);
453
+ }}
454
+ onPressDelete={
455
+ this.props.onDeleteMessage
456
+ ? () => {
457
+ this.onDelete(props.currentMessage);
458
+ }
459
+ : null
460
+ }
461
+ {...props}
462
+ />
463
+ );
464
+ }
465
+ renderMessageText(messageTextProps) {
466
+ // If message is deleted, show placeholder text
467
+ const props = messageTextProps.currentMessage.deleted
468
+ ? {
469
+ ...messageTextProps,
470
+ currentMessage: {
471
+ ...messageTextProps.currentMessage,
472
+ text: "[Message deleted]",
473
+ },
474
+ }
475
+ : messageTextProps;
476
+
477
+ return (
478
+ <MessageText
479
+ {...props}
480
+ textStyle={{
481
+ left: {
482
+ fontFamily: "sf-regular",
483
+ fontSize: 16,
484
+ color: TEXT_DARKEST,
485
+ marginTop: 10,
486
+ marginBottom: 10,
487
+ marginLeft: 15,
488
+ marginRight: 15,
489
+ },
490
+ right: {
491
+ fontFamily: "sf-regular",
492
+ fontSize: 16,
493
+ color: this.props.colourBrandingMain,
494
+ marginTop: 10,
495
+ marginBottom: 10,
496
+ marginLeft: 15,
497
+ marginRight: 15,
498
+ },
499
+ }}
500
+ linkStyle={{
501
+ left: {
502
+ color: TEXT_DARKEST,
503
+ },
504
+ right: {
505
+ color: this.props.colourBrandingMain,
506
+ },
507
+ }}
508
+ />
509
+ );
510
+ }
511
+ renderTime() {
512
+ return null;
513
+ }
514
+ renderDay(dayProps) {
515
+ return (
516
+ <PlussChatTime
517
+ {...dayProps}
518
+ textStyle={{
519
+ fontFamily: "sf-semibold",
520
+ color: TEXT_DARK,
521
+ fontSize: 12,
522
+ }}
523
+ />
524
+ );
525
+ }
526
+ renderCustomView({ currentMessage, position }) {
527
+ // Don't show images or attachments for deleted messages
528
+ if (currentMessage.deleted) {
529
+ return null;
530
+ }
531
+
532
+ if (currentMessage.image) {
533
+ const images =
534
+ typeof currentMessage.image === "string"
535
+ ? [currentMessage.image]
536
+ : currentMessage.image;
537
+ const containerWidth = (() => {
538
+ if (images.length === 0) return 0;
539
+ if (images.length === 1) return IMAGE_SIZE_LARGE;
540
+ if (images.length <= IMAGES_PER_ROW)
541
+ return (IMAGE_SIZE_SMALL + IMAGE_MARGIN) * images.length;
542
+ return (IMAGE_SIZE_SMALL + IMAGE_MARGIN) * IMAGES_PER_ROW;
543
+ })();
544
+ return (
545
+ <View
546
+ style={[
547
+ styles.imagesContainer,
548
+ {
549
+ width: containerWidth,
550
+ paddingVertical: currentMessage.text ? 0 : 20,
551
+ },
552
+ ]}
553
+ >
554
+ {images.map((img) => {
555
+ const thumb = getThumb300(img);
556
+ if (isVideo(img)) {
557
+ return (
558
+ <TouchableOpacity
559
+ key={thumb}
560
+ onPress={this.toggleFullscreenVideo.bind(this, img)}
561
+ >
562
+ <ImageBackground
563
+ style={
564
+ images.length > 1
565
+ ? styles.messageImageSmall
566
+ : styles.messageImageLarge
567
+ }
568
+ source={{ uri: thumb }}
569
+ >
570
+ <View style={styles.imagePlayContainer}>
571
+ <Icon
572
+ name="play"
573
+ type="font-awesome"
574
+ iconStyle={styles.imageControlIcon}
575
+ />
576
+ </View>
577
+ </ImageBackground>
578
+ </TouchableOpacity>
579
+ );
580
+ }
581
+ return (
582
+ <TouchableOpacity
583
+ key={thumb}
584
+ onPress={() => this.onPressImage(images, img)}
585
+ >
586
+ <Image
587
+ source={{ uri: thumb }}
588
+ style={
589
+ images.length > 1
590
+ ? styles.messageImageSmall
591
+ : styles.messageImageLarge
592
+ }
593
+ />
594
+ </TouchableOpacity>
595
+ );
596
+ })}
597
+ </View>
598
+ );
599
+ }
600
+ if (!_.isEmpty(currentMessage.attachments)) {
601
+ return (
602
+ <View>
603
+ {currentMessage.attachments.map((url, i) => {
604
+ return (
605
+ <Attachment
606
+ onPress={() => {
607
+ this.onOpenAttachment(url);
608
+ }}
609
+ key={i}
610
+ title={getFileName(url)}
611
+ />
612
+ );
613
+ })}
614
+ </View>
615
+ );
616
+ }
617
+ if (currentMessage.event) {
618
+ return (
619
+ <TouchableOpacity
620
+ onPress={this.onPressEvent.bind(this, currentMessage.event)}
621
+ >
622
+ <View style={styles.eventContainer[position]}>
623
+ <Image
624
+ style={[styles.eventImage, styles.eventImageMargin[position]]}
625
+ source={{ uri: currentMessage.event.Thumbnail }}
626
+ />
627
+ <View style={styles.eventInfo}>
628
+ <Text
629
+ numberOfLines={3}
630
+ style={[
631
+ styles.eventTitle,
632
+ styles.eventInfoAlign[position],
633
+ { color: this.props.colourBrandingMain },
634
+ ]}
635
+ >
636
+ {currentMessage.event.Title}
637
+ </Text>
638
+ <Text
639
+ style={[
640
+ styles.eventDate,
641
+ styles.eventInfoAlign[position],
642
+ { color: this.props.colourBrandingMain },
643
+ ]}
644
+ >
645
+ {moment
646
+ .utc(currentMessage.event.StartTime)
647
+ .local()
648
+ .format("ddd D MMM")}
649
+ </Text>
650
+ </View>
651
+ </View>
652
+ </TouchableOpacity>
653
+ );
654
+ }
655
+ if (currentMessage.attachment) {
656
+ return (
657
+ <TouchableOpacity
658
+ onPress={this.onPressAttachment.bind(this, currentMessage.attachment)}
659
+ >
660
+ <View style={styles.eventContainer[position]}>
661
+ <Image
662
+ style={[styles.eventImage, styles.eventImageMargin[position]]}
663
+ source={{ uri: currentMessage.attachment.Thumbnail }}
664
+ />
665
+ <View style={styles.eventInfo}>
666
+ <Text
667
+ numberOfLines={3}
668
+ style={[
669
+ styles.eventTitle,
670
+ styles.eventInfoAlign[position],
671
+ { color: this.props.colourBrandingMain },
672
+ ]}
673
+ >
674
+ {currentMessage.attachment.Title}
675
+ </Text>
676
+ {currentMessage.attachment.StartTime && (
677
+ <Text
678
+ style={[
679
+ styles.eventDate,
680
+ styles.eventInfoAlign[position],
681
+ { color: this.props.colourBrandingMain },
682
+ ]}
683
+ >
684
+ {moment
685
+ .utc(currentMessage.attachment.StartTime)
686
+ .local()
687
+ .format("ddd D MMM")}
688
+ </Text>
689
+ )}
690
+ </View>
691
+ </View>
692
+ </TouchableOpacity>
693
+ );
694
+ }
695
+ return null;
696
+ }
697
+
698
+ renderSend(props) {
699
+ const buttonTopOffset = this.state.replyingTo ? 46 : 4;
700
+ const showSendButton =
701
+ !_.isEmpty(props.text) || this.hasImagesReady(props.imagesToUpload);
702
+ return (
703
+ <View
704
+ style={{
705
+ position: "absolute",
706
+ top: buttonTopOffset,
707
+ right: 8,
708
+ flexDirection: "row",
709
+ alignItems: "center",
710
+ }}
711
+ >
712
+ {/* Image upload button - always visible */}
713
+ <TouchableOpacity
714
+ onPress={this.showUploadMenu.bind(this)}
715
+ style={[
716
+ styles.sendContainer,
717
+ {
718
+ right:
719
+ _.isEmpty(props.text) &&
720
+ !this.hasImagesReady(props.imagesToUpload)
721
+ ? 0
722
+ : this.MIN_COMPOSER_HEIGHT,
723
+
724
+ width: this.MIN_COMPOSER_HEIGHT,
725
+ height: this.MIN_COMPOSER_HEIGHT,
726
+ },
727
+ ]}
728
+ >
729
+ <Icon
730
+ name={"picture-o"}
731
+ type="font-awesome"
732
+ iconStyle={[styles.send, { width: this.MIN_COMPOSER_HEIGHT }]}
733
+ />
734
+ </TouchableOpacity>
735
+
736
+ {/* Send button - only visible when there's text or images */}
737
+ {showSendButton && (
738
+ <Send
739
+ {...props}
740
+ alwaysShowSend={true}
741
+ onSend={props.onSend}
742
+ text={props.text || " "}
743
+ containerStyle={[
744
+ styles.sendContainer,
745
+ {
746
+ width: this.MIN_COMPOSER_HEIGHT,
747
+ height: this.MIN_COMPOSER_HEIGHT,
748
+ },
749
+ ]}
750
+ >
751
+ <Icon
752
+ name={"paper-plane"}
753
+ type="font-awesome"
754
+ iconStyle={[styles.send, { width: this.MIN_COMPOSER_HEIGHT }]}
755
+ />
756
+ </Send>
757
+ )}
758
+ </View>
759
+ );
760
+ }
761
+
762
+ renderAccessory(props) {
763
+ const hasAttachment = this.hasImagesAttached(props.imagesToUpload);
764
+ if (!hasAttachment) {
765
+ return null;
766
+ }
767
+ return (
768
+ <ScrollView horizontal style={styles.uploadImagesContainer}>
769
+ {props.imagesToUpload.map((image) => {
770
+ if (image.uploading) {
771
+ return (
772
+ <ImageUploadProgress
773
+ key={image.uploadUri}
774
+ uploader={this.imageUploader}
775
+ image={image}
776
+ color={this.props.colourBrandingMain}
777
+ style={{ width: IMAGE_PREVIEW_SIZE, marginRight: 10 }}
778
+ progressTextStyle={{ fontSize: 10 }}
779
+ />
780
+ );
781
+ }
782
+ const isVideoUrl = isVideo(image.url);
783
+ return (
784
+ <View key={image.url} style={styles.accessoryImageContainer}>
785
+ <ImageBackground
786
+ style={styles.accessoryImage}
787
+ imageStyle={styles.accessoryImageBorder}
788
+ source={getImageSource(
789
+ image.thumbNailExists ? image.thumbNailUrl : image.url,
790
+ )}
791
+ >
792
+ {isVideoUrl && (
793
+ <View style={styles.imagePlayContainer}>
794
+ <TouchableOpacity
795
+ onPress={this.toggleFullscreenVideo.bind(this, image.url)}
796
+ >
797
+ <Icon
798
+ name="play"
799
+ type="font-awesome"
800
+ iconStyle={styles.imageControlIcon}
801
+ />
802
+ </TouchableOpacity>
803
+ </View>
804
+ )}
805
+ </ImageBackground>
806
+ <TouchableOpacity
807
+ style={styles.previewItemRemoveButton}
808
+ onPress={() => this.onRemoveImage(image.url)}
809
+ hitSlop={{ top: 8, right: 8, bottom: 8, left: 8 }}
810
+ >
811
+ <View
812
+ style={[
813
+ styles.previewItemRemoveContainer,
814
+ { backgroundColor: this.props.colourBrandingMain },
815
+ ]}
816
+ >
817
+ <Icon
818
+ name="times"
819
+ type="font-awesome"
820
+ iconStyle={styles.previewItemRemoveIcon}
821
+ />
822
+ </View>
823
+ </TouchableOpacity>
824
+ </View>
825
+ );
826
+ })}
827
+ </ScrollView>
828
+ );
829
+ }
830
+
831
+ renderInputToolbar(props) {
832
+ const hasAttachment = this.hasImagesAttached(props.imagesToUpload);
833
+ return (
834
+ <InputToolbar
835
+ {...props}
836
+ containerStyle={styles.inputContainer}
837
+ renderComposer={this.renderComposer.bind(this)}
838
+ renderAccessory={hasAttachment ? this.renderAccessory.bind(this) : null}
839
+ accessoryStyle={hasAttachment && styles.accessory}
840
+ />
841
+ );
842
+ }
843
+ renderFooter() {
844
+ // if (this.state.keyboardOpen) {
845
+ // return null;
846
+ // }
847
+ // fixes an issue where there's no gap between bottom message and reply container
848
+ return <View style={{ height: 10 }} />;
849
+ }
850
+ renderLoading() {
851
+ return (
852
+ <View
853
+ style={{
854
+ marginTop: 15,
855
+ justifyContent: "center",
856
+ alignContent: "center",
857
+ }}
858
+ >
859
+ <Spinner size={"small"} color={this.props.colourBrandingMain} />
860
+ </View>
861
+ );
862
+ }
863
+ renderAvatar(props) {
864
+ return (
865
+ <View style={{ marginRight: 2 }}>
866
+ <ProfilePic
867
+ ProfilePic={props.currentMessage.user.avatar}
868
+ Diameter={28}
869
+ />
870
+ </View>
871
+ );
872
+ }
873
+ renderComposer(props) {
874
+ return (
875
+ <View style={{ width: "100%" }}>
876
+ {/* Replying to section - stacked vertically on top */}
877
+ {this.state.replyingTo && (
878
+ <View style={styles.replyingTo}>
879
+ <Text type="body">
880
+ Replying to{" "}
881
+ {_.isEmpty(this.state.replyingTo?.user?.name)
882
+ ? "message"
883
+ : this.state.replyingTo?.user?.name}
884
+ </Text>
885
+ <TouchableOpacity
886
+ style={styles.replyingRemoveButton}
887
+ onPress={() => this.onReply(null)}
888
+ hitSlop={{ top: 8, right: 8, bottom: 8, left: 8 }}
889
+ >
890
+ <View
891
+ style={[
892
+ styles.replyingRemoveContainer,
893
+ { backgroundColor: this.props.colourBrandingMain },
894
+ ]}
895
+ >
896
+ <Icon
897
+ name="times"
898
+ type="font-awesome"
899
+ iconStyle={styles.replyingRemoveIcon}
900
+ />
901
+ </View>
902
+ </TouchableOpacity>
903
+ </View>
904
+ )}
905
+ {/* Horizontal row for input - buttons are absolutely positioned via renderSend */}
906
+ <View
907
+ style={{
908
+ flexDirection: "row",
909
+ alignItems: "flex-end",
910
+ width: "100%",
911
+ paddingBottom: 8,
912
+ }}
913
+ >
914
+ <View
915
+ style={[
916
+ styles.input,
917
+ {
918
+ flex: 1,
919
+ marginRight:
920
+ _.isEmpty(props.text) &&
921
+ !this.hasImagesReady(props.imagesToUpload)
922
+ ? 16 + this.MIN_COMPOSER_HEIGHT
923
+ : 2 * (this.MIN_COMPOSER_HEIGHT + 8),
924
+ paddingHorizontal: 12,
925
+ paddingVertical: Platform.select({ ios: 8, android: 6 }),
926
+ },
927
+ ]}
928
+ >
929
+ <TextInput
930
+ maxFontSizeMultiplier={1.2}
931
+ placeholder="Type a message..."
932
+ multiline
933
+ value={props.text}
934
+ onChangeText={props.onTextChanged}
935
+ style={[
936
+ styles.inputText,
937
+ {
938
+ lineHeight: 20,
939
+ minHeight: this.MIN_COMPOSER_HEIGHT - 16,
940
+ maxHeight: 100,
941
+ },
942
+ ]}
943
+ onFocus={this.onFocusInput.bind(this)}
944
+ onBlur={this.onBlurInput.bind(this)}
945
+ placeholderTextColor="#999"
946
+ />
947
+ </View>
948
+ </View>
949
+ </View>
950
+ );
951
+ }
952
+
953
+ /***
954
+ * Main Render
955
+ */
956
+ renderChat() {
957
+ const minInputToolbarHeight =
958
+ this.MIN_COMPOSER_HEIGHT +
959
+ 32 +
960
+ (this.state.replyingTo ? 38 : 0) +
961
+ (this.hasImagesAttached() ? IMAGE_PREVIEW_AREA_HEIGHT : 0);
962
+
963
+ return (
964
+ <GiftedChat
965
+ isKeyboardInternallyHandled={false}
966
+ alwaysShowSend={false}
967
+ keyboardShouldPersistTaps={"never"}
968
+ renderAvatarOnTop
969
+ minInputToolbarHeight={minInputToolbarHeight}
970
+ minComposerHeight={this.MIN_COMPOSER_HEIGHT}
971
+ bottomOffset={0}
972
+ onSend={this.sendMessages.bind(this)}
973
+ messages={this.state.messages}
974
+ user={this.state.currentUser}
975
+ renderBubble={this.renderBubble.bind(this)}
976
+ renderMessage={this.renderMessage.bind(this)}
977
+ renderMessageText={this.renderMessageText.bind(this)}
978
+ renderTime={this.renderTime.bind(this)}
979
+ renderDay={this.renderDay.bind(this)}
980
+ renderCustomView={this.renderCustomView.bind(this)}
981
+ renderSend={this.renderSend.bind(this)}
982
+ renderInputToolbar={this.renderInputToolbar.bind(this)}
983
+ renderFooter={this.renderFooter.bind(this)}
984
+ renderLoading={this.renderLoading.bind(this)}
985
+ renderAvatar={this.renderAvatar.bind(this)}
986
+ imagesToUpload={this.state.imagesToUpload}
987
+ />
988
+ );
989
+ }
990
+
991
+ renderImageUploader() {
992
+ return (
993
+ <ImageUploader
994
+ ref={(ref) => (this.imageUploader = ref)}
995
+ onUploadStarted={this.onUploadStarted}
996
+ onUploadProgress={this.onUploadProgress}
997
+ onUploadSuccess={this.onUploadSuccess}
998
+ onUploadFailed={this.onUploadFailed}
999
+ onLibrarySelected={this.onLibrarySelected}
1000
+ quality={0.8}
1001
+ allowsEditing={false}
1002
+ fileName={"imageInput"}
1003
+ popupTitle={"Add Image"}
1004
+ userId={this.props.user.uid}
1005
+ multiple
1006
+ allowVideo
1007
+ />
1008
+ );
1009
+ }
1010
+
1011
+ renderImagePopup() {
1012
+ const { imagePopupOpen, imagePopupSource, imagePopupIndex } = this.state;
1013
+ return (
1014
+ <ImagePopup
1015
+ visible={imagePopupOpen}
1016
+ images={imagePopupSource}
1017
+ index={imagePopupIndex}
1018
+ onClose={this.closeGallery.bind(this)}
1019
+ />
1020
+ );
1021
+ }
1022
+
1023
+ renderVideoPlayerPopup() {
1024
+ const { showFullscreenVideo, currentVideoUrl } = this.state;
1025
+ if (!currentVideoUrl) return;
1026
+
1027
+ return (
1028
+ <VideoPopup
1029
+ uri={currentVideoUrl}
1030
+ visible={showFullscreenVideo}
1031
+ onClose={this.toggleFullscreenVideo}
1032
+ />
1033
+ );
1034
+ }
1035
+
1036
+ renderPDF() {
1037
+ if (_.isEmpty(this.state.selectedPDF)) {
1038
+ return null;
1039
+ }
1040
+ return (
1041
+ <PDFPopup
1042
+ source={this.state.selectedPDF}
1043
+ onClose={this.onCloseAttachment}
1044
+ title={getFileName(this.state.selectedPDF)}
1045
+ pdfCount={1}
1046
+ />
1047
+ );
1048
+ }
1049
+
1050
+ renderDeleteConfirmPopup() {
1051
+ return (
1052
+ <ConfirmPopup
1053
+ visible={this.state.showDeleteMessageConfirm}
1054
+ onConfirm={this.onConfirmDeleteMessage}
1055
+ onCancel={this.onCancelDeleteMessage}
1056
+ text="Are you sure you want to delete this message?"
1057
+ yesText="Delete"
1058
+ noText="Cancel"
1059
+ />
1060
+ );
1061
+ }
1062
+
1063
+ render() {
1064
+ return (
1065
+ <KeyboardAvoidingView behavior="padding" style={styles.chatContainer}>
1066
+ {this.renderChat()}
1067
+ {this.renderImageUploader()}
1068
+ {this.renderImagePopup()}
1069
+ {this.renderVideoPlayerPopup()}
1070
+ {this.renderPDF()}
1071
+ {this.renderDeleteConfirmPopup()}
1072
+ </KeyboardAvoidingView>
1073
+ );
1074
+ }
790
1075
  }
791
1076
 
792
1077
  const styles = {
793
- chatContainer: {
794
- flex: 1,
795
- justifyContent: 'center',
796
- },
797
- eventContainer: {
798
- left: {
799
- paddingTop: 5,
800
- paddingLeft: 15,
801
- paddingRight: 15,
802
- paddingBottom: 5,
803
- flexDirection: 'row',
804
- },
805
- right: {
806
- paddingTop: 5,
807
- paddingLeft: 15,
808
- paddingRight: 15,
809
- paddingBottom: 5,
810
- flexDirection: 'row-reverse',
811
- },
812
- },
813
- eventImage: {
814
- width: 80,
815
- height: 80,
816
- resizeMode: 'cover',
817
- borderRadius: 2,
818
- },
819
- eventImageMargin: {
820
- right: {
821
- marginLeft: 15,
822
- },
823
- left: {
824
- marginRight: 15,
825
- },
826
- },
827
- eventInfo: {
828
- minHeight: 80,
829
- width: 150,
830
- },
831
- eventTitle: {
832
- fontSize: 12,
833
- fontFamily: 'sf-bold',
834
- backgroundColor: 'rgba(255,255,255,0)',
835
- },
836
- eventInfoAlign: {
837
- left: {
838
- textAlign: 'left',
839
- },
840
- right: {
841
- textAlign: 'right',
842
- },
843
- },
844
- messageImageLarge: {
845
- width: IMAGE_SIZE_LARGE,
846
- height: IMAGE_SIZE_LARGE,
847
- borderRadius: 2,
848
- alignSelf: 'center',
849
- },
850
- messageImageSmall: {
851
- width: IMAGE_SIZE_SMALL,
852
- height: IMAGE_SIZE_SMALL,
853
- borderRadius: 2,
854
- alignSelf: 'center',
855
- marginRight: IMAGE_MARGIN,
856
- marginBottom: IMAGE_MARGIN,
857
- },
858
- eventDate: {
859
- fontSize: 12,
860
- fontFamily: 'sf-regular',
861
- backgroundColor: 'rgba(255,255,255,0)',
862
- },
863
- inputContainer: {
864
- backgroundColor: '#fff',
865
- paddingVertical: 8,
866
- paddingHorizontal: 8,
867
- },
868
- inputText: {
869
- color: TEXT_DARKEST,
870
- fontSize: 14,
871
- fontFamily: 'sf-medium',
872
- },
873
- input: {
874
- margin: 0,
875
- backgroundColor: BG_GREY,
876
- borderRadius: 5,
877
- flex: 1,
878
- },
879
- composerContainer: {
880
- flex: 1,
881
- },
882
- composerInputWrapper: {
883
- flex: 1,
884
- flexDirection: 'row',
885
- },
886
- replyingTo: {
887
- minHeight: 30,
888
- flexDirection: 'row',
889
- alignItems: 'center',
890
- borderBottomWidth: 1,
891
- borderBottomColor: LINEGREY,
892
- marginBottom: 8,
893
- },
894
- replyingRemoveButton: {
895
- marginLeft: 10,
896
- },
897
- replyingRemoveContainer: {
898
- justifyContent: 'center',
899
- alignItems: 'center',
900
- borderRadius: 10,
901
- width: 20,
902
- height: 20,
903
- borderWidth: 2,
904
- borderColor: '#fff',
905
- },
906
- replyingRemoveIcon: {
907
- fontSize: 10,
908
- color: '#fff',
909
- marginBottom: 1,
910
- },
911
- sendContainer: {
912
- position: 'absolute',
913
- top: 0,
914
- right: 0,
915
- height: 30,
916
- width: 30,
917
- alignItems: 'center',
918
- justifyContent: 'center',
919
- backgroundColor: '#fff',
920
- },
921
- send: {
922
- fontSize: 15,
923
- color: TEXT_BLUEGREY,
924
- fontSize: 24,
925
- textAlign: 'center',
926
- },
927
- accessory: {
928
- height: IMAGE_PREVIEW_AREA_HEIGHT,
929
- borderTopWidth: 1,
930
- borderTopColor: LINEGREY,
931
- paddingTop: 8,
932
- marginTop: 8,
933
- },
934
- accessoryImageContainer: {
935
- paddingRight: 8,
936
- paddingTop: 8,
937
- marginRight: 5,
938
- },
939
- accessoryImage: {
940
- width: IMAGE_PREVIEW_SIZE,
941
- height: IMAGE_PREVIEW_SIZE,
942
- },
943
- accessoryImageBorder: {
944
- borderRadius: 2,
945
- },
946
- settingDropDownOpen: {
947
- height: 'auto',
948
- },
949
- imagesContainer: {
950
- marginLeft: 10,
951
- marginRight: 10,
952
- flexDirection: 'row',
953
- flexWrap: 'wrap',
954
- },
955
- uploadImagesContainer: {
956
- flexDirection: 'row',
957
- overflow: 'visible',
958
- },
959
- previewItemRemoveButton: {
960
- position: 'absolute',
961
- top: 0,
962
- right: 0,
963
- },
964
- previewItemRemoveContainer: {
965
- justifyContent: 'center',
966
- alignItems: 'center',
967
- borderRadius: 10,
968
- width: 20,
969
- height: 20,
970
- borderWidth: 2,
971
- borderColor: '#fff',
972
- },
973
- previewItemRemoveIcon: {
974
- fontSize: 10,
975
- color: '#fff',
976
- marginBottom: 1,
977
- },
978
- imagePlayContainer: {
979
- position: 'absolute',
980
- top: 0,
981
- left: 0,
982
- right: 0,
983
- bottom: 0,
984
- alignItems: 'center',
985
- justifyContent: 'center',
986
- },
987
- imageControlIcon: {
988
- color: '#fff',
989
- fontSize: 20,
990
- textShadowColor: 'rgba(0,0,0,0.3)',
991
- textShadowOffset: { width: 2, height: 2 },
992
- },
1078
+ chatContainer: {
1079
+ flex: 1,
1080
+ justifyContent: "center",
1081
+ },
1082
+ eventContainer: {
1083
+ left: {
1084
+ paddingTop: 5,
1085
+ paddingLeft: 15,
1086
+ paddingRight: 15,
1087
+ paddingBottom: 5,
1088
+ flexDirection: "row",
1089
+ },
1090
+ right: {
1091
+ paddingTop: 5,
1092
+ paddingLeft: 15,
1093
+ paddingRight: 15,
1094
+ paddingBottom: 5,
1095
+ flexDirection: "row-reverse",
1096
+ },
1097
+ },
1098
+ eventImage: {
1099
+ width: 80,
1100
+ height: 80,
1101
+ resizeMode: "cover",
1102
+ borderRadius: 2,
1103
+ },
1104
+ eventImageMargin: {
1105
+ right: {
1106
+ marginLeft: 15,
1107
+ },
1108
+ left: {
1109
+ marginRight: 15,
1110
+ },
1111
+ },
1112
+ eventInfo: {
1113
+ minHeight: 80,
1114
+ width: 150,
1115
+ },
1116
+ eventTitle: {
1117
+ fontSize: 12,
1118
+ fontFamily: "sf-bold",
1119
+ backgroundColor: "rgba(255,255,255,0)",
1120
+ },
1121
+ eventInfoAlign: {
1122
+ left: {
1123
+ textAlign: "left",
1124
+ },
1125
+ right: {
1126
+ textAlign: "right",
1127
+ },
1128
+ },
1129
+ messageImageLarge: {
1130
+ width: IMAGE_SIZE_LARGE,
1131
+ height: IMAGE_SIZE_LARGE,
1132
+ borderRadius: 2,
1133
+ alignSelf: "center",
1134
+ },
1135
+ messageImageSmall: {
1136
+ width: IMAGE_SIZE_SMALL,
1137
+ height: IMAGE_SIZE_SMALL,
1138
+ borderRadius: 2,
1139
+ alignSelf: "center",
1140
+ marginRight: IMAGE_MARGIN,
1141
+ marginBottom: IMAGE_MARGIN,
1142
+ },
1143
+ eventDate: {
1144
+ fontSize: 12,
1145
+ fontFamily: "sf-regular",
1146
+ backgroundColor: "rgba(255,255,255,0)",
1147
+ },
1148
+ inputContainer: {
1149
+ backgroundColor: "#fff",
1150
+ paddingVertical: 8,
1151
+ paddingHorizontal: 8,
1152
+ },
1153
+ inputText: {
1154
+ color: TEXT_DARKEST,
1155
+ fontSize: 14,
1156
+ fontFamily: "sf-medium",
1157
+ },
1158
+ input: {
1159
+ margin: 0,
1160
+ backgroundColor: BG_GREY,
1161
+ borderRadius: 5,
1162
+ flex: 1,
1163
+ },
1164
+ composerContainer: {
1165
+ flex: 1,
1166
+ },
1167
+ composerInputWrapper: {
1168
+ flex: 1,
1169
+ flexDirection: "row",
1170
+ },
1171
+ replyingTo: {
1172
+ minHeight: 30,
1173
+ flexDirection: "row",
1174
+ alignItems: "center",
1175
+ borderBottomWidth: 1,
1176
+ borderBottomColor: LINEGREY,
1177
+ marginBottom: 8,
1178
+ },
1179
+ replyingRemoveButton: {
1180
+ marginLeft: 10,
1181
+ },
1182
+ replyingRemoveContainer: {
1183
+ justifyContent: "center",
1184
+ alignItems: "center",
1185
+ borderRadius: 10,
1186
+ width: 20,
1187
+ height: 20,
1188
+ borderWidth: 2,
1189
+ borderColor: "#fff",
1190
+ },
1191
+ replyingRemoveIcon: {
1192
+ fontSize: 10,
1193
+ color: "#fff",
1194
+ marginBottom: 1,
1195
+ },
1196
+ sendContainer: {
1197
+ position: "absolute",
1198
+ top: 0,
1199
+ right: 0,
1200
+ height: 30,
1201
+ width: 30,
1202
+ alignItems: "center",
1203
+ justifyContent: "center",
1204
+ backgroundColor: "#fff",
1205
+ },
1206
+ send: {
1207
+ fontSize: 15,
1208
+ color: TEXT_BLUEGREY,
1209
+ fontSize: 24,
1210
+ textAlign: "center",
1211
+ },
1212
+ accessory: {
1213
+ height: IMAGE_PREVIEW_AREA_HEIGHT,
1214
+ borderTopWidth: 1,
1215
+ borderTopColor: LINEGREY,
1216
+ paddingTop: 8,
1217
+ marginTop: 8,
1218
+ },
1219
+ accessoryImageContainer: {
1220
+ paddingRight: 8,
1221
+ paddingTop: 8,
1222
+ marginRight: 5,
1223
+ },
1224
+ accessoryImage: {
1225
+ width: IMAGE_PREVIEW_SIZE,
1226
+ height: IMAGE_PREVIEW_SIZE,
1227
+ },
1228
+ accessoryImageBorder: {
1229
+ borderRadius: 2,
1230
+ },
1231
+ settingDropDownOpen: {
1232
+ height: "auto",
1233
+ },
1234
+ imagesContainer: {
1235
+ marginLeft: 10,
1236
+ marginRight: 10,
1237
+ flexDirection: "row",
1238
+ flexWrap: "wrap",
1239
+ },
1240
+ uploadImagesContainer: {
1241
+ flexDirection: "row",
1242
+ overflow: "visible",
1243
+ },
1244
+ previewItemRemoveButton: {
1245
+ position: "absolute",
1246
+ top: 0,
1247
+ right: 0,
1248
+ },
1249
+ previewItemRemoveContainer: {
1250
+ justifyContent: "center",
1251
+ alignItems: "center",
1252
+ borderRadius: 10,
1253
+ width: 20,
1254
+ height: 20,
1255
+ borderWidth: 2,
1256
+ borderColor: "#fff",
1257
+ },
1258
+ previewItemRemoveIcon: {
1259
+ fontSize: 10,
1260
+ color: "#fff",
1261
+ marginBottom: 1,
1262
+ },
1263
+ imagePlayContainer: {
1264
+ position: "absolute",
1265
+ top: 0,
1266
+ left: 0,
1267
+ right: 0,
1268
+ bottom: 0,
1269
+ alignItems: "center",
1270
+ justifyContent: "center",
1271
+ },
1272
+ imageControlIcon: {
1273
+ color: "#fff",
1274
+ fontSize: 20,
1275
+ textShadowColor: "rgba(0,0,0,0.3)",
1276
+ textShadowOffset: { width: 2, height: 2 },
1277
+ },
993
1278
  };
994
1279
 
995
- const mapStateToProps = state => {
996
- return {
997
- user: state.user,
998
- colourBrandingMain: getMainBrandingColourFromState(state),
999
- colourBrandingLight: getLightBrandingColourFromState(state),
1000
- tabCount: getEnabledTabsFromState(state).length,
1001
- };
1280
+ const mapStateToProps = (state) => {
1281
+ return {
1282
+ user: state.user,
1283
+ colourBrandingMain: getMainBrandingColourFromState(state),
1284
+ colourBrandingLight: getLightBrandingColourFromState(state),
1285
+ tabCount: getEnabledTabsFromState(state).length,
1286
+ };
1002
1287
  };
1003
1288
 
1004
1289
  export default connect(mapStateToProps, {})(PlussChat);