@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,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CustomSystemMessage } from '../styled/StyledComponents';
|
|
3
|
+
import styled from 'styled-components/native';
|
|
4
|
+
|
|
5
|
+
interface SystemMessageProps {
|
|
6
|
+
messageText?: string;
|
|
7
|
+
colors?: { primary?: string; secondary?: string };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const CustomSystemMessageText = styled.Text<{
|
|
11
|
+
primary?: string;
|
|
12
|
+
secondary?: string;
|
|
13
|
+
}>`
|
|
14
|
+
margin: 0;
|
|
15
|
+
color: ${(props) => props.primary || '#0052cd'};
|
|
16
|
+
border-radius: 118px;
|
|
17
|
+
padding: 5px 8px;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
font-size: 12px;
|
|
22
|
+
line-height: 14px;
|
|
23
|
+
font-weight: 600;
|
|
24
|
+
background-color: ${(props) => props.secondary || '#e7edf9'};
|
|
25
|
+
height: 24px;
|
|
26
|
+
white-space: nowrap;
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const SystemMessage: React.FC<SystemMessageProps> = ({
|
|
30
|
+
messageText,
|
|
31
|
+
colors,
|
|
32
|
+
}) => {
|
|
33
|
+
return (
|
|
34
|
+
<CustomSystemMessage>
|
|
35
|
+
<CustomSystemMessageText {...colors}>
|
|
36
|
+
{messageText}
|
|
37
|
+
</CustomSystemMessageText>
|
|
38
|
+
</CustomSystemMessage>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default SystemMessage;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React, { FC, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
Text,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
TouchableWithoutFeedback,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
Dimensions,
|
|
9
|
+
View,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { AddNewIcon, ProfileIcon, SettingIcon } from '../../assets/icons';
|
|
12
|
+
import { useDispatch } from 'react-redux';
|
|
13
|
+
import { setActiveModal } from '../../roomStore/chatSettingsSlice';
|
|
14
|
+
import { MODAL_TYPES } from '../../helpers/constants/MODAL_TYPES';
|
|
15
|
+
|
|
16
|
+
const { width } = Dimensions.get('window');
|
|
17
|
+
|
|
18
|
+
interface HeaderRoomListMenuProps {
|
|
19
|
+
isDrawerOpen: boolean;
|
|
20
|
+
drawerAnimation: Animated.Value;
|
|
21
|
+
overlayAnimation: Animated.Value;
|
|
22
|
+
closeDrawer: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const HeaderRoomListMenu: FC<HeaderRoomListMenuProps> = ({
|
|
26
|
+
isDrawerOpen,
|
|
27
|
+
drawerAnimation,
|
|
28
|
+
overlayAnimation,
|
|
29
|
+
closeDrawer,
|
|
30
|
+
}) => {
|
|
31
|
+
const dispatch = useDispatch();
|
|
32
|
+
|
|
33
|
+
const drawerTranslateX = drawerAnimation.interpolate({
|
|
34
|
+
inputRange: [0, 1],
|
|
35
|
+
outputRange: [width, 0],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const menuOptions = useMemo(
|
|
39
|
+
() => [
|
|
40
|
+
{
|
|
41
|
+
label: 'New Chat',
|
|
42
|
+
icon: <AddNewIcon color="#8C8C8C" />,
|
|
43
|
+
onClick: () => {
|
|
44
|
+
dispatch(setActiveModal(MODAL_TYPES.NEW_CHAT));
|
|
45
|
+
console.log('New chat clicked');
|
|
46
|
+
},
|
|
47
|
+
styles: { color: '#141414' },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: 'Profile',
|
|
51
|
+
icon: <ProfileIcon color="#8C8C8C" />,
|
|
52
|
+
onClick: () => {
|
|
53
|
+
dispatch(setActiveModal(MODAL_TYPES.PROFILE));
|
|
54
|
+
console.log('Profile clicked');
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: 'Settings',
|
|
59
|
+
icon: <SettingIcon color="#8C8C8C" />,
|
|
60
|
+
onClick: () => {
|
|
61
|
+
dispatch(setActiveModal(MODAL_TYPES.SETTINGS));
|
|
62
|
+
console.log('Settings clicked');
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
// {
|
|
66
|
+
// label: "Logout",
|
|
67
|
+
// onClick: handleLogout,
|
|
68
|
+
// },
|
|
69
|
+
],
|
|
70
|
+
[]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<Animated.View
|
|
76
|
+
style={[
|
|
77
|
+
styles.drawer,
|
|
78
|
+
{ transform: [{ translateX: drawerTranslateX }] },
|
|
79
|
+
]}
|
|
80
|
+
>
|
|
81
|
+
{menuOptions.map((option, index) => (
|
|
82
|
+
<View key={index} style={styles.menuItemWrapper}>
|
|
83
|
+
<TouchableOpacity
|
|
84
|
+
style={styles.menuItem}
|
|
85
|
+
onPress={() => {
|
|
86
|
+
option.onClick();
|
|
87
|
+
closeDrawer();
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<View
|
|
91
|
+
style={{
|
|
92
|
+
width: 22,
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
{option.icon}
|
|
97
|
+
</View>
|
|
98
|
+
<Text style={[styles.label, option?.styles]}>{option.label}</Text>
|
|
99
|
+
</TouchableOpacity>
|
|
100
|
+
{index < menuOptions.length - 1 && <View style={styles.divider} />}
|
|
101
|
+
</View>
|
|
102
|
+
))}
|
|
103
|
+
</Animated.View>
|
|
104
|
+
{isDrawerOpen && (
|
|
105
|
+
<TouchableWithoutFeedback onPress={closeDrawer}>
|
|
106
|
+
<Animated.View
|
|
107
|
+
style={[styles.overlay, { opacity: overlayAnimation }]}
|
|
108
|
+
/>
|
|
109
|
+
</TouchableWithoutFeedback>
|
|
110
|
+
)}
|
|
111
|
+
</>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const styles = StyleSheet.create({
|
|
116
|
+
menuItemWrapper: {
|
|
117
|
+
display: 'flex',
|
|
118
|
+
flexDirection: 'column',
|
|
119
|
+
},
|
|
120
|
+
menuItem: {
|
|
121
|
+
flexDirection: 'row',
|
|
122
|
+
alignItems: 'center',
|
|
123
|
+
padding: 16,
|
|
124
|
+
},
|
|
125
|
+
label: {
|
|
126
|
+
fontSize: 16,
|
|
127
|
+
marginLeft: 10,
|
|
128
|
+
},
|
|
129
|
+
divider: {
|
|
130
|
+
height: 1,
|
|
131
|
+
width: '100%',
|
|
132
|
+
backgroundColor: '#0052cd0d',
|
|
133
|
+
},
|
|
134
|
+
drawer: {
|
|
135
|
+
position: 'absolute',
|
|
136
|
+
top: 0,
|
|
137
|
+
bottom: 0,
|
|
138
|
+
right: 0,
|
|
139
|
+
width: width * 0.7,
|
|
140
|
+
backgroundColor: '#fff',
|
|
141
|
+
padding: 20,
|
|
142
|
+
shadowColor: '#000',
|
|
143
|
+
shadowOpacity: 0.3,
|
|
144
|
+
shadowOffset: { width: -2, height: 0 },
|
|
145
|
+
shadowRadius: 5,
|
|
146
|
+
elevation: 5,
|
|
147
|
+
zIndex: 999,
|
|
148
|
+
},
|
|
149
|
+
drawerTitle: {
|
|
150
|
+
fontSize: 20,
|
|
151
|
+
fontWeight: 'bold',
|
|
152
|
+
marginBottom: 20,
|
|
153
|
+
},
|
|
154
|
+
drawerItem: {
|
|
155
|
+
fontSize: 18,
|
|
156
|
+
marginBottom: 10,
|
|
157
|
+
},
|
|
158
|
+
overlay: {
|
|
159
|
+
position: 'absolute',
|
|
160
|
+
top: 0,
|
|
161
|
+
left: 0,
|
|
162
|
+
right: 0,
|
|
163
|
+
bottom: 0,
|
|
164
|
+
flex: 1,
|
|
165
|
+
width: '100%',
|
|
166
|
+
height: '100%',
|
|
167
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
168
|
+
},
|
|
169
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FC, useMemo } from 'react';
|
|
2
|
+
import DropdownMenu from '../DropdownMenu/DropdownMenu';
|
|
3
|
+
import Button from '../styled/Button';
|
|
4
|
+
import { LeaveIcon, MoreIcon, ReportIcon } from '../../assets/icons';
|
|
5
|
+
|
|
6
|
+
interface RoomMenuProps {
|
|
7
|
+
handleLeaveClick: () => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const RoomMenu: FC<RoomMenuProps> = ({ handleLeaveClick }) => {
|
|
11
|
+
const menuOptions = useMemo(
|
|
12
|
+
() => [
|
|
13
|
+
{
|
|
14
|
+
label: 'Report',
|
|
15
|
+
icon: <ReportIcon />,
|
|
16
|
+
onClick: () => {
|
|
17
|
+
console.log('Report clicked');
|
|
18
|
+
},
|
|
19
|
+
styles: { color: 'red' },
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: 'Leave',
|
|
23
|
+
icon: <LeaveIcon />,
|
|
24
|
+
onClick: () => {
|
|
25
|
+
handleLeaveClick();
|
|
26
|
+
},
|
|
27
|
+
styles: { color: 'red' },
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
[handleLeaveClick]
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<DropdownMenu
|
|
35
|
+
position="right"
|
|
36
|
+
options={menuOptions}
|
|
37
|
+
openButton={
|
|
38
|
+
<Button
|
|
39
|
+
style={{ padding: 8, maxHeight: 40 }}
|
|
40
|
+
EndIcon={<MoreIcon />}
|
|
41
|
+
unstyled
|
|
42
|
+
/>
|
|
43
|
+
}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import styled from 'styled-components/native';
|
|
3
|
+
import { nameToColor } from '../../helpers/hashcolor';
|
|
4
|
+
|
|
5
|
+
interface AvatarProps {
|
|
6
|
+
username?: string | null;
|
|
7
|
+
firstName?: string;
|
|
8
|
+
lastName?: string;
|
|
9
|
+
style?: object;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const AvatarCircle = styled.View<{ bgColor?: string }>`
|
|
13
|
+
width: 40px;
|
|
14
|
+
height: 40px;
|
|
15
|
+
border-radius: 20px;
|
|
16
|
+
background-color: ${({ bgColor }) => bgColor};
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
shadow-color: rgba(0, 0, 0, 0.2);
|
|
20
|
+
shadow-offset: 0px 4px;
|
|
21
|
+
shadow-opacity: 0.2;
|
|
22
|
+
shadow-radius: 4px;
|
|
23
|
+
elevation: 4;
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const AvatarText = styled.Text`
|
|
27
|
+
font-size: 16px;
|
|
28
|
+
font-weight: bold;
|
|
29
|
+
// Pastel backgrounds from nameToColor() are all light (#E2F4FB,
|
|
30
|
+
// #EEE6F9, #F5F2BC, ...). White text on light = invisible — web
|
|
31
|
+
// uses default-black text on the same palette. Match it.
|
|
32
|
+
color: #141414;
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export const Avatar: React.FC<AvatarProps> = ({
|
|
36
|
+
username,
|
|
37
|
+
firstName,
|
|
38
|
+
lastName,
|
|
39
|
+
style,
|
|
40
|
+
}) => {
|
|
41
|
+
const backgroundColor = useMemo(() => {
|
|
42
|
+
if (!username && !firstName) {
|
|
43
|
+
return { backgroundColor: 'transparent' };
|
|
44
|
+
}
|
|
45
|
+
return nameToColor(username ? username : firstName || '');
|
|
46
|
+
}, [username, firstName]);
|
|
47
|
+
|
|
48
|
+
const getInitials = () => {
|
|
49
|
+
const isAlphabetic = (char: string) => /^[a-zA-Zа-яА-ЯёЁ]$/.test(char);
|
|
50
|
+
|
|
51
|
+
if (firstName && lastName) {
|
|
52
|
+
const firstInitial = isAlphabetic(firstName[0])
|
|
53
|
+
? firstName[0].toUpperCase()
|
|
54
|
+
: '';
|
|
55
|
+
const lastInitial = isAlphabetic(lastName[0])
|
|
56
|
+
? lastName[0].toUpperCase()
|
|
57
|
+
: '';
|
|
58
|
+
return `${firstInitial}${lastInitial}`;
|
|
59
|
+
} else if (username) {
|
|
60
|
+
const names = username.split(' ');
|
|
61
|
+
if (names.length > 1) {
|
|
62
|
+
const firstInitial = isAlphabetic(names[0][0])
|
|
63
|
+
? names[0][0].toUpperCase()
|
|
64
|
+
: '';
|
|
65
|
+
const secondInitial = isAlphabetic(names[1][0])
|
|
66
|
+
? names[1][0].toUpperCase()
|
|
67
|
+
: '';
|
|
68
|
+
return `${firstInitial}${secondInitial}`;
|
|
69
|
+
} else {
|
|
70
|
+
const singleInitial = isAlphabetic(names[0][0])
|
|
71
|
+
? names[0][0].toUpperCase()
|
|
72
|
+
: '';
|
|
73
|
+
return `${singleInitial}`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return '??';
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<AvatarCircle style={style} bgColor={backgroundColor?.backgroundColor}>
|
|
81
|
+
<AvatarText>{getInitials()}</AvatarText>
|
|
82
|
+
</AvatarCircle>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { FC, useMemo } from 'react';
|
|
2
|
+
import { IReply, IUser } from '../../types/types';
|
|
3
|
+
import { Avatar } from './Avatar';
|
|
4
|
+
import { styled } from 'styled-components/native';
|
|
5
|
+
import { Platform, Text, View } from 'react-native';
|
|
6
|
+
|
|
7
|
+
interface BottomReplyContainerProps {
|
|
8
|
+
isUser: boolean;
|
|
9
|
+
reply: IReply[];
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const ReplyContainer = styled.TouchableOpacity<{ isUser: boolean }>`
|
|
14
|
+
background-color: #ffffff;
|
|
15
|
+
left: ${(props) => (!props.isUser ? '10px' : 'auto')};
|
|
16
|
+
right: ${(props) => (props.isUser ? '10px' : 'auto')};
|
|
17
|
+
padding: 4px 8px 4px 16px;
|
|
18
|
+
border-radius: 20px;
|
|
19
|
+
flex-direction: row;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: 6px;
|
|
22
|
+
margin: 8px 8px 0;
|
|
23
|
+
|
|
24
|
+
${Platform.select({
|
|
25
|
+
ios: `
|
|
26
|
+
shadow-color: rgba(185, 198, 199, 1);
|
|
27
|
+
shadow-offset: 0px 0px;
|
|
28
|
+
shadow-opacity: 1;
|
|
29
|
+
shadow-radius: 8px;
|
|
30
|
+
`,
|
|
31
|
+
android: `
|
|
32
|
+
elevation: 8;
|
|
33
|
+
`,
|
|
34
|
+
})}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const AvatarCircle = styled.View`
|
|
38
|
+
height: 24px;
|
|
39
|
+
width: 24px;
|
|
40
|
+
margin-left: -10px;
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
const CircleCurrent = styled.View`
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: 100%;
|
|
46
|
+
display: flex;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
align-items: center;
|
|
49
|
+
border: 1px solid #f0f0f0;
|
|
50
|
+
border-radius: 50%;
|
|
51
|
+
background-color: #ffffff;
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
const CircleCurrentText = styled.Text`
|
|
55
|
+
color: #8c8c8c;
|
|
56
|
+
font-size: 10px;
|
|
57
|
+
font-weight: 100;
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
const CounterRepliesText = styled.Text`
|
|
61
|
+
font-size: 12px;
|
|
62
|
+
color: #0052cd;
|
|
63
|
+
font-weight: 600;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
text-overflow: ellipsis;
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
export const BottomReplyContainer: FC<BottomReplyContainerProps> = ({
|
|
69
|
+
isUser,
|
|
70
|
+
reply,
|
|
71
|
+
onClick,
|
|
72
|
+
}) => {
|
|
73
|
+
const uniqueUsers: IUser[] = useMemo(() => {
|
|
74
|
+
return Object.values(
|
|
75
|
+
reply.reduce<Record<string, IUser>>((acc, item) => {
|
|
76
|
+
if (!acc[item.user.id]) {
|
|
77
|
+
acc[item.user.id] = {
|
|
78
|
+
...item.user,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return acc;
|
|
82
|
+
}, {})
|
|
83
|
+
);
|
|
84
|
+
}, [reply]);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<ReplyContainer onPress={onClick} isUser={isUser}>
|
|
88
|
+
<View style={{ flexDirection: 'row' }}>
|
|
89
|
+
{uniqueUsers.slice(0, 3).map((item) => (
|
|
90
|
+
<AvatarCircle key={item.id}>
|
|
91
|
+
<Avatar
|
|
92
|
+
username={item.name}
|
|
93
|
+
style={{
|
|
94
|
+
height: '100%',
|
|
95
|
+
width: '100%',
|
|
96
|
+
borderWidth: 1,
|
|
97
|
+
borderColor: '#F0F0F0',
|
|
98
|
+
borderStyle: 'solid',
|
|
99
|
+
fontSize: 10,
|
|
100
|
+
}}
|
|
101
|
+
/>
|
|
102
|
+
</AvatarCircle>
|
|
103
|
+
))}
|
|
104
|
+
{uniqueUsers.length > 3 && (
|
|
105
|
+
<AvatarCircle>
|
|
106
|
+
<CircleCurrent>
|
|
107
|
+
<CircleCurrentText>+{uniqueUsers.length - 3}</CircleCurrentText>
|
|
108
|
+
</CircleCurrent>
|
|
109
|
+
</AvatarCircle>
|
|
110
|
+
)}
|
|
111
|
+
</View>
|
|
112
|
+
<CounterRepliesText>
|
|
113
|
+
{reply.length} {reply.length > 1 ? 'replies' : 'reply'}
|
|
114
|
+
</CounterRepliesText>
|
|
115
|
+
</ReplyContainer>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Text } from 'react-native';
|
|
2
|
+
import { DeleteIcon } from '../../assets/icons';
|
|
3
|
+
import { styled } from 'styled-components/native';
|
|
4
|
+
|
|
5
|
+
const ReplyContainer = styled.View`
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 5px;
|
|
9
|
+
padding-top: 5px;
|
|
10
|
+
|
|
11
|
+
@media (max-width: 399px) {
|
|
12
|
+
font-size: 14px;
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const IconContainer = styled.View`
|
|
17
|
+
padding: 5px;
|
|
18
|
+
background-color: #cccccc;
|
|
19
|
+
border-radius: 7px;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
export const DeletedMessage = () => {
|
|
26
|
+
return (
|
|
27
|
+
<ReplyContainer>
|
|
28
|
+
<IconContainer>
|
|
29
|
+
<DeleteIcon width={18} height={18} fill="#8C8C8C" />
|
|
30
|
+
</IconContainer>
|
|
31
|
+
<Text style={{ margin: 0, color: '#8C8C8C' }}>
|
|
32
|
+
This message was deleted.
|
|
33
|
+
</Text>
|
|
34
|
+
</ReplyContainer>
|
|
35
|
+
);
|
|
36
|
+
};
|