@sendbird/uikit-react-native 1.0.2 → 1.1.1

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 (185) hide show
  1. package/README.md +7 -7
  2. package/lib/commonjs/components/FileViewer.js +319 -0
  3. package/lib/commonjs/components/FileViewer.js.map +1 -0
  4. package/lib/commonjs/components/MessageRenderer/FileMessage/VideoFileMessage.js +116 -0
  5. package/lib/commonjs/components/MessageRenderer/FileMessage/VideoFileMessage.js.map +1 -0
  6. package/lib/commonjs/components/MessageRenderer/FileMessage/index.js +8 -0
  7. package/lib/commonjs/components/MessageRenderer/FileMessage/index.js.map +1 -1
  8. package/lib/commonjs/components/MessageRenderer/MessageOutgoingStatus.js +20 -65
  9. package/lib/commonjs/components/MessageRenderer/MessageOutgoingStatus.js.map +1 -1
  10. package/lib/commonjs/components/UserActionBar.js +1 -3
  11. package/lib/commonjs/components/UserActionBar.js.map +1 -1
  12. package/lib/commonjs/components/UserSelectableBar.js +1 -3
  13. package/lib/commonjs/components/UserSelectableBar.js.map +1 -1
  14. package/lib/commonjs/constants.js +7 -1
  15. package/lib/commonjs/constants.js.map +1 -1
  16. package/lib/commonjs/containers/GroupChannelPreviewContainer.js +157 -0
  17. package/lib/commonjs/containers/GroupChannelPreviewContainer.js.map +1 -0
  18. package/lib/commonjs/{InternalErrorBoundary.js → containers/InternalErrorBoundaryContainer.js} +5 -5
  19. package/lib/commonjs/containers/InternalErrorBoundaryContainer.js.map +1 -0
  20. package/lib/commonjs/{SendbirdUIKitContainer.js → containers/SendbirdUIKitContainer.js} +15 -12
  21. package/lib/commonjs/containers/SendbirdUIKitContainer.js.map +1 -0
  22. package/lib/commonjs/contexts/PlatformService.js +4 -2
  23. package/lib/commonjs/contexts/PlatformService.js.map +1 -1
  24. package/lib/commonjs/contexts/SendbirdChat.js +6 -2
  25. package/lib/commonjs/contexts/SendbirdChat.js.map +1 -1
  26. package/lib/commonjs/domain/groupChannel/component/GroupChannelInput/SendInput.js +1 -1
  27. package/lib/commonjs/domain/groupChannel/component/GroupChannelInput/SendInput.js.map +1 -1
  28. package/lib/commonjs/domain/groupChannel/component/GroupChannelMessageList.js +30 -7
  29. package/lib/commonjs/domain/groupChannel/component/GroupChannelMessageList.js.map +1 -1
  30. package/lib/commonjs/domain/groupChannel/module/moduleContext.js +2 -3
  31. package/lib/commonjs/domain/groupChannel/module/moduleContext.js.map +1 -1
  32. package/lib/commonjs/domain/groupChannel/types.js.map +1 -1
  33. package/lib/commonjs/domain/groupChannelList/types.js.map +1 -1
  34. package/lib/commonjs/domain/groupChannelSettings/module/moduleContext.js +1 -1
  35. package/lib/commonjs/domain/groupChannelSettings/module/moduleContext.js.map +1 -1
  36. package/lib/commonjs/fragments/createGroupChannelCreateFragment.js +3 -7
  37. package/lib/commonjs/fragments/createGroupChannelCreateFragment.js.map +1 -1
  38. package/lib/commonjs/fragments/createGroupChannelFragment.js +14 -12
  39. package/lib/commonjs/fragments/createGroupChannelFragment.js.map +1 -1
  40. package/lib/commonjs/fragments/createGroupChannelListFragment.js +10 -40
  41. package/lib/commonjs/fragments/createGroupChannelListFragment.js.map +1 -1
  42. package/lib/commonjs/fragments/createGroupChannelMembersFragment.js +1 -1
  43. package/lib/commonjs/fragments/createGroupChannelMembersFragment.js.map +1 -1
  44. package/lib/commonjs/hooks/useContext.js.map +1 -1
  45. package/lib/commonjs/index.js +30 -3
  46. package/lib/commonjs/index.js.map +1 -1
  47. package/lib/commonjs/{InternalLocalCacheStorage.js → libs/InternalLocalCacheStorage.js} +0 -0
  48. package/lib/commonjs/libs/InternalLocalCacheStorage.js.map +1 -0
  49. package/lib/commonjs/localization/StringSet.type.js +8 -0
  50. package/lib/commonjs/localization/StringSet.type.js.map +1 -1
  51. package/lib/commonjs/platform/createFileService.expo.js +21 -2
  52. package/lib/commonjs/platform/createFileService.expo.js.map +1 -1
  53. package/lib/commonjs/platform/createFileService.native.js +20 -3
  54. package/lib/commonjs/platform/createFileService.native.js.map +1 -1
  55. package/lib/commonjs/platform/createMediaService.expo.js +64 -0
  56. package/lib/commonjs/platform/createMediaService.expo.js.map +1 -0
  57. package/lib/commonjs/platform/createMediaService.native.js +67 -0
  58. package/lib/commonjs/platform/createMediaService.native.js.map +1 -0
  59. package/lib/commonjs/platform/createNotificationService.expo.js.map +1 -1
  60. package/lib/commonjs/platform/types.js.map +1 -1
  61. package/lib/commonjs/version.js +1 -1
  62. package/lib/commonjs/version.js.map +1 -1
  63. package/lib/module/components/FileViewer.js +300 -0
  64. package/lib/module/components/FileViewer.js.map +1 -0
  65. package/lib/module/components/MessageRenderer/FileMessage/VideoFileMessage.js +100 -0
  66. package/lib/module/components/MessageRenderer/FileMessage/VideoFileMessage.js.map +1 -0
  67. package/lib/module/components/MessageRenderer/FileMessage/index.js +6 -0
  68. package/lib/module/components/MessageRenderer/FileMessage/index.js.map +1 -1
  69. package/lib/module/components/MessageRenderer/MessageOutgoingStatus.js +17 -60
  70. package/lib/module/components/MessageRenderer/MessageOutgoingStatus.js.map +1 -1
  71. package/lib/module/components/UserActionBar.js +1 -1
  72. package/lib/module/components/UserActionBar.js.map +1 -1
  73. package/lib/module/components/UserSelectableBar.js +1 -1
  74. package/lib/module/components/UserSelectableBar.js.map +1 -1
  75. package/lib/module/constants.js +5 -0
  76. package/lib/module/constants.js.map +1 -1
  77. package/lib/module/containers/GroupChannelPreviewContainer.js +135 -0
  78. package/lib/module/containers/GroupChannelPreviewContainer.js.map +1 -0
  79. package/lib/module/{InternalErrorBoundary.js → containers/InternalErrorBoundaryContainer.js} +5 -5
  80. package/lib/module/containers/InternalErrorBoundaryContainer.js.map +1 -0
  81. package/lib/module/{SendbirdUIKitContainer.js → containers/SendbirdUIKitContainer.js} +15 -12
  82. package/lib/module/containers/SendbirdUIKitContainer.js.map +1 -0
  83. package/lib/module/contexts/PlatformService.js +4 -2
  84. package/lib/module/contexts/PlatformService.js.map +1 -1
  85. package/lib/module/contexts/SendbirdChat.js +6 -2
  86. package/lib/module/contexts/SendbirdChat.js.map +1 -1
  87. package/lib/module/domain/groupChannel/component/GroupChannelInput/SendInput.js +1 -1
  88. package/lib/module/domain/groupChannel/component/GroupChannelInput/SendInput.js.map +1 -1
  89. package/lib/module/domain/groupChannel/component/GroupChannelMessageList.js +28 -7
  90. package/lib/module/domain/groupChannel/component/GroupChannelMessageList.js.map +1 -1
  91. package/lib/module/domain/groupChannel/module/moduleContext.js +2 -3
  92. package/lib/module/domain/groupChannel/module/moduleContext.js.map +1 -1
  93. package/lib/module/domain/groupChannel/types.js.map +1 -1
  94. package/lib/module/domain/groupChannelList/types.js.map +1 -1
  95. package/lib/module/domain/groupChannelSettings/module/moduleContext.js +1 -1
  96. package/lib/module/domain/groupChannelSettings/module/moduleContext.js.map +1 -1
  97. package/lib/module/fragments/createGroupChannelCreateFragment.js +4 -4
  98. package/lib/module/fragments/createGroupChannelCreateFragment.js.map +1 -1
  99. package/lib/module/fragments/createGroupChannelFragment.js +16 -14
  100. package/lib/module/fragments/createGroupChannelFragment.js.map +1 -1
  101. package/lib/module/fragments/createGroupChannelListFragment.js +14 -41
  102. package/lib/module/fragments/createGroupChannelListFragment.js.map +1 -1
  103. package/lib/module/fragments/createGroupChannelMembersFragment.js +1 -1
  104. package/lib/module/fragments/createGroupChannelMembersFragment.js.map +1 -1
  105. package/lib/module/hooks/useContext.js.map +1 -1
  106. package/lib/module/index.js +5 -2
  107. package/lib/module/index.js.map +1 -1
  108. package/lib/module/{InternalLocalCacheStorage.js → libs/InternalLocalCacheStorage.js} +0 -0
  109. package/lib/module/libs/InternalLocalCacheStorage.js.map +1 -0
  110. package/lib/module/localization/StringSet.type.js +8 -0
  111. package/lib/module/localization/StringSet.type.js.map +1 -1
  112. package/lib/module/platform/createFileService.expo.js +21 -2
  113. package/lib/module/platform/createFileService.expo.js.map +1 -1
  114. package/lib/module/platform/createFileService.native.js +20 -3
  115. package/lib/module/platform/createFileService.native.js.map +1 -1
  116. package/lib/module/platform/createMediaService.expo.js +54 -0
  117. package/lib/module/platform/createMediaService.expo.js.map +1 -0
  118. package/lib/module/platform/createMediaService.native.js +57 -0
  119. package/lib/module/platform/createMediaService.native.js.map +1 -0
  120. package/lib/module/platform/createNotificationService.expo.js.map +1 -1
  121. package/lib/module/platform/types.js.map +1 -1
  122. package/lib/module/version.js +1 -1
  123. package/lib/module/version.js.map +1 -1
  124. package/lib/typescript/src/components/FileViewer.d.ts +12 -0
  125. package/lib/typescript/src/components/MessageRenderer/FileMessage/VideoFileMessage.d.ts +3 -0
  126. package/lib/typescript/src/components/UserActionBar.d.ts +2 -3
  127. package/lib/typescript/src/components/UserSelectableBar.d.ts +2 -3
  128. package/lib/typescript/src/constants.d.ts +5 -0
  129. package/lib/typescript/src/containers/GroupChannelPreviewContainer.d.ts +8 -0
  130. package/lib/typescript/src/{InternalErrorBoundary.d.ts → containers/InternalErrorBoundaryContainer.d.ts} +3 -3
  131. package/lib/typescript/src/{SendbirdUIKitContainer.d.ts → containers/SendbirdUIKitContainer.d.ts} +9 -5
  132. package/lib/typescript/src/contexts/PlatformService.d.ts +3 -2
  133. package/lib/typescript/src/contexts/SendbirdChat.d.ts +5 -1
  134. package/lib/typescript/src/domain/groupChannel/component/GroupChannelMessageList.d.ts +3 -2
  135. package/lib/typescript/src/domain/groupChannel/types.d.ts +6 -2
  136. package/lib/typescript/src/domain/groupChannelList/types.d.ts +2 -2
  137. package/lib/typescript/src/hooks/useContext.d.ts +7 -5
  138. package/lib/typescript/src/index.d.ts +4 -1
  139. package/lib/typescript/src/{InternalLocalCacheStorage.d.ts → libs/InternalLocalCacheStorage.d.ts} +2 -2
  140. package/lib/typescript/src/localization/StringSet.type.d.ts +4 -0
  141. package/lib/typescript/src/platform/createMediaService.expo.d.ts +9 -0
  142. package/lib/typescript/src/platform/createMediaService.native.d.ts +9 -0
  143. package/lib/typescript/src/platform/createNotificationService.expo.d.ts +1 -1
  144. package/lib/typescript/src/platform/types.d.ts +20 -1
  145. package/lib/typescript/src/version.d.ts +1 -1
  146. package/package.json +14 -5
  147. package/src/components/FileViewer.tsx +283 -0
  148. package/src/components/MessageRenderer/FileMessage/VideoFileMessage.tsx +91 -0
  149. package/src/components/MessageRenderer/FileMessage/index.tsx +6 -0
  150. package/src/components/MessageRenderer/MessageOutgoingStatus.tsx +14 -54
  151. package/src/components/UserActionBar.tsx +1 -1
  152. package/src/components/UserSelectableBar.tsx +1 -1
  153. package/src/constants.ts +5 -0
  154. package/src/containers/GroupChannelPreviewContainer.tsx +117 -0
  155. package/src/{InternalErrorBoundary.tsx → containers/InternalErrorBoundaryContainer.tsx} +4 -4
  156. package/src/{SendbirdUIKitContainer.tsx → containers/SendbirdUIKitContainer.tsx} +26 -14
  157. package/src/contexts/PlatformService.tsx +15 -3
  158. package/src/contexts/SendbirdChat.tsx +13 -5
  159. package/src/domain/groupChannel/component/GroupChannelInput/SendInput.tsx +1 -1
  160. package/src/domain/groupChannel/component/GroupChannelMessageList.tsx +23 -6
  161. package/src/domain/groupChannel/module/moduleContext.tsx +6 -13
  162. package/src/domain/groupChannel/types.ts +8 -2
  163. package/src/domain/groupChannelList/types.ts +3 -2
  164. package/src/domain/groupChannelSettings/module/moduleContext.tsx +5 -10
  165. package/src/fragments/createGroupChannelCreateFragment.tsx +38 -41
  166. package/src/fragments/createGroupChannelFragment.tsx +24 -34
  167. package/src/fragments/createGroupChannelListFragment.tsx +13 -35
  168. package/src/fragments/createGroupChannelMembersFragment.tsx +34 -39
  169. package/src/hooks/useContext.ts +3 -5
  170. package/src/index.ts +6 -2
  171. package/src/{InternalLocalCacheStorage.ts → libs/InternalLocalCacheStorage.ts} +1 -1
  172. package/src/localization/StringSet.type.ts +8 -0
  173. package/src/platform/createFileService.expo.ts +17 -2
  174. package/src/platform/createFileService.native.ts +16 -3
  175. package/src/platform/createMediaService.expo.tsx +30 -0
  176. package/src/platform/createMediaService.native.tsx +37 -0
  177. package/src/platform/createNotificationService.expo.ts +1 -1
  178. package/src/platform/types.ts +26 -1
  179. package/src/version.ts +1 -1
  180. package/lib/commonjs/InternalErrorBoundary.js.map +0 -1
  181. package/lib/commonjs/InternalLocalCacheStorage.js.map +0 -1
  182. package/lib/commonjs/SendbirdUIKitContainer.js.map +0 -1
  183. package/lib/module/InternalErrorBoundary.js.map +0 -1
  184. package/lib/module/InternalLocalCacheStorage.js.map +0 -1
  185. package/lib/module/SendbirdUIKitContainer.js.map +0 -1
@@ -0,0 +1,300 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { StatusBar, StyleSheet, TouchableOpacity, View } from 'react-native';
3
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
+ import { Icon, Image, LoadingSpinner, Text, createStyleSheet, useAlert, useHeaderStyle, useToast, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';
5
+ import { Logger, getFileExtension, getFileType, isMyMessage, toMegabyte, useIIFE } from '@sendbird/uikit-utils';
6
+ import { useLocalization, usePlatformService, useSendbirdChat } from '../hooks/useContext';
7
+
8
+ const FileViewer = _ref => {
9
+ let {
10
+ headerShown = true,
11
+ deleteMessage,
12
+ headerTopInset,
13
+ fileMessage,
14
+ onPressDownload,
15
+ onPressDelete,
16
+ onClose
17
+ } = _ref;
18
+ const [loading, setLoading] = useState(true);
19
+ const {
20
+ bottom
21
+ } = useSafeAreaInsets();
22
+ const {
23
+ currentUser
24
+ } = useSendbirdChat();
25
+ const {
26
+ palette
27
+ } = useUIKitTheme();
28
+ const {
29
+ topInset,
30
+ statusBarTranslucent,
31
+ defaultHeight
32
+ } = useHeaderStyle();
33
+ const {
34
+ STRINGS
35
+ } = useLocalization();
36
+ const {
37
+ fileService,
38
+ mediaService
39
+ } = usePlatformService();
40
+ const toast = useToast();
41
+ const {
42
+ alert
43
+ } = useAlert();
44
+ const basicTopInset = statusBarTranslucent ? topInset : 0;
45
+ const canDelete = isMyMessage(fileMessage, currentUser === null || currentUser === void 0 ? void 0 : currentUser.userId);
46
+ const fileType = getFileType(fileMessage.type || getFileExtension(fileMessage.url));
47
+ useEffect(() => {
48
+ if (!(mediaService !== null && mediaService !== void 0 && mediaService.VideoComponent) || fileType === 'file') {
49
+ onClose();
50
+ }
51
+ }, [mediaService]);
52
+ const fileViewer = useIIFE(() => {
53
+ switch (fileType) {
54
+ case 'image':
55
+ {
56
+ return /*#__PURE__*/React.createElement(Image, {
57
+ source: {
58
+ uri: fileMessage.url
59
+ },
60
+ style: StyleSheet.absoluteFill,
61
+ resizeMode: 'contain',
62
+ onLoadEnd: () => setLoading(false)
63
+ });
64
+ }
65
+
66
+ case 'video':
67
+ case 'audio':
68
+ {
69
+ if (!(mediaService !== null && mediaService !== void 0 && mediaService.VideoComponent)) return null;
70
+ return /*#__PURE__*/React.createElement(mediaService.VideoComponent, {
71
+ source: {
72
+ uri: fileMessage.url
73
+ },
74
+ style: [StyleSheet.absoluteFill, {
75
+ top: basicTopInset + defaultHeight,
76
+ bottom: defaultHeight + bottom
77
+ }],
78
+ resizeMode: 'contain',
79
+ onLoad: () => setLoading(false)
80
+ });
81
+ }
82
+
83
+ default:
84
+ {
85
+ return null;
86
+ }
87
+ }
88
+ });
89
+
90
+ const _onPressDelete = () => {
91
+ if (!canDelete) return;
92
+
93
+ if (onPressDelete) {
94
+ onPressDelete(fileMessage);
95
+ } else {
96
+ alert({
97
+ title: STRINGS.GROUP_CHANNEL.DIALOG_MESSAGE_DELETE_CONFIRM_TITLE,
98
+ buttons: [{
99
+ text: STRINGS.GROUP_CHANNEL.DIALOG_MESSAGE_DELETE_CONFIRM_CANCEL
100
+ }, {
101
+ text: STRINGS.GROUP_CHANNEL.DIALOG_MESSAGE_DELETE_CONFIRM_OK,
102
+ style: 'destructive',
103
+ onPress: () => {
104
+ deleteMessage().then(() => {
105
+ onClose();
106
+ }).catch(() => {
107
+ toast.show(STRINGS.TOAST.DELETE_MSG_ERROR, 'error');
108
+ });
109
+ }
110
+ }]
111
+ });
112
+ }
113
+ };
114
+
115
+ const _onPressDownload = () => {
116
+ if (onPressDownload) {
117
+ onPressDownload(fileMessage);
118
+ } else {
119
+ if (toMegabyte(fileMessage.size) > 4) {
120
+ toast.show(STRINGS.TOAST.DOWNLOAD_START, 'success');
121
+ }
122
+
123
+ fileService.save({
124
+ fileUrl: fileMessage.url,
125
+ fileName: fileMessage.name,
126
+ fileType: fileMessage.type
127
+ }).then(response => {
128
+ toast.show(STRINGS.TOAST.DOWNLOAD_OK, 'success');
129
+ Logger.log('File saved to', response);
130
+ }).catch(err => {
131
+ toast.show(STRINGS.TOAST.DOWNLOAD_ERROR, 'error');
132
+ Logger.log('File save failure', err);
133
+ });
134
+ }
135
+ };
136
+
137
+ return /*#__PURE__*/React.createElement(View, {
138
+ style: {
139
+ flex: 1,
140
+ backgroundColor: palette.background700
141
+ }
142
+ }, /*#__PURE__*/React.createElement(StatusBar, {
143
+ barStyle: 'light-content',
144
+ animated: true
145
+ }), /*#__PURE__*/React.createElement(View, {
146
+ style: {
147
+ flex: 1,
148
+ alignItems: 'center',
149
+ justifyContent: 'center'
150
+ }
151
+ }, fileViewer, loading && /*#__PURE__*/React.createElement(LoadingSpinner, {
152
+ style: {
153
+ position: 'absolute'
154
+ },
155
+ size: 40,
156
+ color: palette.primary300
157
+ })), headerShown && /*#__PURE__*/React.createElement(FileViewerHeader, {
158
+ title: STRINGS.FILE_VIEWER.TITLE(fileMessage),
159
+ subtitle: STRINGS.FILE_VIEWER.SUBTITLE(fileMessage),
160
+ topInset: headerTopInset ?? basicTopInset,
161
+ onClose: onClose
162
+ }), /*#__PURE__*/React.createElement(FileViewerFooter, {
163
+ bottomInset: bottom,
164
+ deleteShown: canDelete,
165
+ onPressDelete: _onPressDelete,
166
+ onPressDownload: _onPressDownload
167
+ }));
168
+ };
169
+
170
+ const FileViewerHeader = _ref2 => {
171
+ let {
172
+ topInset,
173
+ onClose,
174
+ subtitle,
175
+ title
176
+ } = _ref2;
177
+ const {
178
+ palette
179
+ } = useUIKitTheme();
180
+ const {
181
+ defaultHeight
182
+ } = useHeaderStyle();
183
+ const {
184
+ left,
185
+ right
186
+ } = useSafeAreaInsets();
187
+ return /*#__PURE__*/React.createElement(View, {
188
+ style: [styles.headerContainer, {
189
+ paddingLeft: styles.headerContainer.paddingHorizontal + left,
190
+ paddingRight: styles.headerContainer.paddingHorizontal + right
191
+ }, {
192
+ paddingTop: topInset,
193
+ height: defaultHeight + topInset,
194
+ backgroundColor: palette.overlay01
195
+ }]
196
+ }, /*#__PURE__*/React.createElement(TouchableOpacity, {
197
+ onPress: onClose,
198
+ style: styles.barButton
199
+ }, /*#__PURE__*/React.createElement(Icon, {
200
+ icon: 'close',
201
+ size: 24,
202
+ color: palette.onBackgroundDark01
203
+ })), /*#__PURE__*/React.createElement(View, {
204
+ style: styles.barTitleContainer
205
+ }, /*#__PURE__*/React.createElement(Text, {
206
+ h2: true,
207
+ color: palette.onBackgroundDark01,
208
+ style: styles.headerTitle
209
+ }, title), /*#__PURE__*/React.createElement(Text, {
210
+ caption2: true,
211
+ color: palette.onBackgroundDark01
212
+ }, subtitle)), /*#__PURE__*/React.createElement(View, {
213
+ style: styles.barButton
214
+ }));
215
+ };
216
+
217
+ const FileViewerFooter = _ref3 => {
218
+ let {
219
+ bottomInset,
220
+ deleteShown,
221
+ onPressDelete,
222
+ onPressDownload
223
+ } = _ref3;
224
+ const {
225
+ palette
226
+ } = useUIKitTheme();
227
+ const {
228
+ defaultHeight
229
+ } = useHeaderStyle();
230
+ const {
231
+ left,
232
+ right
233
+ } = useSafeAreaInsets();
234
+ return /*#__PURE__*/React.createElement(View, {
235
+ style: [styles.footerContainer, {
236
+ paddingLeft: styles.headerContainer.paddingHorizontal + left,
237
+ paddingRight: styles.headerContainer.paddingHorizontal + right
238
+ }, {
239
+ paddingBottom: bottomInset,
240
+ height: defaultHeight + bottomInset,
241
+ backgroundColor: palette.overlay01
242
+ }]
243
+ }, /*#__PURE__*/React.createElement(TouchableOpacity, {
244
+ onPress: onPressDownload,
245
+ style: styles.barButton
246
+ }, /*#__PURE__*/React.createElement(Icon, {
247
+ icon: 'download',
248
+ size: 24,
249
+ color: palette.onBackgroundDark01
250
+ })), /*#__PURE__*/React.createElement(View, {
251
+ style: styles.barTitleContainer
252
+ }), /*#__PURE__*/React.createElement(TouchableOpacity, {
253
+ onPress: onPressDelete,
254
+ style: styles.barButton,
255
+ disabled: !deleteShown
256
+ }, deleteShown && /*#__PURE__*/React.createElement(Icon, {
257
+ icon: 'delete',
258
+ size: 24,
259
+ color: palette.onBackgroundDark01
260
+ })));
261
+ };
262
+
263
+ const styles = createStyleSheet({
264
+ headerContainer: {
265
+ top: 0,
266
+ left: 0,
267
+ right: 0,
268
+ position: 'absolute',
269
+ flexDirection: 'row',
270
+ alignItems: 'center',
271
+ justifyContent: 'center',
272
+ paddingHorizontal: 12
273
+ },
274
+ barButton: {
275
+ width: 32,
276
+ height: 32,
277
+ alignItems: 'center',
278
+ justifyContent: 'center'
279
+ },
280
+ barTitleContainer: {
281
+ flex: 1,
282
+ alignItems: 'center',
283
+ justifyContent: 'center'
284
+ },
285
+ headerTitle: {
286
+ marginBottom: 2
287
+ },
288
+ footerContainer: {
289
+ position: 'absolute',
290
+ left: 0,
291
+ right: 0,
292
+ bottom: 0,
293
+ flexDirection: 'row',
294
+ alignItems: 'center',
295
+ justifyContent: 'center',
296
+ paddingHorizontal: 12
297
+ }
298
+ });
299
+ export default FileViewer;
300
+ //# sourceMappingURL=FileViewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useState","StatusBar","StyleSheet","TouchableOpacity","View","useSafeAreaInsets","Icon","Image","LoadingSpinner","Text","createStyleSheet","useAlert","useHeaderStyle","useToast","useUIKitTheme","Logger","getFileExtension","getFileType","isMyMessage","toMegabyte","useIIFE","useLocalization","usePlatformService","useSendbirdChat","FileViewer","headerShown","deleteMessage","headerTopInset","fileMessage","onPressDownload","onPressDelete","onClose","loading","setLoading","bottom","currentUser","palette","topInset","statusBarTranslucent","defaultHeight","STRINGS","fileService","mediaService","toast","alert","basicTopInset","canDelete","userId","fileType","type","url","VideoComponent","fileViewer","uri","absoluteFill","top","_onPressDelete","title","GROUP_CHANNEL","DIALOG_MESSAGE_DELETE_CONFIRM_TITLE","buttons","text","DIALOG_MESSAGE_DELETE_CONFIRM_CANCEL","DIALOG_MESSAGE_DELETE_CONFIRM_OK","style","onPress","then","catch","show","TOAST","DELETE_MSG_ERROR","_onPressDownload","size","DOWNLOAD_START","save","fileUrl","fileName","name","response","DOWNLOAD_OK","log","err","DOWNLOAD_ERROR","flex","backgroundColor","background700","alignItems","justifyContent","position","primary300","FILE_VIEWER","TITLE","SUBTITLE","FileViewerHeader","subtitle","left","right","styles","headerContainer","paddingLeft","paddingHorizontal","paddingRight","paddingTop","height","overlay01","barButton","onBackgroundDark01","barTitleContainer","headerTitle","FileViewerFooter","bottomInset","deleteShown","footerContainer","paddingBottom","flexDirection","width","marginBottom"],"sources":["FileViewer.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { StatusBar, StyleSheet, TouchableOpacity, View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport {\n Icon,\n Image,\n LoadingSpinner,\n Text,\n createStyleSheet,\n useAlert,\n useHeaderStyle,\n useToast,\n useUIKitTheme,\n} from '@sendbird/uikit-react-native-foundation';\nimport type { SendbirdFileMessage } from '@sendbird/uikit-utils';\nimport { Logger, getFileExtension, getFileType, isMyMessage, toMegabyte, useIIFE } from '@sendbird/uikit-utils';\n\nimport { useLocalization, usePlatformService, useSendbirdChat } from '../hooks/useContext';\n\ntype Props = {\n fileMessage: SendbirdFileMessage;\n deleteMessage: () => Promise<void>;\n\n onClose: () => void;\n onPressDownload?: (message: SendbirdFileMessage) => void;\n onPressDelete?: (message: SendbirdFileMessage) => void;\n\n headerShown?: boolean;\n headerTopInset?: number;\n};\nconst FileViewer = ({\n headerShown = true,\n deleteMessage,\n headerTopInset,\n fileMessage,\n onPressDownload,\n onPressDelete,\n onClose,\n}: Props) => {\n const [loading, setLoading] = useState(true);\n\n const { bottom } = useSafeAreaInsets();\n\n const { currentUser } = useSendbirdChat();\n const { palette } = useUIKitTheme();\n const { topInset, statusBarTranslucent, defaultHeight } = useHeaderStyle();\n const { STRINGS } = useLocalization();\n const { fileService, mediaService } = usePlatformService();\n const toast = useToast();\n const { alert } = useAlert();\n\n const basicTopInset = statusBarTranslucent ? topInset : 0;\n const canDelete = isMyMessage(fileMessage, currentUser?.userId);\n const fileType = getFileType(fileMessage.type || getFileExtension(fileMessage.url));\n\n useEffect(() => {\n if (!mediaService?.VideoComponent || fileType === 'file') {\n onClose();\n }\n }, [mediaService]);\n\n const fileViewer = useIIFE(() => {\n switch (fileType) {\n case 'image': {\n return (\n <Image\n source={{ uri: fileMessage.url }}\n style={StyleSheet.absoluteFill}\n resizeMode={'contain'}\n onLoadEnd={() => setLoading(false)}\n />\n );\n }\n\n case 'video':\n case 'audio': {\n if (!mediaService?.VideoComponent) return null;\n return (\n <mediaService.VideoComponent\n source={{ uri: fileMessage.url }}\n style={[StyleSheet.absoluteFill, { top: basicTopInset + defaultHeight, bottom: defaultHeight + bottom }]}\n resizeMode={'contain'}\n onLoad={() => setLoading(false)}\n />\n );\n }\n\n default: {\n return null;\n }\n }\n });\n\n const _onPressDelete = () => {\n if (!canDelete) return;\n\n if (onPressDelete) {\n onPressDelete(fileMessage);\n } else {\n alert({\n title: STRINGS.GROUP_CHANNEL.DIALOG_MESSAGE_DELETE_CONFIRM_TITLE,\n buttons: [\n {\n text: STRINGS.GROUP_CHANNEL.DIALOG_MESSAGE_DELETE_CONFIRM_CANCEL,\n },\n {\n text: STRINGS.GROUP_CHANNEL.DIALOG_MESSAGE_DELETE_CONFIRM_OK,\n style: 'destructive',\n onPress: () => {\n deleteMessage()\n .then(() => {\n onClose();\n })\n .catch(() => {\n toast.show(STRINGS.TOAST.DELETE_MSG_ERROR, 'error');\n });\n },\n },\n ],\n });\n }\n };\n\n const _onPressDownload = () => {\n if (onPressDownload) {\n onPressDownload(fileMessage);\n } else {\n if (toMegabyte(fileMessage.size) > 4) {\n toast.show(STRINGS.TOAST.DOWNLOAD_START, 'success');\n }\n\n fileService\n .save({ fileUrl: fileMessage.url, fileName: fileMessage.name, fileType: fileMessage.type })\n .then((response) => {\n toast.show(STRINGS.TOAST.DOWNLOAD_OK, 'success');\n Logger.log('File saved to', response);\n })\n .catch((err) => {\n toast.show(STRINGS.TOAST.DOWNLOAD_ERROR, 'error');\n Logger.log('File save failure', err);\n });\n }\n };\n\n return (\n <View style={{ flex: 1, backgroundColor: palette.background700 }}>\n <StatusBar barStyle={'light-content'} animated />\n <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>\n {fileViewer}\n {loading && <LoadingSpinner style={{ position: 'absolute' }} size={40} color={palette.primary300} />}\n </View>\n {headerShown && (\n <FileViewerHeader\n title={STRINGS.FILE_VIEWER.TITLE(fileMessage)}\n subtitle={STRINGS.FILE_VIEWER.SUBTITLE(fileMessage)}\n topInset={headerTopInset ?? basicTopInset}\n onClose={onClose}\n />\n )}\n <FileViewerFooter\n bottomInset={bottom}\n deleteShown={canDelete}\n onPressDelete={_onPressDelete}\n onPressDownload={_onPressDownload}\n />\n </View>\n );\n};\n\ntype HeaderProps = {\n topInset: number;\n onClose: () => void;\n title: string;\n subtitle: string;\n};\nconst FileViewerHeader = ({ topInset, onClose, subtitle, title }: HeaderProps) => {\n const { palette } = useUIKitTheme();\n const { defaultHeight } = useHeaderStyle();\n const { left, right } = useSafeAreaInsets();\n\n return (\n <View\n style={[\n styles.headerContainer,\n {\n paddingLeft: styles.headerContainer.paddingHorizontal + left,\n paddingRight: styles.headerContainer.paddingHorizontal + right,\n },\n { paddingTop: topInset, height: defaultHeight + topInset, backgroundColor: palette.overlay01 },\n ]}\n >\n <TouchableOpacity onPress={onClose} style={styles.barButton}>\n <Icon icon={'close'} size={24} color={palette.onBackgroundDark01} />\n </TouchableOpacity>\n <View style={styles.barTitleContainer}>\n <Text h2 color={palette.onBackgroundDark01} style={styles.headerTitle}>\n {title}\n </Text>\n <Text caption2 color={palette.onBackgroundDark01}>\n {subtitle}\n </Text>\n </View>\n <View style={styles.barButton} />\n </View>\n );\n};\n\ntype FooterProps = {\n bottomInset: number;\n deleteShown: boolean;\n onPressDelete: () => void;\n onPressDownload: () => void;\n};\nconst FileViewerFooter = ({ bottomInset, deleteShown, onPressDelete, onPressDownload }: FooterProps) => {\n const { palette } = useUIKitTheme();\n const { defaultHeight } = useHeaderStyle();\n const { left, right } = useSafeAreaInsets();\n\n return (\n <View\n style={[\n styles.footerContainer,\n {\n paddingLeft: styles.headerContainer.paddingHorizontal + left,\n paddingRight: styles.headerContainer.paddingHorizontal + right,\n },\n {\n paddingBottom: bottomInset,\n height: defaultHeight + bottomInset,\n backgroundColor: palette.overlay01,\n },\n ]}\n >\n <TouchableOpacity onPress={onPressDownload} style={styles.barButton}>\n <Icon icon={'download'} size={24} color={palette.onBackgroundDark01} />\n </TouchableOpacity>\n <View style={styles.barTitleContainer} />\n <TouchableOpacity onPress={onPressDelete} style={styles.barButton} disabled={!deleteShown}>\n {deleteShown && <Icon icon={'delete'} size={24} color={palette.onBackgroundDark01} />}\n </TouchableOpacity>\n </View>\n );\n};\n\nconst styles = createStyleSheet({\n headerContainer: {\n top: 0,\n left: 0,\n right: 0,\n position: 'absolute',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n paddingHorizontal: 12,\n },\n barButton: {\n width: 32,\n height: 32,\n alignItems: 'center',\n justifyContent: 'center',\n },\n barTitleContainer: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n },\n headerTitle: {\n marginBottom: 2,\n },\n footerContainer: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'center',\n paddingHorizontal: 12,\n },\n});\n\nexport default FileViewer;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,QAA2C,OAA3C;AACA,SAASC,SAAT,EAAoBC,UAApB,EAAgCC,gBAAhC,EA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EARJ,CADa;EAW9BK,SAAS,EAAE;IACTU,KAAK,EAAE,EADE;IAETZ,MAAM,EAAE,EAFC;IAGTjB,UAAU,EAAE,QAHH;IAITC,cAAc,EAAE;EAJP,CAXmB;EAiB9BoB,iBAAiB,EAAE;IACjBxB,IAAI,EAAE,CADW;IAEjBG,UAAU,EAAE,QAFK;IAGjBC,cAAc,EAAE;EAHC,CAjBW;EAsB9BqB,WAAW,EAAE;IACXQ,YAAY,EAAE;EADH,CAtBiB;EAyB9BJ,eAAe,EAAE;IACfxB,QAAQ,EAAE,UADK;IAEfO,IAAI,EAAE,CAFS;IAGfC,KAAK,EAAE,CAHQ;IAIf9D,MAAM,EAAE,CAJO;IAKfgF,aAAa,EAAE,KALA;IAMf5B,UAAU,EAAE,QANG;IAOfC,cAAc,EAAE,QAPD;IAQfa,iBAAiB,EAAE;EARJ;AAzBa,CAAD,CAA/B;AAqCA,eAAe5E,UAAf"}
@@ -0,0 +1,100 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import { Icon, Image, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';
4
+ import { getAvailableUriFromFileMessage } from '@sendbird/uikit-utils';
5
+ import { usePlatformService } from '../../../hooks/useContext';
6
+
7
+ const VideoFileMessage = _ref => {
8
+ let {
9
+ message
10
+ } = _ref;
11
+ const {
12
+ colors
13
+ } = useUIKitTheme();
14
+ const {
15
+ mediaService
16
+ } = usePlatformService();
17
+ const fileUrl = getAvailableUriFromFileMessage(message);
18
+ const style = [styles.image, {
19
+ backgroundColor: colors.onBackground04
20
+ }];
21
+ const [state, setState] = useState({
22
+ thumbnail: null,
23
+ loading: true,
24
+ imageNotFound: false
25
+ });
26
+ useEffect(() => {
27
+ mediaService === null || mediaService === void 0 ? void 0 : mediaService.getVideoThumbnail({
28
+ url: fileUrl,
29
+ timeMills: 1000
30
+ }).then(result => {
31
+ if (result !== null && result !== void 0 && result.path) {
32
+ setState(prev => ({ ...prev,
33
+ loading: false,
34
+ thumbnail: result.path
35
+ }));
36
+ } else {
37
+ throw new Error('Cannot generate thumbnail');
38
+ }
39
+ }).catch(() => {
40
+ setState(prev => ({ ...prev,
41
+ loading: false,
42
+ imageNotFound: true
43
+ }));
44
+ });
45
+ }, []);
46
+
47
+ if (state.loading || state.imageNotFound) {
48
+ return /*#__PURE__*/React.createElement(View, {
49
+ style: [style, styles.container]
50
+ }, /*#__PURE__*/React.createElement(PlayIcon, null));
51
+ }
52
+
53
+ return /*#__PURE__*/React.createElement(View, {
54
+ style: styles.container
55
+ }, /*#__PURE__*/React.createElement(Image, {
56
+ source: {
57
+ uri: state.thumbnail || fileUrl
58
+ },
59
+ style: style,
60
+ resizeMode: 'cover',
61
+ resizeMethod: 'resize',
62
+ onError: () => setState(prev => ({ ...prev,
63
+ imageNotFound: true
64
+ }))
65
+ }), /*#__PURE__*/React.createElement(PlayIcon, null));
66
+ };
67
+
68
+ const PlayIcon = () => {
69
+ const {
70
+ colors
71
+ } = useUIKitTheme();
72
+ return /*#__PURE__*/React.createElement(Icon, {
73
+ icon: 'play',
74
+ size: 28,
75
+ color: colors.onBackground02,
76
+ containerStyle: [styles.playIcon, {
77
+ backgroundColor: colors.onBackgroundReverse01
78
+ }]
79
+ });
80
+ };
81
+
82
+ const styles = createStyleSheet({
83
+ container: {
84
+ alignItems: 'center',
85
+ justifyContent: 'center'
86
+ },
87
+ image: {
88
+ width: 240,
89
+ maxWidth: 240,
90
+ height: 160,
91
+ borderRadius: 16
92
+ },
93
+ playIcon: {
94
+ position: 'absolute',
95
+ padding: 10,
96
+ borderRadius: 50
97
+ }
98
+ });
99
+ export default VideoFileMessage;
100
+ //# sourceMappingURL=VideoFileMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useState","View","Icon","Image","createStyleSheet","useUIKitTheme","getAvailableUriFromFileMessage","usePlatformService","VideoFileMessage","message","colors","mediaService","fileUrl","style","styles","image","backgroundColor","onBackground04","state","setState","thumbnail","loading","imageNotFound","getVideoThumbnail","url","timeMills","then","result","path","prev","Error","catch","container","uri","PlayIcon","onBackground02","playIcon","onBackgroundReverse01","alignItems","justifyContent","width","maxWidth","height","borderRadius","position","padding"],"sources":["VideoFileMessage.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { View } from 'react-native';\n\nimport { Icon, Image, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';\nimport { getAvailableUriFromFileMessage } from '@sendbird/uikit-utils';\n\nimport { usePlatformService } from '../../../hooks/useContext';\nimport type { FileMessageProps } from './index';\n\nconst VideoFileMessage = ({ message }: FileMessageProps) => {\n const { colors } = useUIKitTheme();\n\n const { mediaService } = usePlatformService();\n const fileUrl = getAvailableUriFromFileMessage(message);\n const style = [styles.image, { backgroundColor: colors.onBackground04 }];\n\n const [state, setState] = useState({\n thumbnail: null as null | string,\n loading: true,\n imageNotFound: false,\n });\n\n useEffect(() => {\n mediaService\n ?.getVideoThumbnail({ url: fileUrl, timeMills: 1000 })\n .then((result) => {\n if (result?.path) {\n setState((prev) => ({ ...prev, loading: false, thumbnail: result.path }));\n } else {\n throw new Error('Cannot generate thumbnail');\n }\n })\n .catch(() => {\n setState((prev) => ({ ...prev, loading: false, imageNotFound: true }));\n });\n }, []);\n\n if (state.loading || state.imageNotFound) {\n return (\n <View style={[style, styles.container]}>\n <PlayIcon />\n </View>\n );\n }\n\n return (\n <View style={styles.container}>\n <Image\n source={{ uri: state.thumbnail || fileUrl }}\n style={style}\n resizeMode={'cover'}\n resizeMethod={'resize'}\n onError={() => setState((prev) => ({ ...prev, imageNotFound: true }))}\n />\n <PlayIcon />\n </View>\n );\n};\n\nconst PlayIcon = () => {\n const { colors } = useUIKitTheme();\n\n return (\n <Icon\n icon={'play'}\n size={28}\n color={colors.onBackground02}\n containerStyle={[styles.playIcon, { backgroundColor: colors.onBackgroundReverse01 }]}\n />\n );\n};\n\nconst styles = createStyleSheet({\n container: {\n alignItems: 'center',\n justifyContent: 'center',\n },\n image: {\n width: 240,\n maxWidth: 240,\n height: 160,\n borderRadius: 16,\n },\n playIcon: {\n position: 'absolute',\n padding: 10,\n borderRadius: 50,\n },\n});\n\nexport default VideoFileMessage;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,QAA2C,OAA3C;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,gBAAtB,EAAwCC,aAAxC,QAA6D,yCAA7D;AACA,SAASC,8BAAT,QAA+C,uBAA/C;AAEA,SAASC,kBAAT,QAAmC,2BAAnC;;AAGA,MAAMC,gBAAgB,GAAG,QAAmC;EAAA,IAAlC;IAAEC;EAAF,CAAkC;EAC1D,MAAM;IAAEC;EAAF,IAAaL,aAAa,EAAhC;EAEA,MAAM;IAAEM;EAAF,IAAmBJ,kBAAkB,EAA3C;EACA,MAAMK,OAAO,GAAGN,8BAA8B,CAACG,OAAD,CAA9C;EACA,MAAMI,KAAK,GAAG,CAACC,MAAM,CAACC,KAAR,EAAe;IAAEC,eAAe,EAAEN,MAAM,CAACO;EAA1B,CAAf,CAAd;EAEA,MAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBnB,QAAQ,CAAC;IACjCoB,SAAS,EAAE,IADsB;IAEjCC,OAAO,EAAE,IAFwB;IAGjCC,aAAa,EAAE;EAHkB,CAAD,CAAlC;EAMAvB,SAAS,CAAC,MAAM;IACdY,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CACRY,iBADJ,CACsB;MAAEC,GAAG,EAAEZ,OAAP;MAAgBa,SAAS,EAAE;IAA3B,CADtB,EAEGC,IAFH,CAESC,MAAD,IAAY;MAChB,IAAIA,MAAJ,aAAIA,MAAJ,eAAIA,MAAM,CAAEC,IAAZ,EAAkB;QAChBT,QAAQ,CAAEU,IAAD,KAAW,EAAE,GAAGA,IAAL;UAAWR,OAAO,EAAE,KAApB;UAA2BD,SAAS,EAAEO,MAA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BAAgB,CAAC;EAC9B4B,SAAS,EAAE;IACTM,UAAU,EAAE,QADH;IAETC,cAAc,EAAE;EAFP,CADmB;EAK9BxB,KAAK,EAAE;IACLyB,KAAK,EAAE,GADF;IAELC,QAAQ,EAAE,GAFL;IAGLC,MAAM,EAAE,GAHH;IAILC,YAAY,EAAE;EAJT,CALuB;EAW9BP,QAAQ,EAAE;IACRQ,QAAQ,EAAE,UADF;IAERC,OAAO,EAAE,EAFD;IAGRF,YAAY,EAAE;EAHN;AAXoB,CAAD,CAA/B;AAkBA,eAAenC,gBAAf"}
@@ -2,12 +2,18 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
2
2
 
3
3
  import React from 'react';
4
4
  import { getFileExtension, getFileType } from '@sendbird/uikit-utils';
5
+ import { usePlatformService } from '../../../hooks/useContext';
5
6
  import BaseFileMessage from './BaseFileMessage';
6
7
  import ImageFileMessage from './ImageFileMessage';
8
+ import VideoFileMessage from './VideoFileMessage';
7
9
 
8
10
  const FileMessage = props => {
11
+ const {
12
+ mediaService
13
+ } = usePlatformService();
9
14
  const fileType = getFileType(props.message.type || getFileExtension(props.message.name));
10
15
  if (fileType === 'image') return /*#__PURE__*/React.createElement(ImageFileMessage, props);
16
+ if (fileType === 'video' && mediaService !== null && mediaService !== void 0 && mediaService.getVideoThumbnail) return /*#__PURE__*/React.createElement(VideoFileMessage, props);
11
17
  return /*#__PURE__*/React.createElement(BaseFileMessage, _extends({}, props, {
12
18
  type: fileType
13
19
  }));
@@ -1 +1 @@
1
- {"version":3,"names":["React","getFileExtension","getFileType","BaseFileMessage","ImageFileMessage","FileMessage","props","fileType","message","type","name","memo"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { SendbirdFileMessage, getFileExtension, getFileType } from '@sendbird/uikit-utils';\n\nimport type { MessageRendererInterface } from '../index';\nimport BaseFileMessage from './BaseFileMessage';\nimport ImageFileMessage from './ImageFileMessage';\n\nexport type FileMessageProps = MessageRendererInterface<SendbirdFileMessage>;\nconst FileMessage = (props: FileMessageProps) => {\n const fileType = getFileType(props.message.type || getFileExtension(props.message.name));\n\n if (fileType === 'image') return <ImageFileMessage {...props} />;\n return <BaseFileMessage {...props} type={fileType} />;\n};\n\nexport default React.memo(FileMessage);\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAA8BC,gBAA9B,EAAgDC,WAAhD,QAAmE,uBAAnE;AAGA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAGA,MAAMC,WAAW,GAAIC,KAAD,IAA6B;EAC/C,MAAMC,QAAQ,GAAGL,WAAW,CAACI,KAAK,CAACE,OAAN,CAAcC,IAAd,IAAsBR,gBAAgB,CAACK,KAAK,CAACE,OAAN,CAAcE,IAAf,CAAvC,CAA5B;EAEA,IAAIH,QAAQ,KAAK,OAAjB,EAA0B,oBAAO,oBAAC,gBAAD,EAAsBD,KAAtB,CAAP;EAC1B,oBAAO,oBAAC,eAAD,eAAqBA,KAArB;IAA4B,IAAI,EAAEC;EAAlC,GAAP;AACD,CALD;;AAOA,4BAAeP,KAAK,CAACW,IAAN,CAAWN,WAAX,CAAf"}
1
+ {"version":3,"names":["React","getFileExtension","getFileType","usePlatformService","BaseFileMessage","ImageFileMessage","VideoFileMessage","FileMessage","props","mediaService","fileType","message","type","name","getVideoThumbnail","memo"],"sources":["index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { SendbirdFileMessage, getFileExtension, getFileType } from '@sendbird/uikit-utils';\n\nimport { usePlatformService } from '../../../hooks/useContext';\nimport type { MessageRendererInterface } from '../index';\nimport BaseFileMessage from './BaseFileMessage';\nimport ImageFileMessage from './ImageFileMessage';\nimport VideoFileMessage from './VideoFileMessage';\n\nexport type FileMessageProps = MessageRendererInterface<SendbirdFileMessage>;\nconst FileMessage = (props: FileMessageProps) => {\n const { mediaService } = usePlatformService();\n\n const fileType = getFileType(props.message.type || getFileExtension(props.message.name));\n\n if (fileType === 'image') return <ImageFileMessage {...props} />;\n if (fileType === 'video' && mediaService?.getVideoThumbnail) return <VideoFileMessage {...props} />;\n\n return <BaseFileMessage {...props} type={fileType} />;\n};\n\nexport default React.memo(FileMessage);\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAA8BC,gBAA9B,EAAgDC,WAAhD,QAAmE,uBAAnE;AAEA,SAASC,kBAAT,QAAmC,2BAAnC;AAEA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;;AAGA,MAAMC,WAAW,GAAIC,KAAD,IAA6B;EAC/C,MAAM;IAAEC;EAAF,IAAmBN,kBAAkB,EAA3C;EAEA,MAAMO,QAAQ,GAAGR,WAAW,CAACM,KAAK,CAACG,OAAN,CAAcC,IAAd,IAAsBX,gBAAgB,CAACO,KAAK,CAACG,OAAN,CAAcE,IAAf,CAAvC,CAA5B;EAEA,IAAIH,QAAQ,KAAK,OAAjB,EAA0B,oBAAO,oBAAC,gBAAD,EAAsBF,KAAtB,CAAP;EAC1B,IAAIE,QAAQ,KAAK,OAAb,IAAwBD,YAAxB,aAAwBA,YAAxB,eAAwBA,YAAY,CAAEK,iBAA1C,EAA6D,oBAAO,oBAAC,gBAAD,EAAsBN,KAAtB,CAAP;EAE7D,oBAAO,oBAAC,eAAD,eAAqBA,KAArB;IAA4B,IAAI,EAAEE;EAAlC,GAAP;AACD,CATD;;AAWA,4BAAeV,KAAK,CAACe,IAAN,CAAWR,WAAX,CAAf"}
@@ -1,6 +1,6 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React from 'react';
2
+ import { useMessageOutgoingStatus } from '@sendbird/uikit-chat-hooks';
2
3
  import { Icon, LoadingSpinner, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';
3
- import { useUniqId } from '@sendbird/uikit-utils';
4
4
  import { useSendbirdChat } from '../../hooks/useContext';
5
5
  const SIZE = 16;
6
6
 
@@ -10,60 +10,22 @@ const MessageOutgoingStatus = _ref => {
10
10
  message
11
11
  } = _ref;
12
12
  if (!message.isUserMessage() && !message.isFileMessage()) return null;
13
- const handlerId = useUniqId('MessageOutgoingStatus');
14
13
  const {
15
- sdk,
16
- features
14
+ sdk
17
15
  } = useSendbirdChat();
18
16
  const {
19
17
  colors
20
18
  } = useUIKitTheme();
21
- const [state, setState] = useState(() => ({
22
- unreadCount: channel.getUnreadMemberCount(message),
23
- undeliveredCount: channel.getUndeliveredMemberCount(message)
24
- }));
19
+ const outgoingStatus = useMessageOutgoingStatus(sdk, channel, message);
25
20
 
26
- const getCounts = (channel, message) => {
27
- return {
28
- unreadCount: channel.getUnreadMemberCount(message),
29
- undeliveredCount: channel.getUndeliveredMemberCount(message)
30
- };
31
- };
32
-
33
- useEffect(() => {
34
- const id = String(handlerId);
35
-
36
- if (message.sendingStatus === 'succeeded' && state.unreadCount === 0 && state.undeliveredCount === 0) {
37
- sdk.removeChannelHandler(id);
38
- } else {
39
- const handler = new sdk.ChannelHandler();
40
-
41
- handler.onReadReceiptUpdated = channel => {
42
- if (channel.url === message.channelUrl) setState(getCounts(channel, message));
43
- };
44
-
45
- if (features.deliveryReceiptEnabled) {
46
- handler.onDeliveryReceiptUpdated = channel => {
47
- if (channel.url === message.channelUrl && channel.isGroupChannel()) setState(getCounts(channel, message));
48
- };
49
- }
50
-
51
- sdk.addChannelHandler(id, handler);
52
- }
53
-
54
- return () => {
55
- sdk.removeChannelHandler(id);
56
- };
57
- }, [message.sendingStatus]);
58
-
59
- if (message.sendingStatus === 'pending') {
21
+ if (outgoingStatus === 'PENDING') {
60
22
  return /*#__PURE__*/React.createElement(LoadingSpinner, {
61
23
  size: SIZE,
62
24
  style: styles.container
63
25
  });
64
26
  }
65
27
 
66
- if (message.sendingStatus === 'failed') {
28
+ if (outgoingStatus === 'FAILED') {
67
29
  return /*#__PURE__*/React.createElement(Icon, {
68
30
  icon: 'error',
69
31
  size: SIZE,
@@ -72,7 +34,7 @@ const MessageOutgoingStatus = _ref => {
72
34
  });
73
35
  }
74
36
 
75
- if (state.unreadCount === 0) {
37
+ if (outgoingStatus === 'READ') {
76
38
  return /*#__PURE__*/React.createElement(Icon, {
77
39
  icon: 'done-all',
78
40
  size: SIZE,
@@ -81,16 +43,16 @@ const MessageOutgoingStatus = _ref => {
81
43
  });
82
44
  }
83
45
 
84
- if (features.deliveryReceiptEnabled) {
85
- if (state.undeliveredCount === 0) {
86
- return /*#__PURE__*/React.createElement(Icon, {
87
- icon: 'done-all',
88
- size: SIZE,
89
- color: colors.onBackground03,
90
- style: styles.container
91
- });
92
- }
46
+ if (outgoingStatus === 'UNREAD' || outgoingStatus === 'DELIVERED') {
47
+ return /*#__PURE__*/React.createElement(Icon, {
48
+ icon: 'done-all',
49
+ size: SIZE,
50
+ color: colors.onBackground03,
51
+ style: styles.container
52
+ });
53
+ }
93
54
 
55
+ if (outgoingStatus === 'UNDELIVERED') {
94
56
  return /*#__PURE__*/React.createElement(Icon, {
95
57
  icon: 'done',
96
58
  size: SIZE,
@@ -99,12 +61,7 @@ const MessageOutgoingStatus = _ref => {
99
61
  });
100
62
  }
101
63
 
102
- return /*#__PURE__*/React.createElement(Icon, {
103
- icon: 'done-all',
104
- size: SIZE,
105
- color: colors.onBackground03,
106
- style: styles.container
107
- });
64
+ return null;
108
65
  };
109
66
 
110
67
  const styles = createStyleSheet({
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useState","Icon","LoadingSpinner","createStyleSheet","useUIKitTheme","useUniqId","useSendbirdChat","SIZE","MessageOutgoingStatus","channel","message","isUserMessage","isFileMessage","handlerId","sdk","features","colors","state","setState","unreadCount","getUnreadMemberCount","undeliveredCount","getUndeliveredMemberCount","getCounts","id","String","sendingStatus","removeChannelHandler","handler","ChannelHandler","onReadReceiptUpdated","url","channelUrl","deliveryReceiptEnabled","onDeliveryReceiptUpdated","isGroupChannel","addChannelHandler","styles","container","error","secondary","onBackground03","marginRight","memo"],"sources":["MessageOutgoingStatus.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport { Icon, LoadingSpinner, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';\nimport type {\n SendbirdFileMessage,\n SendbirdGroupChannel,\n SendbirdMessage,\n SendbirdUserMessage,\n} from '@sendbird/uikit-utils';\nimport { useUniqId } from '@sendbird/uikit-utils';\n\nimport { useSendbirdChat } from '../../hooks/useContext';\n\nconst SIZE = 16;\n\ntype Props = { channel: SendbirdGroupChannel; message: SendbirdMessage };\nconst MessageOutgoingStatus = ({ channel, message }: Props) => {\n if (!message.isUserMessage() && !message.isFileMessage()) return null;\n\n const handlerId = useUniqId('MessageOutgoingStatus');\n\n const { sdk, features } = useSendbirdChat();\n const { colors } = useUIKitTheme();\n\n const [state, setState] = useState(() => ({\n unreadCount: channel.getUnreadMemberCount(message),\n undeliveredCount: channel.getUndeliveredMemberCount(message),\n }));\n\n const getCounts = (channel: SendbirdGroupChannel, message: SendbirdUserMessage | SendbirdFileMessage) => {\n return {\n unreadCount: channel.getUnreadMemberCount(message),\n undeliveredCount: channel.getUndeliveredMemberCount(message),\n };\n };\n\n useEffect(() => {\n const id = String(handlerId);\n if (message.sendingStatus === 'succeeded' && state.unreadCount === 0 && state.undeliveredCount === 0) {\n sdk.removeChannelHandler(id);\n } else {\n const handler = new sdk.ChannelHandler();\n handler.onReadReceiptUpdated = (channel) => {\n if (channel.url === message.channelUrl) setState(getCounts(channel, message));\n };\n\n if (features.deliveryReceiptEnabled) {\n handler.onDeliveryReceiptUpdated = (channel) => {\n if (channel.url === message.channelUrl && channel.isGroupChannel()) setState(getCounts(channel, message));\n };\n }\n sdk.addChannelHandler(id, handler);\n }\n\n return () => {\n sdk.removeChannelHandler(id);\n };\n }, [message.sendingStatus]);\n\n if (message.sendingStatus === 'pending') {\n return <LoadingSpinner size={SIZE} style={styles.container} />;\n }\n\n if (message.sendingStatus === 'failed') {\n return <Icon icon={'error'} size={SIZE} color={colors.error} style={styles.container} />;\n }\n\n if (state.unreadCount === 0) {\n return <Icon icon={'done-all'} size={SIZE} color={colors.secondary} style={styles.container} />;\n }\n\n if (features.deliveryReceiptEnabled) {\n if (state.undeliveredCount === 0) {\n return <Icon icon={'done-all'} size={SIZE} color={colors.onBackground03} style={styles.container} />;\n }\n return <Icon icon={'done'} size={SIZE} color={colors.onBackground03} style={styles.container} />;\n }\n\n return <Icon icon={'done-all'} size={SIZE} color={colors.onBackground03} style={styles.container} />;\n};\n\nconst styles = createStyleSheet({\n container: {\n marginRight: 4,\n },\n});\n\nexport default React.memo(MessageOutgoingStatus);\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,QAA2C,OAA3C;AAEA,SAASC,IAAT,EAAeC,cAAf,EAA+BC,gBAA/B,EAAiDC,aAAjD,QAAsE,yCAAtE;AAOA,SAASC,SAAT,QAA0B,uBAA1B;AAEA,SAASC,eAAT,QAAgC,wBAAhC;AAEA,MAAMC,IAAI,GAAG,EAAb;;AAGA,MAAMC,qBAAqB,GAAG,QAAiC;EAAA,IAAhC;IAAEC,OAAF;IAAWC;EAAX,CAAgC;EAC7D,IAAI,CAACA,OAAO,CAACC,aAAR,EAAD,IAA4B,CAACD,OAAO,CAACE,aAAR,EAAjC,EAA0D,OAAO,IAAP;EAE1D,MAAMC,SAAS,GAAGR,SAAS,CAAC,uBAAD,CAA3B;EAEA,MAAM;IAAES,GAAF;IAAOC;EAAP,IAAoBT,eAAe,EAAzC;EACA,MAAM;IAAEU;EAAF,IAAaZ,aAAa,EAAhC;EAEA,MAAM,CAACa,KAAD,EAAQC,QAAR,IAAoBlB,QAAQ,CAAC,OAAO;IACxCmB,WAAW,EAAEV,OAAO,CAACW,oBAAR,CAA6BV,OAA7B,CAD2B;IAExCW,gBAAgB,EAAEZ,OAAO,CAACa,yBAAR,CAAkCZ,OAAlC;EAFsB,CAAP,CAAD,CAAlC;;EAKA,MAAMa,SAAS,GAAG,CAACd,OAA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S,EAAE;IACTI,WAAW,EAAE;EADJ;AADmB,CAAD,CAA/B;AAMA,4BAAe5C,KAAK,CAAC6C,IAAN,CAAWnC,qBAAX,CAAf"}
1
+ {"version":3,"names":["React","useMessageOutgoingStatus","Icon","LoadingSpinner","createStyleSheet","useUIKitTheme","useSendbirdChat","SIZE","MessageOutgoingStatus","channel","message","isUserMessage","isFileMessage","sdk","colors","outgoingStatus","styles","container","error","secondary","onBackground03","marginRight","memo"],"sources":["MessageOutgoingStatus.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useMessageOutgoingStatus } from '@sendbird/uikit-chat-hooks';\nimport { Icon, LoadingSpinner, createStyleSheet, useUIKitTheme } from '@sendbird/uikit-react-native-foundation';\nimport type { SendbirdGroupChannel, SendbirdMessage } from '@sendbird/uikit-utils';\n\nimport { useSendbirdChat } from '../../hooks/useContext';\n\nconst SIZE = 16;\n\ntype Props = { channel: SendbirdGroupChannel; message: SendbirdMessage };\nconst MessageOutgoingStatus = ({ channel, message }: Props) => {\n if (!message.isUserMessage() && !message.isFileMessage()) return null;\n\n const { sdk } = useSendbirdChat();\n const { colors } = useUIKitTheme();\n const outgoingStatus = useMessageOutgoingStatus(sdk, channel, message);\n\n if (outgoingStatus === 'PENDING') {\n return <LoadingSpinner size={SIZE} style={styles.container} />;\n }\n\n if (outgoingStatus === 'FAILED') {\n return <Icon icon={'error'} size={SIZE} color={colors.error} style={styles.container} />;\n }\n\n if (outgoingStatus === 'READ') {\n return <Icon icon={'done-all'} size={SIZE} color={colors.secondary} style={styles.container} />;\n }\n\n if (outgoingStatus === 'UNREAD' || outgoingStatus === 'DELIVERED') {\n return <Icon icon={'done-all'} size={SIZE} color={colors.onBackground03} style={styles.container} />;\n }\n\n if (outgoingStatus === 'UNDELIVERED') {\n return <Icon icon={'done'} size={SIZE} color={colors.onBackground03} style={styles.container} />;\n }\n\n return null;\n};\n\nconst styles = createStyleSheet({\n container: {\n marginRight: 4,\n },\n});\n\nexport default React.memo(MessageOutgoingSt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,IAAD;MAAM,IAAI,EAAE,UAAZ;MAAwB,IAAI,EAAER,IAA9B;MAAoC,KAAK,EAAEO,MAAM,CAACM,cAAlD;MAAkE,KAAK,EAAEJ,MAAM,CAACC;IAAhF,EAAP;EACD;;EAED,IAAIF,cAAc,KAAK,aAAvB,EAAsC;IACpC,oBAAO,oBAAC,IAAD;MAAM,IAAI,EAAE,MAAZ;MAAoB,IAAI,EAAER,IAA1B;MAAgC,KAAK,EAAEO,MAAM,CAACM,cAA9C;MAA8D,KAAK,EAAEJ,MAAM,CAACC;IAA5E,EAAP;EACD;;EAED,OAAO,IAAP;AACD,CA5BD;;AA8BA,MAAMD,MAAM,GAAGZ,gBAAgB,CAAC;EAC9Ba,SAAS,EAAE;IACTI,WAAW,EAAE;EADJ;AADmB,CAAD,CAA/B;AAMA,4BAAerB,KAAK,CAACsB,IAAN,CAAWd,qBAAX,CAAf"}
@@ -77,5 +77,5 @@ const styles = createStyleSheet({
77
77
  marginRight: 8
78
78
  }
79
79
  });
80
- export default /*#__PURE__*/React.memo(UserActionBar);
80
+ export default UserActionBar;
81
81
  //# sourceMappingURL=UserActionBar.js.map