@ethora/chat-component-rn 26.7.2 → 26.7.4
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.
- package/CHANGELOG.md +45 -0
- package/README.md +9 -8
- package/lib/commonjs/assets/icons.js +7 -2
- package/lib/commonjs/assets/icons.js.map +1 -1
- package/lib/commonjs/components/Header/HeaderRoomList.js +20 -6
- package/lib/commonjs/components/Header/HeaderRoomList.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatRoom.js +86 -7
- package/lib/commonjs/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatWrapper.js +18 -0
- package/lib/commonjs/components/MainComponents/ChatWrapper.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MessageList.js +11 -4
- package/lib/commonjs/components/MainComponents/MessageList.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js +5 -5
- package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
- package/lib/commonjs/components/MainComponents/RoomList.js +62 -32
- package/lib/commonjs/components/MainComponents/RoomList.js.map +1 -1
- package/lib/commonjs/components/Menu/HeaderRoomListMenu.js +208 -70
- package/lib/commonjs/components/Menu/HeaderRoomListMenu.js.map +1 -1
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js +307 -99
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +544 -200
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js +226 -0
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +6 -2
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/commonjs/components/Modals/Modal/Modal.js +8 -0
- package/lib/commonjs/components/Modals/Modal/Modal.js.map +1 -1
- package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js +202 -104
- package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js +556 -0
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -0
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js +210 -0
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js.map +1 -0
- package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js +4 -2
- package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js +507 -244
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js +74 -46
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/commonjs/components/Modals/styledModalComponents.js +9 -2
- package/lib/commonjs/components/Modals/styledModalComponents.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js +17 -7
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/commonjs/components/styled/SendInput.js +80 -1
- package/lib/commonjs/components/styled/SendInput.js.map +1 -1
- package/lib/commonjs/components/styled/StyledComponents.js +9 -3
- package/lib/commonjs/components/styled/StyledComponents.js.map +1 -1
- package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js +11 -4
- package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
- package/lib/commonjs/context/xmppProvider.js +12 -0
- package/lib/commonjs/context/xmppProvider.js.map +1 -1
- package/lib/commonjs/helpers/getChatBackground.js +23 -0
- package/lib/commonjs/helpers/getChatBackground.js.map +1 -0
- package/lib/commonjs/helpers/historyPreloadScheduler.js +65 -2
- package/lib/commonjs/helpers/historyPreloadScheduler.js.map +1 -1
- package/lib/commonjs/helpers/mediaLibraryRuntime.js +31 -0
- package/lib/commonjs/helpers/mediaLibraryRuntime.js.map +1 -0
- package/lib/commonjs/helpers/shallowEqual.js +36 -0
- package/lib/commonjs/helpers/shallowEqual.js.map +1 -0
- package/lib/commonjs/helpers/sheetGestures.js +32 -0
- package/lib/commonjs/helpers/sheetGestures.js.map +1 -0
- package/lib/commonjs/hooks/useChatWrapperInit.js +15 -0
- package/lib/commonjs/hooks/useChatWrapperInit.js.map +1 -1
- package/lib/commonjs/hooks/useComposing.js +27 -0
- package/lib/commonjs/hooks/useComposing.js.map +1 -1
- package/lib/commonjs/hooks/useSendMessage.js +27 -1
- package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
- package/lib/commonjs/hooks/useUnreadMessagesCounter.js +6 -1
- package/lib/commonjs/hooks/useUnreadMessagesCounter.js.map +1 -1
- package/lib/commonjs/i18n/strings.js +121 -1
- package/lib/commonjs/i18n/strings.js.map +1 -1
- package/lib/commonjs/networking/api-requests/user.api.js +59 -0
- package/lib/commonjs/networking/api-requests/user.api.js.map +1 -1
- package/lib/commonjs/networking/xmpp/flushLastViewedToPrivateStore.js +6 -2
- package/lib/commonjs/networking/xmpp/flushLastViewedToPrivateStore.js.map +1 -1
- package/lib/commonjs/networking/xmppClient.js.map +1 -1
- package/lib/commonjs/roomStore/chatSettingsSlice.js +3 -1
- package/lib/commonjs/roomStore/chatSettingsSlice.js.map +1 -1
- package/lib/commonjs/roomStore/roomsSlice.js +2 -2
- package/lib/commonjs/roomStore/roomsSlice.js.map +1 -1
- package/lib/module/assets/icons.js +6 -1
- package/lib/module/assets/icons.js.map +1 -1
- package/lib/module/components/Header/HeaderRoomList.js +20 -6
- package/lib/module/components/Header/HeaderRoomList.js.map +1 -1
- package/lib/module/components/MainComponents/ChatRoom.js +87 -8
- package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/module/components/MainComponents/ChatWrapper.js +19 -1
- package/lib/module/components/MainComponents/ChatWrapper.js.map +1 -1
- package/lib/module/components/MainComponents/MessageList.js +11 -4
- package/lib/module/components/MainComponents/MessageList.js.map +1 -1
- package/lib/module/components/MainComponents/ProfileImagePlaceholder.js +5 -5
- package/lib/module/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
- package/lib/module/components/MainComponents/RoomList.js +62 -32
- package/lib/module/components/MainComponents/RoomList.js.map +1 -1
- package/lib/module/components/Menu/HeaderRoomListMenu.js +211 -73
- package/lib/module/components/Menu/HeaderRoomListMenu.js.map +1 -1
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js +298 -102
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +547 -204
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js +223 -0
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js.map +1 -0
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +6 -2
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/module/components/Modals/Modal/Modal.js +9 -1
- package/lib/module/components/Modals/Modal/Modal.js.map +1 -1
- package/lib/module/components/Modals/NewChatModal/NewChatModal.js +205 -106
- package/lib/module/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
- package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js +548 -0
- package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js.map +1 -0
- package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js +205 -0
- package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js.map +1 -0
- package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js +4 -2
- package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js +509 -248
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js +76 -48
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/module/components/Modals/styledModalComponents.js +9 -2
- package/lib/module/components/Modals/styledModalComponents.js.map +1 -1
- package/lib/module/components/RoomComponents/ChatRoomItem.js +17 -7
- package/lib/module/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/module/components/styled/SendInput.js +80 -1
- package/lib/module/components/styled/SendInput.js.map +1 -1
- package/lib/module/components/styled/StyledComponents.js +9 -3
- package/lib/module/components/styled/StyledComponents.js.map +1 -1
- package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js +11 -4
- package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
- package/lib/module/context/xmppProvider.js +12 -0
- package/lib/module/context/xmppProvider.js.map +1 -1
- package/lib/module/helpers/getChatBackground.js +18 -0
- package/lib/module/helpers/getChatBackground.js.map +1 -0
- package/lib/module/helpers/historyPreloadScheduler.js +66 -3
- package/lib/module/helpers/historyPreloadScheduler.js.map +1 -1
- package/lib/module/helpers/mediaLibraryRuntime.js +25 -0
- package/lib/module/helpers/mediaLibraryRuntime.js.map +1 -0
- package/lib/module/helpers/shallowEqual.js +31 -0
- package/lib/module/helpers/shallowEqual.js.map +1 -0
- package/lib/module/helpers/sheetGestures.js +26 -0
- package/lib/module/helpers/sheetGestures.js.map +1 -0
- package/lib/module/hooks/useChatWrapperInit.js +15 -0
- package/lib/module/hooks/useChatWrapperInit.js.map +1 -1
- package/lib/module/hooks/useComposing.js +28 -1
- package/lib/module/hooks/useComposing.js.map +1 -1
- package/lib/module/hooks/useSendMessage.js +28 -2
- package/lib/module/hooks/useSendMessage.js.map +1 -1
- package/lib/module/hooks/useUnreadMessagesCounter.js +6 -1
- package/lib/module/hooks/useUnreadMessagesCounter.js.map +1 -1
- package/lib/module/i18n/strings.js +121 -1
- package/lib/module/i18n/strings.js.map +1 -1
- package/lib/module/networking/api-requests/user.api.js +56 -0
- package/lib/module/networking/api-requests/user.api.js.map +1 -1
- package/lib/module/networking/xmpp/flushLastViewedToPrivateStore.js +6 -2
- package/lib/module/networking/xmpp/flushLastViewedToPrivateStore.js.map +1 -1
- package/lib/module/networking/xmppClient.js.map +1 -1
- package/lib/module/roomStore/chatSettingsSlice.js +3 -1
- package/lib/module/roomStore/chatSettingsSlice.js.map +1 -1
- package/lib/module/roomStore/roomsSlice.js +1 -1
- package/lib/module/roomStore/roomsSlice.js.map +1 -1
- package/lib/typescript/assets/icons.d.ts +12 -0
- package/lib/typescript/assets/icons.d.ts.map +1 -1
- package/lib/typescript/components/Header/HeaderRoomList.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatWrapper.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MessageList.d.ts +10 -1
- package/lib/typescript/components/MainComponents/MessageList.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/RoomList.d.ts.map +1 -1
- package/lib/typescript/components/Menu/HeaderRoomListMenu.d.ts.map +1 -1
- package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts +9 -0
- package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts +10 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts +9 -0
- package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts.map +1 -0
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/Modal/Modal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts +1 -1
- package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts +75 -0
- package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts.map +1 -0
- package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts +25 -0
- package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts.map +1 -0
- package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts +6 -1
- package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts +16 -0
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts +1 -0
- package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/styledModalComponents.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts.map +1 -1
- package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
- package/lib/typescript/components/styled/StyledComponents.d.ts.map +1 -1
- package/lib/typescript/components/styled/StyledInputComponents/StyledInputComponents.d.ts.map +1 -1
- package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
- package/lib/typescript/helpers/getChatBackground.d.ts +15 -0
- package/lib/typescript/helpers/getChatBackground.d.ts.map +1 -0
- package/lib/typescript/helpers/historyPreloadScheduler.d.ts.map +1 -1
- package/lib/typescript/helpers/mediaLibraryRuntime.d.ts +3 -0
- package/lib/typescript/helpers/mediaLibraryRuntime.d.ts.map +1 -0
- package/lib/typescript/helpers/shallowEqual.d.ts +11 -0
- package/lib/typescript/helpers/shallowEqual.d.ts.map +1 -0
- package/lib/typescript/helpers/sheetGestures.d.ts +20 -0
- package/lib/typescript/helpers/sheetGestures.d.ts.map +1 -0
- package/lib/typescript/hooks/useChatWrapperInit.d.ts.map +1 -1
- package/lib/typescript/hooks/useComposing.d.ts.map +1 -1
- package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
- package/lib/typescript/hooks/useUnreadMessagesCounter.d.ts +1 -0
- package/lib/typescript/hooks/useUnreadMessagesCounter.d.ts.map +1 -1
- package/lib/typescript/i18n/strings.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/user.api.d.ts +27 -0
- package/lib/typescript/networking/api-requests/user.api.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/flushLastViewedToPrivateStore.d.ts +1 -0
- package/lib/typescript/networking/xmpp/flushLastViewedToPrivateStore.d.ts.map +1 -1
- package/lib/typescript/networking/xmppClient.d.ts +1 -0
- package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
- package/lib/typescript/roomStore/chatSettingsSlice.d.ts.map +1 -1
- package/lib/typescript/roomStore/roomsSlice.d.ts +1 -0
- package/lib/typescript/roomStore/roomsSlice.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +9 -5
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/assets/icons.tsx +29 -9
- package/src/components/Header/HeaderRoomList.tsx +20 -5
- package/src/components/MainComponents/ChatRoom.tsx +92 -8
- package/src/components/MainComponents/ChatWrapper.tsx +19 -1
- package/src/components/MainComponents/MessageList.tsx +21 -3
- package/src/components/MainComponents/ProfileImagePlaceholder.tsx +5 -5
- package/src/components/MainComponents/RoomList.tsx +65 -34
- package/src/components/Menu/HeaderRoomListMenu.tsx +209 -64
- package/src/components/Modals/AttachSheet/AttachSheet.tsx +318 -86
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +599 -278
- package/src/components/Modals/ChatProfileModal/ReportChatModal.tsx +244 -0
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +4 -2
- package/src/components/Modals/Modal/Modal.tsx +7 -0
- package/src/components/Modals/NewChatModal/NewChatModal.tsx +219 -117
- package/src/components/Modals/ProfileHeader/ProfileHeader.tsx +615 -0
- package/src/components/Modals/ProfileHeader/ProfileMenu.tsx +217 -0
- package/src/components/Modals/SelectUsersModal/SelectUsersModal.tsx +14 -4
- package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +617 -307
- package/src/components/Modals/UserSettingsModal/UserSettingsModal.tsx +75 -58
- package/src/components/Modals/styledModalComponents.tsx +9 -2
- package/src/components/RoomComponents/ChatRoomItem.tsx +14 -7
- package/src/components/styled/SendInput.tsx +83 -2
- package/src/components/styled/StyledComponents.ts +9 -3
- package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +11 -4
- package/src/context/xmppProvider.tsx +14 -0
- package/src/helpers/getChatBackground.ts +18 -0
- package/src/helpers/historyPreloadScheduler.ts +80 -3
- package/src/helpers/mediaLibraryRuntime.ts +25 -0
- package/src/helpers/shallowEqual.ts +33 -0
- package/src/helpers/sheetGestures.ts +25 -0
- package/src/hooks/useChatWrapperInit.ts +15 -0
- package/src/hooks/useComposing.tsx +37 -1
- package/src/hooks/useSendMessage.tsx +32 -2
- package/src/hooks/useUnreadMessagesCounter.ts +11 -0
- package/src/i18n/strings.ts +121 -1
- package/src/networking/api-requests/user.api.ts +71 -0
- package/src/networking/xmpp/flushLastViewedToPrivateStore.ts +17 -3
- package/src/networking/xmppClient.ts +5 -1
- package/src/roomStore/chatSettingsSlice.ts +3 -1
- package/src/roomStore/roomsSlice.ts +1 -1
- package/src/types/types.ts +16 -5
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
/** @format */
|
|
2
2
|
|
|
3
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import {
|
|
5
|
+
ActivityIndicator,
|
|
5
6
|
Animated,
|
|
6
7
|
Easing,
|
|
8
|
+
Image,
|
|
7
9
|
Modal,
|
|
10
|
+
PanResponder,
|
|
8
11
|
Platform,
|
|
12
|
+
ScrollView,
|
|
9
13
|
StyleSheet,
|
|
10
14
|
Text,
|
|
11
15
|
TouchableOpacity,
|
|
12
16
|
View,
|
|
13
17
|
} from 'react-native';
|
|
14
|
-
import { CameraIcon, DocumentIcon
|
|
18
|
+
import { CameraIcon, DocumentIcon } from '../../../assets/icons';
|
|
15
19
|
import { useChatSettingState } from '../../../hooks/useChatSettingState';
|
|
16
20
|
import { chatTextStyle } from '../../../helpers/typography';
|
|
21
|
+
import { getMediaLibrary } from '../../../helpers/mediaLibraryRuntime';
|
|
22
|
+
import {
|
|
23
|
+
shouldClaimVerticalDrag,
|
|
24
|
+
shouldDismissOnDrag,
|
|
25
|
+
} from '../../../helpers/sheetGestures';
|
|
26
|
+
|
|
27
|
+
interface RecentItem {
|
|
28
|
+
id: string;
|
|
29
|
+
uri: string;
|
|
30
|
+
filename: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface PickedMedia {
|
|
34
|
+
uri: string;
|
|
35
|
+
name: string;
|
|
36
|
+
mimeType?: string;
|
|
37
|
+
isVideo: boolean;
|
|
38
|
+
}
|
|
17
39
|
|
|
18
40
|
interface AttachSheetProps {
|
|
19
41
|
visible: boolean;
|
|
@@ -21,13 +43,54 @@ interface AttachSheetProps {
|
|
|
21
43
|
onCamera: () => void;
|
|
22
44
|
onGallery: () => void;
|
|
23
45
|
onDocument: () => void;
|
|
46
|
+
onPickMedia?: (media: PickedMedia) => void;
|
|
24
47
|
primaryColor?: string;
|
|
25
48
|
}
|
|
26
49
|
|
|
27
50
|
// Starting translateY for the sheet. Larger than any realistic sheet
|
|
28
51
|
// height so it sits fully below the viewport before opening; the exact
|
|
29
52
|
// number doesn't matter visually because it animates to 0.
|
|
30
|
-
const SHEET_OFFSCREEN =
|
|
53
|
+
const SHEET_OFFSCREEN = 800;
|
|
54
|
+
// Re-exported so this sheet's own tests keep addressing them here.
|
|
55
|
+
export { shouldClaimVerticalDrag, shouldDismissOnDrag };
|
|
56
|
+
|
|
57
|
+
const RECENTS_COUNT = 12;
|
|
58
|
+
const THUMB_SIZE = 88;
|
|
59
|
+
const THUMB_DECODE = THUMB_SIZE * 2;
|
|
60
|
+
|
|
61
|
+
const EXT_MIME: Record<string, string> = {
|
|
62
|
+
jpg: 'image/jpeg',
|
|
63
|
+
jpeg: 'image/jpeg',
|
|
64
|
+
png: 'image/png',
|
|
65
|
+
gif: 'image/gif',
|
|
66
|
+
webp: 'image/webp',
|
|
67
|
+
heic: 'image/heic',
|
|
68
|
+
heif: 'image/heif',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const guessMimeType = (name: string) => {
|
|
72
|
+
const ext = name.split('.').pop()?.toLowerCase() ?? '';
|
|
73
|
+
return EXT_MIME[ext] ?? 'image/jpeg';
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const toRecentItem = async (
|
|
77
|
+
MediaLibrary: any,
|
|
78
|
+
asset: any
|
|
79
|
+
): Promise<RecentItem | null> => {
|
|
80
|
+
const filename = asset?.filename || `photo_${asset?.id ?? Date.now()}`;
|
|
81
|
+
if (asset?.uri && !asset.uri.startsWith('ph://')) {
|
|
82
|
+
return { id: asset.id, uri: asset.uri, filename };
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const info = await MediaLibrary?.getAssetInfoAsync?.(asset, {
|
|
86
|
+
shouldDownloadFromNetwork: false,
|
|
87
|
+
});
|
|
88
|
+
if (!info?.localUri) {return null;}
|
|
89
|
+
return { id: asset.id, uri: info.localUri, filename };
|
|
90
|
+
} catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
31
94
|
|
|
32
95
|
const AttachSheet: React.FC<AttachSheetProps> = ({
|
|
33
96
|
visible,
|
|
@@ -35,13 +98,13 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
|
|
|
35
98
|
onCamera,
|
|
36
99
|
onGallery,
|
|
37
100
|
onDocument,
|
|
101
|
+
onPickMedia,
|
|
38
102
|
primaryColor = '#0052CD',
|
|
39
103
|
}) => {
|
|
40
104
|
const { config } = useChatSettingState();
|
|
41
105
|
const ts = config?.typography?.attachSheet;
|
|
42
106
|
const pendingRef = useRef<(() => void) | null>(null);
|
|
43
107
|
const runPending = () => {
|
|
44
|
-
console.log('[timing] runPending', Date.now());
|
|
45
108
|
const fn = pendingRef.current;
|
|
46
109
|
pendingRef.current = null;
|
|
47
110
|
fn?.();
|
|
@@ -64,6 +127,9 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
|
|
|
64
127
|
new Animated.Value(SHEET_OFFSCREEN)
|
|
65
128
|
).current;
|
|
66
129
|
|
|
130
|
+
const onCloseRef = useRef(onClose);
|
|
131
|
+
onCloseRef.current = onClose;
|
|
132
|
+
|
|
67
133
|
useEffect(() => {
|
|
68
134
|
if (visible) {
|
|
69
135
|
setMounted(true);
|
|
@@ -119,8 +185,96 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
|
|
|
119
185
|
return undefined;
|
|
120
186
|
}, [visible]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
121
187
|
|
|
188
|
+
const makeDragResponder = (claimOnStart: boolean) =>
|
|
189
|
+
PanResponder.create({
|
|
190
|
+
onStartShouldSetPanResponder: () => claimOnStart,
|
|
191
|
+
// Capture, so a pull that starts on a row (whose Touchable grabbed
|
|
192
|
+
// the responder on touch-down) still drags the sheet.
|
|
193
|
+
onMoveShouldSetPanResponderCapture: (_evt, g) =>
|
|
194
|
+
claimOnStart || shouldClaimVerticalDrag(g.dy, g.dx),
|
|
195
|
+
onMoveShouldSetPanResponder: (_evt, g) =>
|
|
196
|
+
claimOnStart || shouldClaimVerticalDrag(g.dy, g.dx),
|
|
197
|
+
onPanResponderTerminationRequest: () => false,
|
|
198
|
+
onPanResponderMove: (_evt, g) => {
|
|
199
|
+
sheetTranslateY.setValue(Math.max(0, g.dy));
|
|
200
|
+
},
|
|
201
|
+
onPanResponderRelease: (_evt, g) => {
|
|
202
|
+
if (shouldDismissOnDrag(g.dy, g.vy)) {
|
|
203
|
+
onCloseRef.current();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
Animated.spring(sheetTranslateY, {
|
|
207
|
+
toValue: 0,
|
|
208
|
+
tension: 90,
|
|
209
|
+
friction: 14,
|
|
210
|
+
useNativeDriver: true,
|
|
211
|
+
}).start();
|
|
212
|
+
},
|
|
213
|
+
onPanResponderTerminate: () => {
|
|
214
|
+
Animated.spring(sheetTranslateY, {
|
|
215
|
+
toValue: 0,
|
|
216
|
+
tension: 90,
|
|
217
|
+
friction: 14,
|
|
218
|
+
useNativeDriver: true,
|
|
219
|
+
}).start();
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const sheetPanRef = useRef<ReturnType<typeof makeDragResponder> | null>(null);
|
|
224
|
+
const grabberPanRef = useRef<ReturnType<typeof makeDragResponder> | null>(null);
|
|
225
|
+
if (!sheetPanRef.current) {sheetPanRef.current = makeDragResponder(false);}
|
|
226
|
+
if (!grabberPanRef.current) {grabberPanRef.current = makeDragResponder(true);}
|
|
227
|
+
const sheetPan = sheetPanRef.current;
|
|
228
|
+
const grabberPan = grabberPanRef.current;
|
|
229
|
+
|
|
230
|
+
const [recents, setRecents] = useState<RecentItem[]>([]);
|
|
231
|
+
const [loadingRecents, setLoadingRecents] = useState(false);
|
|
232
|
+
const lastLoadRef = useRef(0);
|
|
233
|
+
const RECENTS_TTL_MS = 15000;
|
|
234
|
+
|
|
235
|
+
const loadRecents = useCallback(async () => {
|
|
236
|
+
const MediaLibrary = getMediaLibrary();
|
|
237
|
+
if (!MediaLibrary?.getAssetsAsync) {
|
|
238
|
+
setLoadingRecents(false);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
const perm = await MediaLibrary.getPermissionsAsync();
|
|
243
|
+
if (!perm?.granted) {
|
|
244
|
+
setRecents([]);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const page = await MediaLibrary.getAssetsAsync({
|
|
248
|
+
first: RECENTS_COUNT,
|
|
249
|
+
sortBy: [MediaLibrary.SortBy?.creationTime ?? 'creationTime'],
|
|
250
|
+
mediaType: [MediaLibrary.MediaType?.photo ?? 'photo'],
|
|
251
|
+
});
|
|
252
|
+
const items = await Promise.all(
|
|
253
|
+
(page?.assets ?? []).map((asset: any) => toRecentItem(MediaLibrary, asset))
|
|
254
|
+
);
|
|
255
|
+
lastLoadRef.current = Date.now();
|
|
256
|
+
setRecents(items.filter(Boolean) as RecentItem[]);
|
|
257
|
+
} catch (err) {
|
|
258
|
+
console.warn('AttachSheet: could not read recent media', err);
|
|
259
|
+
setRecents([]);
|
|
260
|
+
} finally {
|
|
261
|
+
setLoadingRecents(false);
|
|
262
|
+
}
|
|
263
|
+
}, []);
|
|
264
|
+
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
if (!visible) {return undefined;}
|
|
267
|
+
if (recents.length && Date.now() - lastLoadRef.current < RECENTS_TTL_MS) {
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
setLoadingRecents(true);
|
|
271
|
+
const timer = setTimeout(() => {
|
|
272
|
+
loadRecents();
|
|
273
|
+
}, 250);
|
|
274
|
+
return () => clearTimeout(timer);
|
|
275
|
+
}, [visible]);
|
|
276
|
+
|
|
122
277
|
const trigger = (handler: () => void) => () => {
|
|
123
|
-
console.log('[timing] row tap', Date.now());
|
|
124
278
|
pendingRef.current = handler;
|
|
125
279
|
if (Platform.OS === 'ios') {
|
|
126
280
|
setMounted(false);
|
|
@@ -128,27 +282,29 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
|
|
|
128
282
|
onClose();
|
|
129
283
|
};
|
|
130
284
|
|
|
285
|
+
const handleRecentPress = (item: RecentItem) =>
|
|
286
|
+
trigger(() => {
|
|
287
|
+
if (onPickMedia) {
|
|
288
|
+
onPickMedia({
|
|
289
|
+
uri: item.uri,
|
|
290
|
+
name: item.filename,
|
|
291
|
+
mimeType: guessMimeType(item.filename),
|
|
292
|
+
isVideo: false,
|
|
293
|
+
});
|
|
294
|
+
} else {
|
|
295
|
+
onGallery();
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
131
299
|
const rows: {
|
|
300
|
+
id: string;
|
|
132
301
|
label: string;
|
|
133
|
-
hint: string;
|
|
134
302
|
Icon: React.ComponentType<any>;
|
|
135
303
|
handler: () => void;
|
|
136
304
|
}[] = [
|
|
137
305
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
Icon: CameraIcon,
|
|
141
|
-
handler: onCamera,
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
label: 'Photo or video',
|
|
145
|
-
hint: 'Pick from your library',
|
|
146
|
-
Icon: MediaIcon,
|
|
147
|
-
handler: onGallery,
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
label: 'Document',
|
|
151
|
-
hint: 'Choose a file',
|
|
306
|
+
id: 'Document',
|
|
307
|
+
label: 'Upload a File',
|
|
152
308
|
Icon: DocumentIcon,
|
|
153
309
|
handler: onDocument,
|
|
154
310
|
},
|
|
@@ -181,43 +337,101 @@ const AttachSheet: React.FC<AttachSheetProps> = ({
|
|
|
181
337
|
styles.sheet,
|
|
182
338
|
{ transform: [{ translateY: sheetTranslateY }] },
|
|
183
339
|
]}
|
|
340
|
+
{...sheetPan.panHandlers}
|
|
184
341
|
>
|
|
185
|
-
<
|
|
342
|
+
<View
|
|
343
|
+
testID="attach-grabber"
|
|
344
|
+
style={styles.grabberArea}
|
|
345
|
+
{...grabberPan.panHandlers}
|
|
346
|
+
>
|
|
186
347
|
<View style={styles.grabber} />
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
348
|
+
</View>
|
|
349
|
+
|
|
350
|
+
{/* Photos & Videos ------------------------------------------------ */}
|
|
351
|
+
<View style={styles.sectionHeader}>
|
|
352
|
+
<Text style={[styles.sectionTitle, chatTextStyle(ts?.title)]}>
|
|
353
|
+
Photos & Videos
|
|
354
|
+
</Text>
|
|
355
|
+
<TouchableOpacity
|
|
356
|
+
testID="attach-view-library"
|
|
357
|
+
activeOpacity={0.6}
|
|
358
|
+
onPress={trigger(onGallery)}
|
|
359
|
+
hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}
|
|
360
|
+
>
|
|
361
|
+
<Text
|
|
193
362
|
style={[
|
|
194
|
-
styles.
|
|
195
|
-
|
|
363
|
+
styles.sectionAction,
|
|
364
|
+
{ color: primaryColor },
|
|
365
|
+
chatTextStyle(ts?.viewLibrary),
|
|
196
366
|
]}
|
|
197
|
-
onPress={trigger(handler)}
|
|
198
367
|
>
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
368
|
+
View Library
|
|
369
|
+
</Text>
|
|
370
|
+
</TouchableOpacity>
|
|
371
|
+
</View>
|
|
372
|
+
|
|
373
|
+
<ScrollView
|
|
374
|
+
horizontal
|
|
375
|
+
showsHorizontalScrollIndicator={false}
|
|
376
|
+
contentContainerStyle={styles.strip}
|
|
377
|
+
keyboardShouldPersistTaps="handled"
|
|
378
|
+
>
|
|
379
|
+
{/* Camera tile — always first, works without library access. */}
|
|
380
|
+
<TouchableOpacity
|
|
381
|
+
testID="attach-row-Camera"
|
|
382
|
+
activeOpacity={0.7}
|
|
383
|
+
style={styles.cameraTile}
|
|
384
|
+
onPress={trigger(onCamera)}
|
|
385
|
+
>
|
|
386
|
+
<CameraIcon color="#8A8A8E" width={26} height={26} />
|
|
387
|
+
</TouchableOpacity>
|
|
388
|
+
|
|
389
|
+
{loadingRecents && recents.length === 0 && (
|
|
390
|
+
<View style={styles.loadingTile}>
|
|
391
|
+
<ActivityIndicator color="#8A8A8E" />
|
|
392
|
+
</View>
|
|
393
|
+
)}
|
|
394
|
+
|
|
395
|
+
{recents.map((item) => (
|
|
396
|
+
<TouchableOpacity
|
|
397
|
+
key={item.id}
|
|
398
|
+
testID={`attach-recent-${item.id}`}
|
|
399
|
+
activeOpacity={0.8}
|
|
400
|
+
style={styles.thumbWrap}
|
|
401
|
+
onPress={handleRecentPress(item)}
|
|
402
|
+
>
|
|
403
|
+
<Image
|
|
404
|
+
source={{
|
|
405
|
+
uri: item.uri,
|
|
406
|
+
width: THUMB_DECODE,
|
|
407
|
+
height: THUMB_DECODE,
|
|
408
|
+
}}
|
|
409
|
+
style={styles.thumb}
|
|
410
|
+
resizeMethod="resize"
|
|
411
|
+
resizeMode="cover"
|
|
412
|
+
fadeDuration={0}
|
|
413
|
+
/>
|
|
211
414
|
</TouchableOpacity>
|
|
212
415
|
))}
|
|
416
|
+
</ScrollView>
|
|
417
|
+
|
|
418
|
+
<View style={styles.rowsDivider} />
|
|
419
|
+
{rows.map(({ id, label, Icon, handler }) => (
|
|
213
420
|
<TouchableOpacity
|
|
421
|
+
key={id}
|
|
422
|
+
testID={`attach-row-${id}`}
|
|
214
423
|
activeOpacity={0.6}
|
|
215
|
-
style={styles.
|
|
216
|
-
onPress={
|
|
424
|
+
style={styles.row}
|
|
425
|
+
onPress={trigger(handler)}
|
|
217
426
|
>
|
|
218
|
-
<
|
|
427
|
+
<View style={styles.rowIcon}>
|
|
428
|
+
<Icon color="#1C1C1E" width={20} height={20} />
|
|
429
|
+
</View>
|
|
430
|
+
<Text style={[styles.rowLabel, chatTextStyle(ts?.rowLabel)]}>
|
|
431
|
+
{label}
|
|
432
|
+
</Text>
|
|
219
433
|
</TouchableOpacity>
|
|
220
|
-
|
|
434
|
+
))}
|
|
221
435
|
</Animated.View>
|
|
222
436
|
</Animated.View>
|
|
223
437
|
</Modal>
|
|
@@ -234,7 +448,7 @@ const styles = StyleSheet.create({
|
|
|
234
448
|
backgroundColor: '#fff',
|
|
235
449
|
borderTopLeftRadius: 24,
|
|
236
450
|
borderTopRightRadius: 24,
|
|
237
|
-
paddingTop:
|
|
451
|
+
paddingTop: 4,
|
|
238
452
|
paddingBottom: Platform.OS === 'ios' ? 32 : 20,
|
|
239
453
|
shadowColor: '#000',
|
|
240
454
|
shadowOffset: { width: 0, height: -2 },
|
|
@@ -242,65 +456,83 @@ const styles = StyleSheet.create({
|
|
|
242
456
|
shadowRadius: 12,
|
|
243
457
|
elevation: 16,
|
|
244
458
|
},
|
|
459
|
+
grabberArea: {
|
|
460
|
+
alignItems: 'center',
|
|
461
|
+
paddingTop: 10,
|
|
462
|
+
paddingBottom: 14,
|
|
463
|
+
},
|
|
245
464
|
grabber: {
|
|
246
|
-
alignSelf: 'center',
|
|
247
465
|
width: 40,
|
|
248
466
|
height: 4,
|
|
249
467
|
borderRadius: 2,
|
|
250
468
|
backgroundColor: '#D9D9DE',
|
|
251
|
-
marginBottom: 12,
|
|
252
469
|
},
|
|
253
|
-
|
|
254
|
-
fontSize: 13,
|
|
255
|
-
fontWeight: '600',
|
|
256
|
-
color: '#8A8A8E',
|
|
257
|
-
letterSpacing: 0.4,
|
|
258
|
-
textTransform: 'uppercase',
|
|
259
|
-
paddingHorizontal: 20,
|
|
260
|
-
paddingBottom: 8,
|
|
261
|
-
},
|
|
262
|
-
row: {
|
|
470
|
+
sectionHeader: {
|
|
263
471
|
flexDirection: 'row',
|
|
264
472
|
alignItems: 'center',
|
|
473
|
+
justifyContent: 'space-between',
|
|
265
474
|
paddingHorizontal: 20,
|
|
266
|
-
|
|
475
|
+
paddingBottom: 12,
|
|
267
476
|
},
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
477
|
+
sectionTitle: {
|
|
478
|
+
fontSize: 17,
|
|
479
|
+
fontWeight: '700',
|
|
480
|
+
color: '#1C1C1E',
|
|
271
481
|
},
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
482
|
+
sectionAction: {
|
|
483
|
+
fontSize: 15,
|
|
484
|
+
fontWeight: '500',
|
|
485
|
+
},
|
|
486
|
+
strip: {
|
|
487
|
+
paddingHorizontal: 16,
|
|
488
|
+
paddingBottom: 16,
|
|
489
|
+
gap: 8,
|
|
490
|
+
},
|
|
491
|
+
cameraTile: {
|
|
492
|
+
width: THUMB_SIZE,
|
|
493
|
+
height: THUMB_SIZE,
|
|
494
|
+
borderRadius: 16,
|
|
495
|
+
borderWidth: 1,
|
|
496
|
+
borderColor: '#E4E4E9',
|
|
497
|
+
backgroundColor: '#FAFAFC',
|
|
276
498
|
alignItems: 'center',
|
|
277
499
|
justifyContent: 'center',
|
|
278
|
-
marginRight: 14,
|
|
279
500
|
},
|
|
280
|
-
|
|
281
|
-
|
|
501
|
+
loadingTile: {
|
|
502
|
+
width: THUMB_SIZE,
|
|
503
|
+
height: THUMB_SIZE,
|
|
504
|
+
alignItems: 'center',
|
|
505
|
+
justifyContent: 'center',
|
|
282
506
|
},
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
507
|
+
thumbWrap: {
|
|
508
|
+
width: THUMB_SIZE,
|
|
509
|
+
height: THUMB_SIZE,
|
|
510
|
+
borderRadius: 16,
|
|
511
|
+
overflow: 'hidden',
|
|
512
|
+
backgroundColor: '#EFEFF2',
|
|
513
|
+
},
|
|
514
|
+
thumb: {
|
|
515
|
+
width: '100%',
|
|
516
|
+
height: '100%',
|
|
287
517
|
},
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
marginTop: 2,
|
|
518
|
+
rowsDivider: {
|
|
519
|
+
height: StyleSheet.hairlineWidth,
|
|
520
|
+
backgroundColor: '#EFEFF2',
|
|
292
521
|
},
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
marginHorizontal: 16,
|
|
296
|
-
paddingVertical: 14,
|
|
297
|
-
borderRadius: 14,
|
|
522
|
+
row: {
|
|
523
|
+
flexDirection: 'row',
|
|
298
524
|
alignItems: 'center',
|
|
299
|
-
|
|
525
|
+
paddingHorizontal: 20,
|
|
526
|
+
paddingVertical: 16,
|
|
300
527
|
},
|
|
301
|
-
|
|
528
|
+
rowIcon: {
|
|
529
|
+
width: 28,
|
|
530
|
+
alignItems: 'center',
|
|
531
|
+
marginRight: 12,
|
|
532
|
+
},
|
|
533
|
+
rowLabel: {
|
|
302
534
|
fontSize: 16,
|
|
303
|
-
fontWeight: '
|
|
535
|
+
fontWeight: '500',
|
|
304
536
|
color: '#1C1C1E',
|
|
305
537
|
},
|
|
306
538
|
});
|