@ethora/chat-component-rn 26.4.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.
- package/LICENSE +661 -0
- package/README.md +148 -0
- package/empty-shim.js +15 -0
- package/index.js +13 -0
- package/metro.js +72 -0
- package/package.json +99 -0
- package/src/api.config.ts +34 -0
- package/src/assets/BG.png +0 -0
- package/src/assets/BG.tsx +56 -0
- package/src/assets/File.svg +4 -0
- package/src/assets/ForzaCare.png +0 -0
- package/src/assets/ForzaCare.tsx +27 -0
- package/src/assets/icons.tsx +685 -0
- package/src/assets/images.tsx +41 -0
- package/src/assets/test.xml +243 -0
- package/src/components/AuthForms/Login.tsx +295 -0
- package/src/components/AuthForms/LoginAnonym.tsx +68 -0
- package/src/components/AuthForms/Register.tsx +8 -0
- package/src/components/ContextMenu/ContextMenuComponents.tsx +87 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +244 -0
- package/src/components/ExampleComponents/CustomMessage.tsx +92 -0
- package/src/components/ExampleComponents/CustomTypingIndicatorExamples.tsx +239 -0
- package/src/components/Header/HeaderRoomList.tsx +104 -0
- package/src/components/InputComponents/AudioInput.tsx +24 -0
- package/src/components/InputComponents/AudioRecorder.tsx +100 -0
- package/src/components/InputComponents/MediaInput.tsx +114 -0
- package/src/components/InputComponents/RecordingIndicator.tsx +77 -0
- package/src/components/InputComponents/Search.tsx +135 -0
- package/src/components/InputComponents/TextInput.tsx +66 -0
- package/src/components/MainComponents/ChatHeader.tsx +163 -0
- package/src/components/MainComponents/ChatRoom.tsx +392 -0
- package/src/components/MainComponents/ChatWrapper.tsx +318 -0
- package/src/components/MainComponents/ChooseChatMessage.tsx +44 -0
- package/src/components/MainComponents/ConnectionBanner.tsx +33 -0
- package/src/components/MainComponents/EditWrapper.tsx +72 -0
- package/src/components/MainComponents/LoginWrapper.tsx +134 -0
- package/src/components/MainComponents/MediaMessage.tsx +55 -0
- package/src/components/MainComponents/MessageContainer.tsx +122 -0
- package/src/components/MainComponents/MessageList.tsx +429 -0
- package/src/components/MainComponents/NoMessagesPlaceholder.tsx +49 -0
- package/src/components/MainComponents/ProfileImagePlaceholder.tsx +143 -0
- package/src/components/MainComponents/RNStyled.tsx +34 -0
- package/src/components/MainComponents/ReduxWrapper.tsx +40 -0
- package/src/components/MainComponents/RoomList.tsx +246 -0
- package/src/components/MainComponents/Select.tsx +165 -0
- package/src/components/MainComponents/Switch.tsx +73 -0
- package/src/components/MainComponents/SystemMessage.tsx +42 -0
- package/src/components/Menu/HeaderRoomListMenu.tsx +169 -0
- package/src/components/MenuRoom/MenuRoom.tsx +46 -0
- package/src/components/MessageBubble/Avatar.tsx +84 -0
- package/src/components/MessageBubble/BottomReplyContainer.tsx +117 -0
- package/src/components/MessageBubble/CustomDivider.tsx +10 -0
- package/src/components/MessageBubble/DeletedMessage.tsx +36 -0
- package/src/components/MessageBubble/Message.tsx +400 -0
- package/src/components/MessageBubble/MessageInteractions.tsx +247 -0
- package/src/components/MessageBubble/MessageReaction.tsx +149 -0
- package/src/components/MessageBubble/MessageReply.tsx +50 -0
- package/src/components/MessageBubble/MessageTranslations.tsx +30 -0
- package/src/components/Modals/AddMembersModal/AddMembersModal.tsx +142 -0
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +471 -0
- package/src/components/Modals/ChatProfileModal/DeleteChatModal.tsx +91 -0
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +298 -0
- package/src/components/Modals/Modal/Modal.tsx +52 -0
- package/src/components/Modals/ModalHeaderComponent.tsx +41 -0
- package/src/components/Modals/ModalSelectMedia/ModalSelectMedia.tsx +285 -0
- package/src/components/Modals/ModalWrapper/ModalWrapper.tsx +103 -0
- package/src/components/Modals/NewChatModal/ModalContent.tsx +151 -0
- package/src/components/Modals/NewChatModal/NewChatModal.tsx +391 -0
- package/src/components/Modals/NewChatModal/UpdNewChatModal.tsx +136 -0
- package/src/components/Modals/SelectUsersModal/SelectUsersModal.tsx +134 -0
- package/src/components/Modals/SettingsModals/BlockedUsers/BlockedUsersModal.tsx +63 -0
- package/src/components/Modals/SettingsModals/DocumentShares/DocumentSharesModal.tsx +115 -0
- package/src/components/Modals/SettingsModals/ManageDataModal/ManageDataModal.tsx +121 -0
- package/src/components/Modals/SettingsModals/ManageDataModal/StyledComponents.ts +0 -0
- package/src/components/Modals/SettingsModals/ProfileShares/ProfileShares.tsx +65 -0
- package/src/components/Modals/SettingsModals/Referrals/Referrals.tsx +90 -0
- package/src/components/Modals/SettingsModals/SharedStyledComponents.ts +74 -0
- package/src/components/Modals/SettingsModals/Visibility/RadioInput.tsx +59 -0
- package/src/components/Modals/SettingsModals/Visibility/StyledComponents.ts +32 -0
- package/src/components/Modals/SettingsModals/Visibility/VisibilityModal.tsx +146 -0
- package/src/components/Modals/UserProfileModal/EditUserModal.tsx +163 -0
- package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +410 -0
- package/src/components/Modals/UserSettingsModal/UserSettingsModal.tsx +85 -0
- package/src/components/Modals/styledModalComponents.tsx +181 -0
- package/src/components/OperationalModal/OperationalModal.tsx +78 -0
- package/src/components/RoomComponents/ChatRoomItem.tsx +219 -0
- package/src/components/RoomComponents/LastMessageItem.tsx +47 -0
- package/src/components/RoomComponents/styled/LastAudioMessage.tsx +62 -0
- package/src/components/RoomComponents/styled/LastMessageEmoji.tsx +26 -0
- package/src/components/RoomComponents/styled/LastMessageFile.tsx +54 -0
- package/src/components/RoomComponents/styled/LastMessagePhoto.tsx +54 -0
- package/src/components/RoomComponents/styled/LastMessageVideo.tsx +70 -0
- package/src/components/RoomComponents/styled/LastTextMessage.tsx +65 -0
- package/src/components/RoomComponents/styled/StyledRoomComponents.ts +53 -0
- package/src/components/SortDropDown/index.tsx +76 -0
- package/src/components/Thread/ThreadHeader.tsx +41 -0
- package/src/components/Thread/ThreadWrapper.tsx +270 -0
- package/src/components/Toast/Toast.tsx +128 -0
- package/src/components/Toast/index.ts +13 -0
- package/src/components/UsersList/StyledComponents.ts +30 -0
- package/src/components/UsersList/UsersList.tsx +112 -0
- package/src/components/styled/ActionButton.tsx +40 -0
- package/src/components/styled/AudioMessage.tsx +82 -0
- package/src/components/styled/Button.tsx +107 -0
- package/src/components/styled/ChatWrapperBox.tsx +9 -0
- package/src/components/styled/DateLabel.tsx +77 -0
- package/src/components/styled/Loader.tsx +65 -0
- package/src/components/styled/MediaFilePreview.tsx +42 -0
- package/src/components/styled/MediaModal.tsx +54 -0
- package/src/components/styled/MessageImage.tsx +54 -0
- package/src/components/styled/NewMessageLabel.tsx +50 -0
- package/src/components/styled/RoomListComponents/index.tsx +164 -0
- package/src/components/styled/SendInput.tsx +297 -0
- package/src/components/styled/StyledComponents.ts +320 -0
- package/src/components/styled/StyledInput.tsx +101 -0
- package/src/components/styled/StyledInputComponents/AudioComponents.tsx +1 -0
- package/src/components/styled/StyledInputComponents/Composing.tsx +97 -0
- package/src/components/styled/StyledInputComponents/CustomTypingIndicator.tsx +261 -0
- package/src/components/styled/StyledInputComponents/MediaComponents.tsx +90 -0
- package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +131 -0
- package/src/components/styled/StyledInputComponents/VideoComponents.tsx +49 -0
- package/src/components/styled/TreadLabel.tsx +50 -0
- package/src/components/styled/UnsupportedType.tsx +95 -0
- package/src/components/styled/VideoMessage.tsx +68 -0
- package/src/context/MessageNotificationContext.tsx +335 -0
- package/src/context/PushNotificationProvider.tsx +78 -0
- package/src/context/ToastContext.tsx +63 -0
- package/src/context/toastProvider.tsx +0 -0
- package/src/context/xmppProvider.tsx +364 -0
- package/src/helpers/block_scroll.ts +95 -0
- package/src/helpers/chatAutoEnterer.ts +46 -0
- package/src/helpers/checkUniqueUsers.tsx +31 -0
- package/src/helpers/constants/CHAT_TYPES.ts +6 -0
- package/src/helpers/constants/LANGUAGE_OPTIONS.ts +14 -0
- package/src/helpers/constants/LOCAL_STORAGE.ts +3 -0
- package/src/helpers/constants/MESSAGE_INTERACTIONS.ts +29 -0
- package/src/helpers/constants/MODAL_TYPES.ts +57 -0
- package/src/helpers/constants/PLATFORM_CONSTANTS.ts +3 -0
- package/src/helpers/createMainMessageForThread.ts +23 -0
- package/src/helpers/createMessageFromXml.ts +118 -0
- package/src/helpers/createRoomFromApi.tsx +27 -0
- package/src/helpers/createUserNameFromSetUser.ts +15 -0
- package/src/helpers/dateComparison.ts +12 -0
- package/src/helpers/debounce.ts +10 -0
- package/src/helpers/ensureScopedChatCache.ts +61 -0
- package/src/helpers/extractUniqueMembersFromRooms.ts +45 -0
- package/src/helpers/formatNumberWithCommas.ts +3 -0
- package/src/helpers/getBooleanFromString.ts +7 -0
- package/src/helpers/getDataFromXml.ts +80 -0
- package/src/helpers/getNumberFromString.ts +5 -0
- package/src/helpers/getRoomsWithRetry.ts +45 -0
- package/src/helpers/getTintedColor.ts +28 -0
- package/src/helpers/getUnnamedUsers.ts +39 -0
- package/src/helpers/handleCopyClick.ts +3 -0
- package/src/helpers/handleXmppError.ts +14 -0
- package/src/helpers/hashcolor.ts +34 -0
- package/src/helpers/historyPreloadScheduler.ts +264 -0
- package/src/helpers/initRoomsPresence.ts +32 -0
- package/src/helpers/initXmppRooms.tsx +71 -0
- package/src/helpers/insertMessageWithDelimiter.ts +96 -0
- package/src/helpers/isChatIdPresentInArray.ts +54 -0
- package/src/helpers/localStorageUser.ts +9 -0
- package/src/helpers/markdownParser.tsx +295 -0
- package/src/helpers/nanoToMs.ts +3 -0
- package/src/helpers/parseMessageBody.tsx +516 -0
- package/src/helpers/parseUrls.tsx +42 -0
- package/src/helpers/resolveInitBeforeLoadUser.ts +240 -0
- package/src/helpers/storeConsole.ts +26 -0
- package/src/helpers/transformTranslatations.ts +16 -0
- package/src/helpers/updateMessagesTillLast.tsx +104 -0
- package/src/helpers/updatedChatLastTimestamps.ts +29 -0
- package/src/helpers/validator.ts +20 -0
- package/src/helpers/walletUsername.ts +12 -0
- package/src/hooks/hooks.ts +6 -0
- package/src/hooks/useChatSettingState.tsx +38 -0
- package/src/hooks/useChatWrapperInit.ts +266 -0
- package/src/hooks/useComposing.tsx +59 -0
- package/src/hooks/useCustomTypingIndicator.tsx +193 -0
- package/src/hooks/useEventHandlers.tsx +81 -0
- package/src/hooks/useGetNewArchRoom.tsx +57 -0
- package/src/hooks/useHeapSender.tsx +88 -0
- package/src/hooks/useLocalStorage.tsx +53 -0
- package/src/hooks/useLogout.tsx +31 -0
- package/src/hooks/useMessageHeapState.tsx +11 -0
- package/src/hooks/useMessageLoaderQueue.tsx +90 -0
- package/src/hooks/useMessageQueue.ts +146 -0
- package/src/hooks/usePendingNotification.ts +49 -0
- package/src/hooks/usePrevious.tsx +15 -0
- package/src/hooks/usePushNotifications.ts +106 -0
- package/src/hooks/useQRCodeChatHandler.ts +58 -0
- package/src/hooks/useRoomInitialization.tsx +160 -0
- package/src/hooks/useRoomState.tsx +47 -0
- package/src/hooks/useRoomUrl.tsx +41 -0
- package/src/hooks/useSendMessage.tsx +306 -0
- package/src/hooks/useUnreadMessagesCounter.ts +55 -0
- package/src/hooks/useXmppInitialization.ts +148 -0
- package/src/main.ts +45 -0
- package/src/networking/api-requests/auth.api.ts +140 -0
- package/src/networking/api-requests/push.api.ts +55 -0
- package/src/networking/api-requests/roomMembers.api.ts +20 -0
- package/src/networking/api-requests/rooms.api.ts +142 -0
- package/src/networking/api-requests/user.api.ts +65 -0
- package/src/networking/apiClient.ts +149 -0
- package/src/networking/helpers/refreshChecker.ts +13 -0
- package/src/networking/stanzaHandlers.ts +418 -0
- package/src/networking/xmpp/actionSetTimestampToPrivateStore.xmpp.ts +37 -0
- package/src/networking/xmpp/allRoomPresences.xmpp.ts +10 -0
- package/src/networking/xmpp/createPrivateRoom.xmpp.ts +26 -0
- package/src/networking/xmpp/createRoom.xmpp.ts +35 -0
- package/src/networking/xmpp/createRoomPresence.xmpp.ts +74 -0
- package/src/networking/xmpp/createTimeoutPromise.xmpp.ts +15 -0
- package/src/networking/xmpp/deleteMessage.xmpp.ts +19 -0
- package/src/networking/xmpp/editMessage.xmpp.ts +46 -0
- package/src/networking/xmpp/getChatsPrivateStoreRequest.xmpp.ts +57 -0
- package/src/networking/xmpp/getHistory.xmpp.ts +140 -0
- package/src/networking/xmpp/getLastMessageArchive.xmpp.ts +24 -0
- package/src/networking/xmpp/getRoomInfo.xmpp.ts +15 -0
- package/src/networking/xmpp/getRoomMembers.xmpp.ts +13 -0
- package/src/networking/xmpp/getRooms.xmpp.ts +43 -0
- package/src/networking/xmpp/getRoomsPaged.xmpp.ts +59 -0
- package/src/networking/xmpp/handlePong.xmpp.ts +7 -0
- package/src/networking/xmpp/handleStanzas.xmpp.ts +55 -0
- package/src/networking/xmpp/inviteRoomRequest.xmpp.ts +25 -0
- package/src/networking/xmpp/leaveTheRoom.xmpp.ts +15 -0
- package/src/networking/xmpp/listenerManager.ts +116 -0
- package/src/networking/xmpp/presenceInRoom.xmpp.ts +57 -0
- package/src/networking/xmpp/roomConfig.xmpp.ts +71 -0
- package/src/networking/xmpp/sendMediaMessage.xmpp.ts +97 -0
- package/src/networking/xmpp/sendMessageReaction.xmpp.ts +41 -0
- package/src/networking/xmpp/sendPing.xmpp.ts +21 -0
- package/src/networking/xmpp/sendTextMessage.xmpp.ts +99 -0
- package/src/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.ts +44 -0
- package/src/networking/xmpp/sendTypingRequest.xmpp.ts +26 -0
- package/src/networking/xmpp/setChatsPrivateStoreRequest.xmpp.ts +48 -0
- package/src/networking/xmpp/setMeAsOwner.xmpp.ts +52 -0
- package/src/networking/xmpp/setRoomImage.xmpp.ts +26 -0
- package/src/networking/xmpp/setVCard.xmpp.ts +19 -0
- package/src/networking/xmpp/subscribeToRoomMessages.xmpp.ts +75 -0
- package/src/networking/xmppClient.ts +603 -0
- package/src/roomStore/Middleware/logoutMiddleware.tsx +24 -0
- package/src/roomStore/Middleware/newMessageMidlleware.tsx +87 -0
- package/src/roomStore/Middleware/reactionsMiddleware.tsx +77 -0
- package/src/roomStore/Middleware/testMiddleware.tsx +20 -0
- package/src/roomStore/Middleware/unreadMidlleware.tsx +58 -0
- package/src/roomStore/chatSettingsSlice.ts +178 -0
- package/src/roomStore/index.ts +68 -0
- package/src/roomStore/persistence.ts +152 -0
- package/src/roomStore/roomHeapSlice.ts +37 -0
- package/src/roomStore/roomsSlice.ts +353 -0
- package/src/services/pushNotifications.ts +170 -0
- package/src/services/pushSubscriptionService.ts +145 -0
- package/src/types/messages.ts +61 -0
- package/src/types/models/action.model.ts +30 -0
- package/src/types/models/config.model.ts +16 -0
- package/src/types/models/customComponents.model.ts +53 -0
- package/src/types/models/language.model.ts +11 -0
- package/src/types/models/media.model.ts +5 -0
- package/src/types/models/message.model.ts +69 -0
- package/src/types/models/modal.model.ts +9 -0
- package/src/types/models/room.model.ts +120 -0
- package/src/types/models/user.model.ts +90 -0
- package/src/types/models/xmpp.model.ts +155 -0
- package/src/types/types.ts +505 -0
- package/src/utils/PriorityQueue.ts +47 -0
- package/src/utils/actionHelpers.ts +40 -0
- package/src/utils/actionLogger.ts +64 -0
- package/src/utils/clientRegistry.ts +80 -0
- package/src/utils/devLogger.ts +197 -0
- package/src/utils/messageNotificationManager.ts +108 -0
- package/src/utils/resendMessage.ts +87 -0
- package/src/utils/toastEmitter.ts +27 -0
- package/src/utils/xmppMemoryMonitor.ts +63 -0
- package/src/version.ts +1 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks -- pre-existing port artifacts; hooks called conditionally / inside helpers. TODO: refactor */
|
|
2
|
+
// CustomTypingIndicator.native.tsx
|
|
3
|
+
import React, { FC, useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import styled, { css } from 'styled-components/native';
|
|
5
|
+
import {
|
|
6
|
+
Animated,
|
|
7
|
+
Easing,
|
|
8
|
+
StyleProp,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
View,
|
|
11
|
+
Text,
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
|
|
14
|
+
/* -------- Types -------- */
|
|
15
|
+
export interface CustomTypingIndicatorProps {
|
|
16
|
+
usersTyping: string[];
|
|
17
|
+
text?: string | ((usersTyping: string[]) => string);
|
|
18
|
+
position?: 'bottom' | 'top' | 'overlay' | 'floating';
|
|
19
|
+
styles?: StyleProp<ViewStyle>; // RN-эквивалент CSSProperties
|
|
20
|
+
customComponent?: React.ComponentType<{
|
|
21
|
+
usersTyping: string[];
|
|
22
|
+
text: string;
|
|
23
|
+
isVisible: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
isVisible: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* -------- Helpers (texts) -------- */
|
|
29
|
+
export const generateDefaultText = (usersTyping: string[]): string => {
|
|
30
|
+
if (usersTyping.length === 0) {return '';}
|
|
31
|
+
if (usersTyping.length === 1) {return `${usersTyping[0]} is typing`;}
|
|
32
|
+
if (usersTyping.length === 2)
|
|
33
|
+
{return `${usersTyping[0]} and ${usersTyping[1]} are typing`;}
|
|
34
|
+
return `${usersTyping.length} people are typing`;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const generateProcessingText = (usersTyping: string[]): string => {
|
|
38
|
+
if (usersTyping.length === 0) {return '';}
|
|
39
|
+
const processingStates = ['processing', 'thinking', 'generating answer'];
|
|
40
|
+
const randomState =
|
|
41
|
+
processingStates[Math.floor(Math.random() * processingStates.length)];
|
|
42
|
+
if (usersTyping.length === 1) {return `${usersTyping[0]} is ${randomState}`;}
|
|
43
|
+
if (usersTyping.length === 2)
|
|
44
|
+
{return `${usersTyping[0]} and ${usersTyping[1]} are ${randomState}`;}
|
|
45
|
+
return `${usersTyping.length} people are ${randomState}`;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/* -------- Styled (static layout) -------- */
|
|
49
|
+
|
|
50
|
+
const BaseWrapper = styled.View<{ $position: NonNullable<CustomTypingIndicatorProps['position']> }>`
|
|
51
|
+
flex-direction: row;
|
|
52
|
+
align-items: center;
|
|
53
|
+
z-index: 1000;
|
|
54
|
+
/* основная типографика */
|
|
55
|
+
/* (цвета текста задаём на текстовых нодах) */
|
|
56
|
+
|
|
57
|
+
${({ $position }) => {
|
|
58
|
+
switch ($position) {
|
|
59
|
+
case 'top':
|
|
60
|
+
return css`
|
|
61
|
+
position: absolute;
|
|
62
|
+
top: 8px;
|
|
63
|
+
left: 16px;
|
|
64
|
+
right: 16px;
|
|
65
|
+
background-color: rgba(255, 255, 255, 0.95);
|
|
66
|
+
padding: 8px 12px;
|
|
67
|
+
border-radius: 8px;
|
|
68
|
+
/* тени (iOS/Android) */
|
|
69
|
+
shadow-color: #000;
|
|
70
|
+
shadow-opacity: 0.1;
|
|
71
|
+
shadow-radius: 8px;
|
|
72
|
+
shadow-offset: 0px 2px;
|
|
73
|
+
elevation: 3;
|
|
74
|
+
`;
|
|
75
|
+
case 'overlay':
|
|
76
|
+
// В RN нет position: fixed, используем absolute + центрирование
|
|
77
|
+
return css`
|
|
78
|
+
position: absolute;
|
|
79
|
+
top: 0; left: 0; right: 0; bottom: 0;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
background-color: rgba(0, 0, 0, 0.4); /* лёгкая вуаль */
|
|
83
|
+
padding: 16px 24px;
|
|
84
|
+
`;
|
|
85
|
+
case 'floating':
|
|
86
|
+
return css`
|
|
87
|
+
position: absolute;
|
|
88
|
+
right: 20px;
|
|
89
|
+
bottom: 80px;
|
|
90
|
+
background-color: rgba(255, 255, 255, 0.95);
|
|
91
|
+
padding: 12px 16px;
|
|
92
|
+
border-radius: 20px;
|
|
93
|
+
shadow-color: #000;
|
|
94
|
+
shadow-opacity: 0.15;
|
|
95
|
+
shadow-radius: 12px;
|
|
96
|
+
shadow-offset: 0px 4px;
|
|
97
|
+
elevation: 4;
|
|
98
|
+
`;
|
|
99
|
+
case 'bottom':
|
|
100
|
+
default:
|
|
101
|
+
return css`
|
|
102
|
+
/* встроенное расположение в потоке */
|
|
103
|
+
padding: 8px 0;
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
}}
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
const Label = styled.Text`
|
|
110
|
+
margin-right: 8px;
|
|
111
|
+
font-weight: 500;
|
|
112
|
+
font-size: 14px;
|
|
113
|
+
color: #555;
|
|
114
|
+
`;
|
|
115
|
+
|
|
116
|
+
const DotsRow = styled.View`
|
|
117
|
+
flex-direction: row;
|
|
118
|
+
align-items: center;
|
|
119
|
+
`;
|
|
120
|
+
|
|
121
|
+
/* -------- Animated helpers -------- */
|
|
122
|
+
|
|
123
|
+
// pulse для wrapper'ов overlay/floating (scale + opacity)
|
|
124
|
+
const usePulse = () => {
|
|
125
|
+
const scale = useRef(new Animated.Value(1)).current;
|
|
126
|
+
const opacity = useRef(new Animated.Value(0.8)).current;
|
|
127
|
+
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
const loop = Animated.loop(
|
|
130
|
+
Animated.parallel([
|
|
131
|
+
Animated.sequence([
|
|
132
|
+
Animated.timing(scale, {
|
|
133
|
+
toValue: 1.05,
|
|
134
|
+
duration: 1000,
|
|
135
|
+
easing: Easing.inOut(Easing.ease),
|
|
136
|
+
useNativeDriver: true,
|
|
137
|
+
}),
|
|
138
|
+
Animated.timing(scale, {
|
|
139
|
+
toValue: 1,
|
|
140
|
+
duration: 1000,
|
|
141
|
+
easing: Easing.inOut(Easing.ease),
|
|
142
|
+
useNativeDriver: true,
|
|
143
|
+
}),
|
|
144
|
+
]),
|
|
145
|
+
Animated.sequence([
|
|
146
|
+
Animated.timing(opacity, {
|
|
147
|
+
toValue: 1,
|
|
148
|
+
duration: 1000,
|
|
149
|
+
easing: Easing.inOut(Easing.ease),
|
|
150
|
+
useNativeDriver: true,
|
|
151
|
+
}),
|
|
152
|
+
Animated.timing(opacity, {
|
|
153
|
+
toValue: 0.8,
|
|
154
|
+
duration: 1000,
|
|
155
|
+
easing: Easing.inOut(Easing.ease),
|
|
156
|
+
useNativeDriver: true,
|
|
157
|
+
}),
|
|
158
|
+
]),
|
|
159
|
+
])
|
|
160
|
+
);
|
|
161
|
+
loop.start();
|
|
162
|
+
return () => loop.stop();
|
|
163
|
+
}, [opacity, scale]);
|
|
164
|
+
|
|
165
|
+
return { scale, opacity };
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// мигание одной точки
|
|
169
|
+
const useBlink = (delay = 0) => {
|
|
170
|
+
const o = useRef(new Animated.Value(0.2)).current;
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
const loop = Animated.loop(
|
|
173
|
+
Animated.sequence([
|
|
174
|
+
Animated.timing(o, {
|
|
175
|
+
toValue: 1,
|
|
176
|
+
duration: 300,
|
|
177
|
+
delay,
|
|
178
|
+
useNativeDriver: true,
|
|
179
|
+
}),
|
|
180
|
+
Animated.timing(o, {
|
|
181
|
+
toValue: 0.2,
|
|
182
|
+
duration: 900,
|
|
183
|
+
useNativeDriver: true,
|
|
184
|
+
}),
|
|
185
|
+
])
|
|
186
|
+
);
|
|
187
|
+
loop.start();
|
|
188
|
+
return () => loop.stop();
|
|
189
|
+
}, [o, delay]);
|
|
190
|
+
return o;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/* Точка — как View (а не текст), чтобы выглядело одинаково на iOS/Android */
|
|
194
|
+
const DotView = styled(Animated.View)`
|
|
195
|
+
width: 6px;
|
|
196
|
+
height: 6px;
|
|
197
|
+
border-radius: 3px;
|
|
198
|
+
background-color: #666;
|
|
199
|
+
margin-right: 2px;
|
|
200
|
+
`;
|
|
201
|
+
|
|
202
|
+
/* -------- Component -------- */
|
|
203
|
+
|
|
204
|
+
const CustomTypingIndicator: FC<CustomTypingIndicatorProps> = ({
|
|
205
|
+
usersTyping = [],
|
|
206
|
+
text,
|
|
207
|
+
position = 'bottom',
|
|
208
|
+
styles,
|
|
209
|
+
customComponent: CustomComponent,
|
|
210
|
+
isVisible = true,
|
|
211
|
+
}) => {
|
|
212
|
+
if (!isVisible || usersTyping.length === 0) {return null;}
|
|
213
|
+
|
|
214
|
+
const displayText = useMemo(() => {
|
|
215
|
+
if (typeof text === 'function') {return text(usersTyping);}
|
|
216
|
+
if (typeof text === 'string') {return text;}
|
|
217
|
+
return generateDefaultText(usersTyping);
|
|
218
|
+
}, [text, usersTyping]);
|
|
219
|
+
|
|
220
|
+
// Анимации
|
|
221
|
+
const pulse = usePulse();
|
|
222
|
+
const o1 = useBlink(0);
|
|
223
|
+
const o2 = useBlink(200);
|
|
224
|
+
const o3 = useBlink(400);
|
|
225
|
+
|
|
226
|
+
if (CustomComponent) {
|
|
227
|
+
return (
|
|
228
|
+
<CustomComponent
|
|
229
|
+
usersTyping={usersTyping}
|
|
230
|
+
text={displayText}
|
|
231
|
+
isVisible={isVisible}
|
|
232
|
+
/>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Для overlay/floating оборачиваем в Animated.View, чтобы дать pulse
|
|
237
|
+
const WrapperComponent =
|
|
238
|
+
position === 'overlay' || position === 'floating'
|
|
239
|
+
? Animated.View
|
|
240
|
+
: View;
|
|
241
|
+
|
|
242
|
+
const animatedStyle =
|
|
243
|
+
position === 'overlay' || position === 'floating'
|
|
244
|
+
? { transform: [{ scale: pulse.scale }], opacity: pulse.opacity }
|
|
245
|
+
: null;
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<WrapperComponent style={animatedStyle as any}>
|
|
249
|
+
<BaseWrapper $position={position} style={styles}>
|
|
250
|
+
<Label>{displayText}</Label>
|
|
251
|
+
<DotsRow>
|
|
252
|
+
<DotView style={{ opacity: o1 }} />
|
|
253
|
+
<DotView style={{ opacity: o2 }} />
|
|
254
|
+
<DotView style={{ opacity: o3 }} />
|
|
255
|
+
</DotsRow>
|
|
256
|
+
</BaseWrapper>
|
|
257
|
+
</WrapperComponent>
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export default CustomTypingIndicator;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import styled from 'styled-components/native';
|
|
2
|
+
|
|
3
|
+
export const Container = styled.View`
|
|
4
|
+
margin: 0;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const FullScreenImage = styled.Image`
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
object-fit: contain;
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export const ModalContent = styled.View`
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
border-radius: 10px;
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const ButtonContainer = styled.View`
|
|
28
|
+
display: flex;
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 8px;
|
|
31
|
+
right: 8px;
|
|
32
|
+
gap: 4px;
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export const IconButton = styled.TouchableOpacity`
|
|
36
|
+
border: none;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
color: gray;
|
|
39
|
+
font-size: 36px;
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: 5px;
|
|
43
|
+
pointer-events: auto;
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
export const UnsupportedContainer = styled.TouchableOpacity`
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: row;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
border-radius: 8px;
|
|
52
|
+
padding: 10px;
|
|
53
|
+
margin: 5px 0;
|
|
54
|
+
cursor: pointer;
|
|
55
|
+
gap: 8px;
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
export const BackgroundFile = styled.View`
|
|
59
|
+
background-color: #f9f9f9;
|
|
60
|
+
border-radius: 8px;
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
export const FileInformation = styled.View`
|
|
64
|
+
align-items: flex-start;
|
|
65
|
+
justify-content: space-between;
|
|
66
|
+
gap: 8px;
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
export const FileName = styled.Text`
|
|
70
|
+
font-size: 14px;
|
|
71
|
+
font-weight: 500;
|
|
72
|
+
flex-grow: 1;
|
|
73
|
+
color: #fff;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
export const FileSizeContainer = styled.View`
|
|
78
|
+
align-items: flex-start;
|
|
79
|
+
flex-direction: row;
|
|
80
|
+
background-color: #f2e6f6;
|
|
81
|
+
padding: 2px 8px;
|
|
82
|
+
border-radius: 10px;
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
export const FileSize = styled.Text`
|
|
86
|
+
color: #53575a;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
text-align: left;
|
|
89
|
+
font-weight: 500;
|
|
90
|
+
`;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
3
|
+
import styled from 'styled-components/native';
|
|
4
|
+
|
|
5
|
+
// Theme variables for reuse
|
|
6
|
+
const colors = {
|
|
7
|
+
primary: '#141414',
|
|
8
|
+
secondary: '#f5f7f9',
|
|
9
|
+
border: '#ccc',
|
|
10
|
+
white: '#fff',
|
|
11
|
+
black: '#000',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const InputContainer = styled.View<{ isText?: boolean }>`
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
padding: 12px 16px;
|
|
17
|
+
background-color: ${colors.white};
|
|
18
|
+
z-index: 100;
|
|
19
|
+
width: 100%;
|
|
20
|
+
bottom: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
border-top-width: 1px;
|
|
23
|
+
border-top-color: #e5e7eb;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export const MediaContainer = styled.View`
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
gap: 8px;
|
|
29
|
+
padding: 0 16px 8px;
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
export const MediaImage = styled.Image`
|
|
33
|
+
width: 70px;
|
|
34
|
+
height: 70px;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
export const MessageInputContainer = styled.View`
|
|
39
|
+
flex-direction: row;
|
|
40
|
+
align-items: center;
|
|
41
|
+
width: 100%;
|
|
42
|
+
gap: 8px;
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export const MessageInput = styled.TextInput<{
|
|
46
|
+
isFocused?: boolean;
|
|
47
|
+
color?: string;
|
|
48
|
+
}>`
|
|
49
|
+
padding: 10px 14px;
|
|
50
|
+
border-radius: 20px;
|
|
51
|
+
border-width: 1px;
|
|
52
|
+
border-color: ${(props) =>
|
|
53
|
+
props.isFocused ? props.color || '#0052CD' : 'transparent'};
|
|
54
|
+
color: #141414;
|
|
55
|
+
background-color: #f5f7f9;
|
|
56
|
+
flex: 1;
|
|
57
|
+
text-align-vertical: center;
|
|
58
|
+
line-height: 20px;
|
|
59
|
+
include-font-padding: false;
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
export const HiddenFileInput = styled.View``;
|
|
63
|
+
|
|
64
|
+
export const Timer = styled.Text`
|
|
65
|
+
justify-content: center;
|
|
66
|
+
align-items: center;
|
|
67
|
+
margin-left: 10px;
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
export const TimerText = styled.Text`
|
|
71
|
+
font-size: 18px;
|
|
72
|
+
font-weight: bold;
|
|
73
|
+
color: ${colors.black};
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
export const WaveformContainer = styled.View`
|
|
77
|
+
width: 100%;
|
|
78
|
+
height: 40px;
|
|
79
|
+
background-color: #f1f1f1;
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
export const RecordContainer = styled.View`
|
|
83
|
+
flex-direction: row;
|
|
84
|
+
justify-content: space-between;
|
|
85
|
+
align-items: center;
|
|
86
|
+
width: 100%;
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
export const FilePreviewContainer = styled.View`
|
|
90
|
+
flex-direction: row;
|
|
91
|
+
flex-wrap: wrap;
|
|
92
|
+
gap: 10px;
|
|
93
|
+
margin-top: 10px;
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
export const FilePreview = styled.View`
|
|
97
|
+
justify-content: center;
|
|
98
|
+
align-items: center;
|
|
99
|
+
width: 100px;
|
|
100
|
+
height: 100px;
|
|
101
|
+
border-width: 1px;
|
|
102
|
+
border-color: ${colors.border};
|
|
103
|
+
border-radius: 8px;
|
|
104
|
+
background-color: #f9f9f9;
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
export const FileIcon = styled.Image`
|
|
109
|
+
max-width: 80%;
|
|
110
|
+
max-height: 80%;
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
export const VideoPreview = styled.View`
|
|
114
|
+
width: 100%;
|
|
115
|
+
height: 100%;
|
|
116
|
+
`;
|
|
117
|
+
|
|
118
|
+
export const StyledInput = styled.TextInput`
|
|
119
|
+
padding: 16px 12px;
|
|
120
|
+
background-color: ${colors.secondary};
|
|
121
|
+
font-size: 16px;
|
|
122
|
+
border-radius: 16px;
|
|
123
|
+
`;
|
|
124
|
+
|
|
125
|
+
export const TextareaInput = styled.TextInput`
|
|
126
|
+
padding: 16px 12px;
|
|
127
|
+
background-color: ${colors.secondary};
|
|
128
|
+
font-size: 16px;
|
|
129
|
+
color: ${colors.black};
|
|
130
|
+
border-radius: 16px;
|
|
131
|
+
`;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import styled from 'styled-components/native';
|
|
2
|
+
|
|
3
|
+
export const Container = styled.View`
|
|
4
|
+
margin: 0;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const FullScreenVideo = styled.video`
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
object-fit: contain;
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export const FixedSizeVideo = styled.video`
|
|
18
|
+
width: 300px;
|
|
19
|
+
height: 200px;
|
|
20
|
+
object-fit: cover;
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export const ModalContent = styled.View`
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
border-radius: 10px;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
export const ButtonContainer = styled.View`
|
|
34
|
+
display: flex;
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 8px;
|
|
37
|
+
right: 8px;
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export const IconButton = styled.TouchableOpacity`
|
|
41
|
+
border: none;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
color: gray;
|
|
44
|
+
font-size: 36px;
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
gap: 5px;
|
|
48
|
+
pointer-events: auto;
|
|
49
|
+
`;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components/native';
|
|
3
|
+
import { Line } from './StyledComponents';
|
|
4
|
+
|
|
5
|
+
interface DateLabelProps {
|
|
6
|
+
reply: number;
|
|
7
|
+
colors?: { primary?: string; secondary?: string };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Container = styled.View`
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
width: 100%;
|
|
15
|
+
background-color: transparent;
|
|
16
|
+
gap: 16px;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export const StyledDateLabel = styled.Text<{
|
|
20
|
+
primary?: string;
|
|
21
|
+
secondary?: string;
|
|
22
|
+
}>`
|
|
23
|
+
margin: 0;
|
|
24
|
+
color: ${(props) => props.primary || '#0052cd'};
|
|
25
|
+
border-radius: 118px;
|
|
26
|
+
padding: 5px 8px;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
line-height: 14px;
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
background-color: ${(props) => props.secondary || '#e7edf9'};
|
|
34
|
+
height: 24px;
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const TreadLabel: React.FC<DateLabelProps> = ({ reply, colors }) => {
|
|
39
|
+
return (
|
|
40
|
+
<Container>
|
|
41
|
+
<Line />
|
|
42
|
+
<StyledDateLabel {...colors}>
|
|
43
|
+
{reply} {reply > 1 ? 'replies' : 'reply'}
|
|
44
|
+
</StyledDateLabel>
|
|
45
|
+
<Line />
|
|
46
|
+
</Container>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default TreadLabel;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BackgroundFile,
|
|
5
|
+
FileInformation,
|
|
6
|
+
FileName,
|
|
7
|
+
FileSize,
|
|
8
|
+
FileSizeContainer,
|
|
9
|
+
UnsupportedContainer,
|
|
10
|
+
} from './StyledInputComponents/MediaComponents';
|
|
11
|
+
import { useDispatch } from 'react-redux';
|
|
12
|
+
import { MODAL_TYPES } from '../../helpers/constants/MODAL_TYPES';
|
|
13
|
+
import {
|
|
14
|
+
setActiveFile,
|
|
15
|
+
setActiveModal,
|
|
16
|
+
} from '../../roomStore/chatSettingsSlice';
|
|
17
|
+
import { Text, View } from 'react-native';
|
|
18
|
+
import { useChatSettingState } from '../../hooks/useChatSettingState';
|
|
19
|
+
import { FileIcon } from '../../assets/icons';
|
|
20
|
+
|
|
21
|
+
interface FileDownloadProps {
|
|
22
|
+
fileName: string;
|
|
23
|
+
fileURL: string;
|
|
24
|
+
mimetype: string;
|
|
25
|
+
size?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const FileDownload: React.FC<FileDownloadProps> = ({
|
|
29
|
+
fileName,
|
|
30
|
+
fileURL,
|
|
31
|
+
mimetype,
|
|
32
|
+
size,
|
|
33
|
+
}) => {
|
|
34
|
+
const dispatch = useDispatch();
|
|
35
|
+
const { config } = useChatSettingState();
|
|
36
|
+
|
|
37
|
+
const formatFileSize = (sizeInBytes: string): string => {
|
|
38
|
+
const size = parseInt(sizeInBytes, 10);
|
|
39
|
+
|
|
40
|
+
if (isNaN(size)) {
|
|
41
|
+
return 'Invalid size';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (size < 1024) {
|
|
45
|
+
return `${size} B`;
|
|
46
|
+
} else if (size < 1024 ** 2) {
|
|
47
|
+
return `${(size / 1024).toFixed(2)} KB`;
|
|
48
|
+
} else if (size < 1024 ** 3) {
|
|
49
|
+
return `${(size / 1024 ** 2).toFixed(2)} MB`;
|
|
50
|
+
} else {
|
|
51
|
+
return `${(size / 1024 ** 3).toFixed(2)} GB`;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const formatFileName = (name: string, maxLength: number): string => {
|
|
56
|
+
const dotIndex = name.lastIndexOf('.');
|
|
57
|
+
const extension = dotIndex !== -1 ? name.substring(dotIndex) : '';
|
|
58
|
+
|
|
59
|
+
const baseName = dotIndex !== -1 ? name.substring(0, dotIndex) : name;
|
|
60
|
+
|
|
61
|
+
if (baseName.length + extension.length <= maxLength) {
|
|
62
|
+
return name;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const shortenedBaseName = baseName.substring(
|
|
66
|
+
0,
|
|
67
|
+
maxLength - extension.length - 3
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return `${shortenedBaseName}...${extension}`;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const handleOpen = () => {
|
|
74
|
+
dispatch(setActiveFile({ fileName, fileURL, mimetype }));
|
|
75
|
+
dispatch(setActiveModal(MODAL_TYPES.FILE_PREVIEW));
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<UnsupportedContainer onPress={handleOpen}>
|
|
80
|
+
<BackgroundFile>
|
|
81
|
+
<FileIcon />
|
|
82
|
+
</BackgroundFile>
|
|
83
|
+
<FileInformation>
|
|
84
|
+
<FileName>{formatFileName(fileName, 20)}</FileName>
|
|
85
|
+
{size && (
|
|
86
|
+
<FileSizeContainer>
|
|
87
|
+
<FileSize>{formatFileSize(size)}</FileSize>
|
|
88
|
+
</FileSizeContainer>
|
|
89
|
+
)}
|
|
90
|
+
</FileInformation>
|
|
91
|
+
</UnsupportedContainer>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default FileDownload;
|