chat 1.0.6 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -96
- package/readme.md +1 -201
- package/lib/module/ChatContext/index.js +0 -2
- package/lib/module/ChatContext/index.js.map +0 -1
- package/lib/module/ChatContext/types.js +0 -2
- package/lib/module/ChatContext/types.js.map +0 -1
- package/lib/module/classes/Chat/index.js +0 -2
- package/lib/module/classes/Chat/index.js.map +0 -1
- package/lib/module/classes/Chat/types.js +0 -2
- package/lib/module/classes/Chat/types.js.map +0 -1
- package/lib/module/classes/Inbox/index.js +0 -2
- package/lib/module/classes/Inbox/index.js.map +0 -1
- package/lib/module/classes/Inbox/types.js +0 -2
- package/lib/module/classes/Inbox/types.js.map +0 -1
- package/lib/module/classes/Message/index.js +0 -2
- package/lib/module/classes/Message/index.js.map +0 -1
- package/lib/module/classes/Message/types.js +0 -2
- package/lib/module/classes/Message/types.js.map +0 -1
- package/lib/module/classes/Reaction/index.js +0 -2
- package/lib/module/classes/Reaction/index.js.map +0 -1
- package/lib/module/classes/Reaction/types.js +0 -2
- package/lib/module/classes/Reaction/types.js.map +0 -1
- package/lib/module/classes/Room/index.js +0 -2
- package/lib/module/classes/Room/index.js.map +0 -1
- package/lib/module/classes/Room/types.js +0 -2
- package/lib/module/classes/Room/types.js.map +0 -1
- package/lib/module/classes/index.js +0 -2
- package/lib/module/classes/index.js.map +0 -1
- package/lib/module/components/Avatar/index.js +0 -2
- package/lib/module/components/Avatar/index.js.map +0 -1
- package/lib/module/components/Chat/Bubble/index.js +0 -2
- package/lib/module/components/Chat/Bubble/index.js.map +0 -1
- package/lib/module/components/Chat/Composer/Input/index.js +0 -2
- package/lib/module/components/Chat/Composer/Input/index.js.map +0 -1
- package/lib/module/components/Chat/Composer/Send/index.js +0 -2
- package/lib/module/components/Chat/Composer/Send/index.js.map +0 -1
- package/lib/module/components/Chat/Composer/index.js +0 -2
- package/lib/module/components/Chat/Composer/index.js.map +0 -1
- package/lib/module/components/Chat/Media/Image/index.js +0 -2
- package/lib/module/components/Chat/Media/Image/index.js.map +0 -1
- package/lib/module/components/Chat/Media/index.js +0 -2
- package/lib/module/components/Chat/Media/index.js.map +0 -1
- package/lib/module/components/Chat/Message/Swiper/Action/index.js +0 -2
- package/lib/module/components/Chat/Message/Swiper/Action/index.js.map +0 -1
- package/lib/module/components/Chat/Message/Swiper/index.js +0 -2
- package/lib/module/components/Chat/Message/Swiper/index.js.map +0 -1
- package/lib/module/components/Chat/Message/Touchable/index.js +0 -2
- package/lib/module/components/Chat/Message/Touchable/index.js.map +0 -1
- package/lib/module/components/Chat/Message/index.js +0 -2
- package/lib/module/components/Chat/Message/index.js.map +0 -1
- package/lib/module/components/Chat/SystemMessage/index.js +0 -2
- package/lib/module/components/Chat/SystemMessage/index.js.map +0 -1
- package/lib/module/components/Chat/TypingFooter/index.js +0 -2
- package/lib/module/components/Chat/TypingFooter/index.js.map +0 -1
- package/lib/module/components/Chat/index.js +0 -2
- package/lib/module/components/Chat/index.js.map +0 -1
- package/lib/module/components/Chat/types.js +0 -2
- package/lib/module/components/Chat/types.js.map +0 -1
- package/lib/module/components/Chat-Old/Bubble/index.js +0 -2
- package/lib/module/components/Chat-Old/Bubble/index.js.map +0 -1
- package/lib/module/components/Chat-Old/Composer/Input/index.js +0 -2
- package/lib/module/components/Chat-Old/Composer/Input/index.js.map +0 -1
- package/lib/module/components/Chat-Old/Composer/Send/index.js +0 -2
- package/lib/module/components/Chat-Old/Composer/Send/index.js.map +0 -1
- package/lib/module/components/Chat-Old/Composer/index.js +0 -2
- package/lib/module/components/Chat-Old/Composer/index.js.map +0 -1
- package/lib/module/components/Chat-Old/Message/index.js +0 -2
- package/lib/module/components/Chat-Old/Message/index.js.map +0 -1
- package/lib/module/components/Chat-Old/Swiper/Action/index.js +0 -2
- package/lib/module/components/Chat-Old/Swiper/Action/index.js.map +0 -1
- package/lib/module/components/Chat-Old/Swiper/index.js +0 -2
- package/lib/module/components/Chat-Old/Swiper/index.js.map +0 -1
- package/lib/module/components/Chat-Old/SystemMessage/index.js +0 -2
- package/lib/module/components/Chat-Old/SystemMessage/index.js.map +0 -1
- package/lib/module/components/Chat-Old/index.js +0 -2
- package/lib/module/components/Chat-Old/index.js.map +0 -1
- package/lib/module/components/Chat-Old/types.js +0 -2
- package/lib/module/components/Chat-Old/types.js.map +0 -1
- package/lib/module/components/ChatProvider/index.js +0 -2
- package/lib/module/components/ChatProvider/index.js.map +0 -1
- package/lib/module/components/ChatProvider/types.js +0 -2
- package/lib/module/components/ChatProvider/types.js.map +0 -1
- package/lib/module/components/Inbox/Item/Circle/index.js +0 -2
- package/lib/module/components/Inbox/Item/Circle/index.js.map +0 -1
- package/lib/module/components/Inbox/Item/Circle/types.js +0 -2
- package/lib/module/components/Inbox/Item/Circle/types.js.map +0 -1
- package/lib/module/components/Inbox/Item/Initials/index.js +0 -2
- package/lib/module/components/Inbox/Item/Initials/index.js.map +0 -1
- package/lib/module/components/Inbox/Item/ItemDate/index.js +0 -2
- package/lib/module/components/Inbox/Item/ItemDate/index.js.map +0 -1
- package/lib/module/components/Inbox/Item/Separator/index.js +0 -2
- package/lib/module/components/Inbox/Item/Separator/index.js.map +0 -1
- package/lib/module/components/Inbox/Item/Subtitle/index.js +0 -2
- package/lib/module/components/Inbox/Item/Subtitle/index.js.map +0 -1
- package/lib/module/components/Inbox/Item/Swipeable/index.js +0 -2
- package/lib/module/components/Inbox/Item/Swipeable/index.js.map +0 -1
- package/lib/module/components/Inbox/Item/Title/index.js +0 -2
- package/lib/module/components/Inbox/Item/Title/index.js.map +0 -1
- package/lib/module/components/Inbox/Item/UnreadIndicator/index.js +0 -2
- package/lib/module/components/Inbox/Item/UnreadIndicator/index.js.map +0 -1
- package/lib/module/components/Inbox/Item/index.js +0 -2
- package/lib/module/components/Inbox/Item/index.js.map +0 -1
- package/lib/module/components/Inbox/index.js +0 -2
- package/lib/module/components/Inbox/index.js.map +0 -1
- package/lib/module/components/Inbox/question.md +0 -21
- package/lib/module/components/Inbox/readme.md +0 -21
- package/lib/module/components/Inbox/types.js +0 -2
- package/lib/module/components/Inbox/types.js.map +0 -1
- package/lib/module/components/RoomCreator/Content/Footer/Button/index.js +0 -2
- package/lib/module/components/RoomCreator/Content/Footer/Button/index.js.map +0 -1
- package/lib/module/components/RoomCreator/Content/Footer/Input/index.js +0 -2
- package/lib/module/components/RoomCreator/Content/Footer/Input/index.js.map +0 -1
- package/lib/module/components/RoomCreator/Content/Footer/index.js +0 -2
- package/lib/module/components/RoomCreator/Content/Footer/index.js.map +0 -1
- package/lib/module/components/RoomCreator/Content/Item/Icon/index.js +0 -2
- package/lib/module/components/RoomCreator/Content/Item/Icon/index.js.map +0 -1
- package/lib/module/components/RoomCreator/Content/Item/index.js +0 -2
- package/lib/module/components/RoomCreator/Content/Item/index.js.map +0 -1
- package/lib/module/components/RoomCreator/Content/index.js +0 -2
- package/lib/module/components/RoomCreator/Content/index.js.map +0 -1
- package/lib/module/components/RoomCreator/Header/index.js +0 -2
- package/lib/module/components/RoomCreator/Header/index.js.map +0 -1
- package/lib/module/components/RoomCreator/index.js +0 -2
- package/lib/module/components/RoomCreator/index.js.map +0 -1
- package/lib/module/components/RoomCreator/types.js +0 -2
- package/lib/module/components/RoomCreator/types.js.map +0 -1
- package/lib/module/components/TypingIndicator/index.js +0 -2
- package/lib/module/components/TypingIndicator/index.js.map +0 -1
- package/lib/module/components/index.js +0 -2
- package/lib/module/components/index.js.map +0 -1
- package/lib/module/helpers/getInitials.js +0 -2
- package/lib/module/helpers/getInitials.js.map +0 -1
- package/lib/module/helpers/sortByAvatar.js +0 -2
- package/lib/module/helpers/sortByAvatar.js.map +0 -1
- package/lib/module/hooks/index.js +0 -2
- package/lib/module/hooks/index.js.map +0 -1
- package/lib/module/hooks/useCreateRoom/index.js +0 -2
- package/lib/module/hooks/useCreateRoom/index.js.map +0 -1
- package/lib/module/hooks/useCreator/index.js +0 -2
- package/lib/module/hooks/useCreator/index.js.map +0 -1
- package/lib/module/hooks/useInbox/index.js +0 -2
- package/lib/module/hooks/useInbox/index.js.map +0 -1
- package/lib/module/hooks/useInbox/types.js +0 -2
- package/lib/module/hooks/useInbox/types.js.map +0 -1
- package/lib/module/hooks/useMessages/index.js +0 -2
- package/lib/module/hooks/useMessages/index.js.map +0 -1
- package/lib/module/hooks/useMessages/types.js +0 -2
- package/lib/module/hooks/useMessages/types.js.map +0 -1
- package/lib/module/hooks/useRoom/index.js +0 -2
- package/lib/module/hooks/useRoom/index.js.map +0 -1
- package/lib/module/hooks/useRoom/types.js +0 -2
- package/lib/module/hooks/useRoom/types.js.map +0 -1
- package/lib/module/hooks/useSend/useSendToGroup/index.js +0 -2
- package/lib/module/hooks/useSend/useSendToGroup/index.js.map +0 -1
- package/lib/module/hooks/useSend/useSendToPeople/index.js +0 -2
- package/lib/module/hooks/useSend/useSendToPeople/index.js.map +0 -1
- package/lib/module/hooks/useTyping/index.js +0 -2
- package/lib/module/hooks/useTyping/index.js.map +0 -1
- package/lib/module/hooks/useTypingOLD/index.js +0 -2
- package/lib/module/hooks/useTypingOLD/index.js.map +0 -1
- package/lib/module/hooks/useTypingOLD/types.js +0 -2
- package/lib/module/hooks/useTypingOLD/types.js.map +0 -1
- package/lib/module/hooks/useViewMessages/index.js +0 -2
- package/lib/module/hooks/useViewMessages/index.js.map +0 -1
- package/lib/module/hooks/useViewMessages/types.js +0 -2
- package/lib/module/hooks/useViewMessages/types.js.map +0 -1
- package/lib/module/hooks/useViewMessagesOld/index.js +0 -2
- package/lib/module/hooks/useViewMessagesOld/index.js.map +0 -1
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +0 -1
- package/lib/typescript/ChatContext/index.d.ts +0 -2
- package/lib/typescript/ChatContext/types.d.ts +0 -4
- package/lib/typescript/classes/Chat/index.d.ts +0 -14
- package/lib/typescript/classes/Chat/types.d.ts +0 -21
- package/lib/typescript/classes/Inbox/types.d.ts +0 -2
- package/lib/typescript/classes/Message/index.d.ts +0 -47
- package/lib/typescript/classes/Message/types.d.ts +0 -66
- package/lib/typescript/classes/Reaction/index.d.ts +0 -17
- package/lib/typescript/classes/Reaction/types.d.ts +0 -33
- package/lib/typescript/classes/Room/index.d.ts +0 -42
- package/lib/typescript/classes/Room/types.d.ts +0 -112
- package/lib/typescript/classes/index.d.ts +0 -4
- package/lib/typescript/components/Avatar/index.d.ts +0 -4
- package/lib/typescript/components/Chat/Bubble/index.d.ts +0 -4
- package/lib/typescript/components/Chat/Composer/Input/index.d.ts +0 -7
- package/lib/typescript/components/Chat/Composer/Send/index.d.ts +0 -4
- package/lib/typescript/components/Chat/Composer/index.d.ts +0 -8
- package/lib/typescript/components/Chat/Media/Image/index.d.ts +0 -7
- package/lib/typescript/components/Chat/Media/index.d.ts +0 -4
- package/lib/typescript/components/Chat/Message/Touchable/index.d.ts +0 -4
- package/lib/typescript/components/Chat/Message/index.d.ts +0 -8
- package/lib/typescript/components/Chat/SystemMessage/index.d.ts +0 -4
- package/lib/typescript/components/Chat/TypingFooter/index.d.ts +0 -4
- package/lib/typescript/components/Chat/index.d.ts +0 -8
- package/lib/typescript/components/Chat/types.d.ts +0 -844
- package/lib/typescript/components/ChatProvider/index.d.ts +0 -10
- package/lib/typescript/components/ChatProvider/types.d.ts +0 -7
- package/lib/typescript/components/Inbox/Item/Initials/index.d.ts +0 -4
- package/lib/typescript/components/Inbox/Item/ItemDate/index.d.ts +0 -4
- package/lib/typescript/components/Inbox/Item/Separator/index.d.ts +0 -6
- package/lib/typescript/components/Inbox/Item/Subtitle/index.d.ts +0 -3
- package/lib/typescript/components/Inbox/Item/Swipeable/index.d.ts +0 -4
- package/lib/typescript/components/Inbox/Item/Title/index.d.ts +0 -3
- package/lib/typescript/components/Inbox/Item/UnreadIndicator/index.d.ts +0 -4
- package/lib/typescript/components/Inbox/Item/index.d.ts +0 -6
- package/lib/typescript/components/Inbox/index.d.ts +0 -4
- package/lib/typescript/components/Inbox/types.d.ts +0 -304
- package/lib/typescript/components/RoomCreator/Content/Footer/Button/index.d.ts +0 -4
- package/lib/typescript/components/RoomCreator/Content/Footer/Input/index.d.ts +0 -4
- package/lib/typescript/components/RoomCreator/Content/Footer/index.d.ts +0 -3
- package/lib/typescript/components/RoomCreator/Content/Item/Icon/index.d.ts +0 -4
- package/lib/typescript/components/RoomCreator/Content/Item/index.d.ts +0 -4
- package/lib/typescript/components/RoomCreator/Content/index.d.ts +0 -4
- package/lib/typescript/components/RoomCreator/Header/index.d.ts +0 -4
- package/lib/typescript/components/RoomCreator/index.d.ts +0 -4
- package/lib/typescript/components/RoomCreator/types.d.ts +0 -208
- package/lib/typescript/components/TypingIndicator/index.d.ts +0 -9
- package/lib/typescript/components/index.d.ts +0 -12
- package/lib/typescript/helpers/getInitials.d.ts +0 -1
- package/lib/typescript/hooks/index.d.ts +0 -8
- package/lib/typescript/hooks/useCreator/index.d.ts +0 -27
- package/lib/typescript/hooks/useInbox/index.d.ts +0 -29
- package/lib/typescript/hooks/useInbox/types.d.ts +0 -5
- package/lib/typescript/hooks/useMessages/index.d.ts +0 -24
- package/lib/typescript/hooks/useMessages/types.d.ts +0 -5
- package/lib/typescript/hooks/useRoom/index.d.ts +0 -26
- package/lib/typescript/hooks/useRoom/types.d.ts +0 -5
- package/lib/typescript/hooks/useSend/useSendToGroup/index.d.ts +0 -6
- package/lib/typescript/hooks/useSend/useSendToPeople/index.d.ts +0 -6
- package/lib/typescript/hooks/useTyping/index.d.ts +0 -36
- package/lib/typescript/hooks/useViewMessages/index.d.ts +0 -18
- package/lib/typescript/hooks/useViewMessages/types.d.ts +0 -20
- package/lib/typescript/index.d.ts +0 -11
- package/src/ChatContext/index.tsx +0 -9
- package/src/ChatContext/types.ts +0 -4
- package/src/classes/Chat/index.ts +0 -46
- package/src/classes/Chat/types.ts +0 -23
- package/src/classes/Inbox/index.ts +0 -12
- package/src/classes/Inbox/types.ts +0 -3
- package/src/classes/Message/index.ts +0 -310
- package/src/classes/Message/types.ts +0 -118
- package/src/classes/Reaction/index.ts +0 -108
- package/src/classes/Reaction/types.ts +0 -37
- package/src/classes/Room/index.ts +0 -323
- package/src/classes/Room/types.ts +0 -161
- package/src/classes/index.ts +0 -4
- package/src/components/Avatar/index.tsx +0 -25
- package/src/components/Chat/Bubble/index.tsx +0 -139
- package/src/components/Chat/Composer/Input/index.tsx +0 -45
- package/src/components/Chat/Composer/Send/index.tsx +0 -51
- package/src/components/Chat/Composer/index.tsx +0 -184
- package/src/components/Chat/Media/Image/index.tsx +0 -26
- package/src/components/Chat/Media/index.tsx +0 -11
- package/src/components/Chat/Message/Swiper/Action/index.tsx +0 -7
- package/src/components/Chat/Message/Swiper/index.tsx +0 -32
- package/src/components/Chat/Message/Touchable/index.tsx +0 -60
- package/src/components/Chat/Message/index.tsx +0 -328
- package/src/components/Chat/SystemMessage/index.tsx +0 -44
- package/src/components/Chat/TypingFooter/index.tsx +0 -48
- package/src/components/Chat/index.tsx +0 -592
- package/src/components/Chat/types.ts +0 -911
- package/src/components/Chat-Old/Bubble/index.tsx +0 -58
- package/src/components/Chat-Old/Composer/Input/index.tsx +0 -34
- package/src/components/Chat-Old/Composer/Send/index.tsx +0 -37
- package/src/components/Chat-Old/Composer/index.tsx +0 -131
- package/src/components/Chat-Old/Message/index.tsx +0 -160
- package/src/components/Chat-Old/Swiper/Action/index.tsx +0 -7
- package/src/components/Chat-Old/Swiper/index.tsx +0 -30
- package/src/components/Chat-Old/SystemMessage/index.tsx +0 -44
- package/src/components/Chat-Old/index.tsx +0 -356
- package/src/components/Chat-Old/types.ts +0 -752
- package/src/components/ChatProvider/index.tsx +0 -31
- package/src/components/ChatProvider/types.ts +0 -8
- package/src/components/Inbox/Item/Circle/index.tsx +0 -47
- package/src/components/Inbox/Item/Circle/types.ts +0 -8
- package/src/components/Inbox/Item/Initials/index.tsx +0 -41
- package/src/components/Inbox/Item/ItemDate/index.tsx +0 -26
- package/src/components/Inbox/Item/Separator/index.tsx +0 -13
- package/src/components/Inbox/Item/Subtitle/index.tsx +0 -23
- package/src/components/Inbox/Item/Swipeable/index.tsx +0 -143
- package/src/components/Inbox/Item/Title/index.tsx +0 -23
- package/src/components/Inbox/Item/UnreadIndicator/index.tsx +0 -84
- package/src/components/Inbox/Item/index.tsx +0 -307
- package/src/components/Inbox/index.tsx +0 -315
- package/src/components/Inbox/question.md +0 -21
- package/src/components/Inbox/readme.md +0 -21
- package/src/components/Inbox/types.ts +0 -371
- package/src/components/RoomCreator/Content/Footer/Button/index.tsx +0 -55
- package/src/components/RoomCreator/Content/Footer/Input/index.tsx +0 -27
- package/src/components/RoomCreator/Content/Footer/index.tsx +0 -72
- package/src/components/RoomCreator/Content/Item/Icon/index.tsx +0 -16
- package/src/components/RoomCreator/Content/Item/index.tsx +0 -87
- package/src/components/RoomCreator/Content/index.tsx +0 -75
- package/src/components/RoomCreator/Header/index.tsx +0 -74
- package/src/components/RoomCreator/index.tsx +0 -177
- package/src/components/RoomCreator/types.ts +0 -233
- package/src/components/TypingIndicator/index.tsx +0 -169
- package/src/components/index.ts +0 -18
- package/src/helpers/getInitials.ts +0 -11
- package/src/helpers/sortByAvatar.ts +0 -1
- package/src/hooks/index.ts +0 -8
- package/src/hooks/useCreateRoom/index.ts +0 -34
- package/src/hooks/useCreator/index.ts +0 -33
- package/src/hooks/useInbox/index.ts +0 -76
- package/src/hooks/useInbox/types.ts +0 -6
- package/src/hooks/useMessages/index.ts +0 -109
- package/src/hooks/useMessages/types.ts +0 -6
- package/src/hooks/useRoom/index.ts +0 -82
- package/src/hooks/useRoom/types.ts +0 -6
- package/src/hooks/useSend/useSendToGroup/index.ts +0 -38
- package/src/hooks/useSend/useSendToPeople/index.ts +0 -38
- package/src/hooks/useTyping/index.ts +0 -154
- package/src/hooks/useTypingOLD/index.ts +0 -67
- package/src/hooks/useTypingOLD/types.ts +0 -7
- package/src/hooks/useViewMessages/index.ts +0 -61
- package/src/hooks/useViewMessages/types.ts +0 -22
- package/src/hooks/useViewMessagesOld/index.ts +0 -39
- package/src/index.ts +0 -13
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useCallback, FunctionComponent } from 'react'
|
|
2
|
-
|
|
3
|
-
import { TouchableProps } from '../../types'
|
|
4
|
-
import {
|
|
5
|
-
LongPressGestureHandler,
|
|
6
|
-
State,
|
|
7
|
-
TapGestureHandler
|
|
8
|
-
} from 'react-native-gesture-handler'
|
|
9
|
-
|
|
10
|
-
const Touchable: FunctionComponent<TouchableProps> = props => {
|
|
11
|
-
const doubleTapRef = useRef<TapGestureHandler>(null)
|
|
12
|
-
const { onLongPress, onPress, onDoubleTap: handleDoubleTap, id } = props
|
|
13
|
-
const onHandlerStateChange = useCallback(
|
|
14
|
-
event => {
|
|
15
|
-
if (event.nativeEvent.state === State.ACTIVE) {
|
|
16
|
-
if (onLongPress) onLongPress(id)
|
|
17
|
-
// alert("I'm being pressed for so long")
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
[onLongPress, id]
|
|
21
|
-
)
|
|
22
|
-
const onSingleTap = useCallback(
|
|
23
|
-
event => {
|
|
24
|
-
if (event.nativeEvent.state === State.ACTIVE) {
|
|
25
|
-
if (onPress) onPress(id)
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
[onPress, id]
|
|
29
|
-
)
|
|
30
|
-
const onDoubleTap = useCallback(
|
|
31
|
-
event => {
|
|
32
|
-
if (event.nativeEvent.state === State.ACTIVE) {
|
|
33
|
-
if (handleDoubleTap) handleDoubleTap(id)
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
[handleDoubleTap, id]
|
|
37
|
-
)
|
|
38
|
-
return (
|
|
39
|
-
<LongPressGestureHandler
|
|
40
|
-
onHandlerStateChange={onHandlerStateChange}
|
|
41
|
-
minDurationMs={props.longPressDelay || 500}
|
|
42
|
-
>
|
|
43
|
-
<TapGestureHandler
|
|
44
|
-
onHandlerStateChange={onSingleTap}
|
|
45
|
-
waitFor={doubleTapRef}
|
|
46
|
-
>
|
|
47
|
-
<TapGestureHandler
|
|
48
|
-
maxDelayMs={props.doubleTapDelay || 500}
|
|
49
|
-
ref={doubleTapRef}
|
|
50
|
-
onHandlerStateChange={onDoubleTap}
|
|
51
|
-
numberOfTaps={2}
|
|
52
|
-
>
|
|
53
|
-
{props.children}
|
|
54
|
-
</TapGestureHandler>
|
|
55
|
-
</TapGestureHandler>
|
|
56
|
-
</LongPressGestureHandler>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default Touchable
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useCallback,
|
|
3
|
-
useRef,
|
|
4
|
-
MutableRefObject,
|
|
5
|
-
useMemo,
|
|
6
|
-
FunctionComponent,
|
|
7
|
-
useEffect,
|
|
8
|
-
RefObject,
|
|
9
|
-
} from 'react'
|
|
10
|
-
import { View, StyleSheet, Text } from 'react-native'
|
|
11
|
-
import { MessageProps } from '../types'
|
|
12
|
-
import { NewMessageModel } from '../../../classes/Message/types'
|
|
13
|
-
// import { NewMessageModel } from '../../../classes/Message/types'
|
|
14
|
-
import Bubble from '../Bubble'
|
|
15
|
-
import { Avatar, Initials } from '../../index'
|
|
16
|
-
import { InitialsProps, AvatarProps } from '../../../components/Inbox/types'
|
|
17
|
-
// TODO update imports for these
|
|
18
|
-
import { getInitials } from '../../../helpers/getInitials'
|
|
19
|
-
import {
|
|
20
|
-
Transitioning,
|
|
21
|
-
TransitioningView,
|
|
22
|
-
Transition,
|
|
23
|
-
} from 'react-native-reanimated'
|
|
24
|
-
import Touchable from './Touchable'
|
|
25
|
-
// import { AvatarProps, InitialsProps } from '../../Inbox/types'
|
|
26
|
-
// import { getInitials } from '../../../helpers/getInitials'
|
|
27
|
-
|
|
28
|
-
const Message = <Model extends NewMessageModel = NewMessageModel>(
|
|
29
|
-
props: MessageProps<Model>
|
|
30
|
-
) => {
|
|
31
|
-
const bubble = useRef<View>()
|
|
32
|
-
const transitionRef = useRef<TransitioningView>()
|
|
33
|
-
const mounted = useRef(false)
|
|
34
|
-
|
|
35
|
-
const {
|
|
36
|
-
renderAvatar,
|
|
37
|
-
avatar,
|
|
38
|
-
avatarImageProps,
|
|
39
|
-
showAvatar,
|
|
40
|
-
name,
|
|
41
|
-
renderInitials,
|
|
42
|
-
initialsBackgroundColor,
|
|
43
|
-
initialsTextColor,
|
|
44
|
-
} = props
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (mounted.current) {
|
|
48
|
-
// console.log('message updated', props.text)
|
|
49
|
-
transitionRef.current && transitionRef.current.animateNextTransition()
|
|
50
|
-
} else {
|
|
51
|
-
mounted.current = true
|
|
52
|
-
}
|
|
53
|
-
}, [props.avatar, props.text, renderAvatar])
|
|
54
|
-
|
|
55
|
-
const { renderFooter } = props
|
|
56
|
-
|
|
57
|
-
const footer = useCallback(
|
|
58
|
-
() => (renderFooter ? renderFooter({ id: props.id }) : null),
|
|
59
|
-
[props.id, renderFooter]
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
const containerStyle = useMemo(() => {
|
|
63
|
-
return [
|
|
64
|
-
styles.container,
|
|
65
|
-
props.isMe ? meStyles.container : otherStyles.container,
|
|
66
|
-
props.messageContainerStyle,
|
|
67
|
-
]
|
|
68
|
-
}, [props.isMe, props.messageContainerStyle])
|
|
69
|
-
|
|
70
|
-
const wrapperStyle = useMemo(() => {
|
|
71
|
-
return [
|
|
72
|
-
styles.wrapper,
|
|
73
|
-
props.isMe ? meStyles.wrapper : otherStyles.wrapper,
|
|
74
|
-
props.messageWrapperStyle,
|
|
75
|
-
]
|
|
76
|
-
}, [props.isMe, props.messageWrapperStyle])
|
|
77
|
-
|
|
78
|
-
// no avatar size if it's rendered null. this var is used in different spots
|
|
79
|
-
const avatarSize = renderAvatar === null ? 0 : props.avatarSize || 35
|
|
80
|
-
|
|
81
|
-
const maybeRenderName = useCallback(() => {
|
|
82
|
-
const style = {
|
|
83
|
-
...styles.name,
|
|
84
|
-
...(props.isMe ? meStyles.name : otherStyles.name),
|
|
85
|
-
}
|
|
86
|
-
return props.showName && props.name ? (
|
|
87
|
-
<Text style={[style, props.nameStyle]}>{props.name}</Text>
|
|
88
|
-
) : null
|
|
89
|
-
}, [props.showName, props.name, props.nameStyle, props.isMe])
|
|
90
|
-
|
|
91
|
-
const renderAvatarOrInitials = useCallback(() => {
|
|
92
|
-
if (renderAvatar === null) return null
|
|
93
|
-
// we make opacity 0 instead of hiding it to maintain the same width from the side
|
|
94
|
-
const opacity = showAvatar === false ? 0 : 1
|
|
95
|
-
const size = avatarSize
|
|
96
|
-
|
|
97
|
-
if (avatar) {
|
|
98
|
-
const avatarProps: AvatarProps = {
|
|
99
|
-
avatar: avatar,
|
|
100
|
-
imageProps: avatarImageProps,
|
|
101
|
-
size,
|
|
102
|
-
ImageComponent: props.AvatarImageComponent,
|
|
103
|
-
}
|
|
104
|
-
if (renderAvatar) return renderAvatar(avatarProps)
|
|
105
|
-
return (
|
|
106
|
-
<AvatarContainer opacity={opacity} showAvatar={!!showAvatar}>
|
|
107
|
-
<Avatar {...avatarProps} />
|
|
108
|
-
</AvatarContainer>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
const initialsProps: InitialsProps = {
|
|
112
|
-
initials: getInitials(name),
|
|
113
|
-
size,
|
|
114
|
-
textColor: initialsTextColor,
|
|
115
|
-
backgroundColor: initialsBackgroundColor || props.tintColor,
|
|
116
|
-
}
|
|
117
|
-
if (renderInitials) return renderInitials(initialsProps)
|
|
118
|
-
return (
|
|
119
|
-
<AvatarContainer opacity={opacity} showAvatar={!!showAvatar}>
|
|
120
|
-
<Initials {...initialsProps} />
|
|
121
|
-
</AvatarContainer>
|
|
122
|
-
)
|
|
123
|
-
}, [
|
|
124
|
-
avatar,
|
|
125
|
-
avatarImageProps,
|
|
126
|
-
avatarSize,
|
|
127
|
-
renderAvatar,
|
|
128
|
-
showAvatar,
|
|
129
|
-
name,
|
|
130
|
-
renderInitials,
|
|
131
|
-
initialsBackgroundColor,
|
|
132
|
-
initialsTextColor,
|
|
133
|
-
props.tintColor,
|
|
134
|
-
props.AvatarImageComponent,
|
|
135
|
-
])
|
|
136
|
-
|
|
137
|
-
const {
|
|
138
|
-
bubbleBackgroundColor,
|
|
139
|
-
id,
|
|
140
|
-
userId,
|
|
141
|
-
userName,
|
|
142
|
-
createdAt,
|
|
143
|
-
text,
|
|
144
|
-
system,
|
|
145
|
-
} = props
|
|
146
|
-
const backgroundColor = useMemo(() => {
|
|
147
|
-
const fallback = props.isMe
|
|
148
|
-
? ['#7B16FF', '#7114EA']
|
|
149
|
-
: ['#f1f7f8', '#f8f8f8']
|
|
150
|
-
if (!bubbleBackgroundColor) return fallback
|
|
151
|
-
let colors: string[] = []
|
|
152
|
-
if (typeof bubbleBackgroundColor === 'string') {
|
|
153
|
-
colors = [bubbleBackgroundColor, bubbleBackgroundColor]
|
|
154
|
-
} else if (Array.isArray(bubbleBackgroundColor)) {
|
|
155
|
-
colors = bubbleBackgroundColor
|
|
156
|
-
} else if (typeof bubbleBackgroundColor === 'function') {
|
|
157
|
-
const background = bubbleBackgroundColor({
|
|
158
|
-
createdAt,
|
|
159
|
-
id,
|
|
160
|
-
user: {
|
|
161
|
-
name: userName ?? '',
|
|
162
|
-
id: userId ?? '',
|
|
163
|
-
avatar: avatar ?? '',
|
|
164
|
-
},
|
|
165
|
-
text,
|
|
166
|
-
system,
|
|
167
|
-
})
|
|
168
|
-
// const background = bubbleBackgroundColor({
|
|
169
|
-
// user: {
|
|
170
|
-
// avatar: props.avatar || '',
|
|
171
|
-
// id: props.userId || '',
|
|
172
|
-
// name: props.userName || '',
|
|
173
|
-
// },
|
|
174
|
-
// id: props.id,
|
|
175
|
-
// })
|
|
176
|
-
if (Array.isArray(background)) {
|
|
177
|
-
colors = background
|
|
178
|
-
} else if (typeof background === 'string') {
|
|
179
|
-
colors = [background, background]
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (!colors.length) {
|
|
183
|
-
console.warn(
|
|
184
|
-
`🍇 Juice.Chat issue: It looks like you tried to set the message bubble background color, but something was off, so we're using the default colors. You should be passing either a string, array, or function to the bubbleBackgroundColor, like this: bubbleBackgroundColor={{ ${
|
|
185
|
-
props.isMe ? 'me' : 'others'
|
|
186
|
-
}: 'blue' }}. Instead, you passed this: ${bubbleBackgroundColor}.`
|
|
187
|
-
)
|
|
188
|
-
return fallback
|
|
189
|
-
}
|
|
190
|
-
return colors
|
|
191
|
-
}, [
|
|
192
|
-
props.isMe,
|
|
193
|
-
bubbleBackgroundColor,
|
|
194
|
-
createdAt,
|
|
195
|
-
id,
|
|
196
|
-
userName,
|
|
197
|
-
userId,
|
|
198
|
-
avatar,
|
|
199
|
-
text,
|
|
200
|
-
system,
|
|
201
|
-
])
|
|
202
|
-
const renderBubble = () => {
|
|
203
|
-
return (
|
|
204
|
-
<Bubble
|
|
205
|
-
text={props.text}
|
|
206
|
-
isMe={props.isMe}
|
|
207
|
-
style={props.bubbleStyle}
|
|
208
|
-
textStyle={props.bubbleTextStyle}
|
|
209
|
-
bubbleRef={bubble as MutableRefObject<View>}
|
|
210
|
-
backgroundColor={backgroundColor}
|
|
211
|
-
textColor={props.bubbleTextColor}
|
|
212
|
-
mediaContentType={props.mediaContentType}
|
|
213
|
-
mediaHeight={props.mediaHeight}
|
|
214
|
-
mediaWidth={props.mediaWidth}
|
|
215
|
-
mediaUri={props.mediaUri}
|
|
216
|
-
mediaUrl={props.mediaUrl}
|
|
217
|
-
renderMedia={props.renderMedia}
|
|
218
|
-
renderText={props.renderText}
|
|
219
|
-
/>
|
|
220
|
-
)
|
|
221
|
-
}
|
|
222
|
-
const outerStyle = useMemo(
|
|
223
|
-
() => (props.createsNewBunch ? { marginTop: 10 } : {}),
|
|
224
|
-
[props.createsNewBunch]
|
|
225
|
-
)
|
|
226
|
-
return (
|
|
227
|
-
<Touchable
|
|
228
|
-
id={props.id}
|
|
229
|
-
longPressDelay={props.longPressDelay}
|
|
230
|
-
doubleTapDelay={props.doubleTapDelay}
|
|
231
|
-
onDoubleTap={props.onDoubleTap}
|
|
232
|
-
onPress={props.onPress}
|
|
233
|
-
onLongPress={props.onLongPress}
|
|
234
|
-
>
|
|
235
|
-
<Transitioning.View
|
|
236
|
-
style={outerStyle}
|
|
237
|
-
transition={transition}
|
|
238
|
-
ref={transitionRef as RefObject<TransitioningView>}
|
|
239
|
-
>
|
|
240
|
-
<View style={containerStyle}>
|
|
241
|
-
<View style={wrapperStyle}>
|
|
242
|
-
{renderAvatarOrInitials()}
|
|
243
|
-
<View style={{ flex: 1, justifyContent: 'flex-start' }}>
|
|
244
|
-
{maybeRenderName()}
|
|
245
|
-
<View style={wrapperStyle}>{renderBubble()}</View>
|
|
246
|
-
</View>
|
|
247
|
-
</View>
|
|
248
|
-
{footer()}
|
|
249
|
-
</View>
|
|
250
|
-
</Transitioning.View>
|
|
251
|
-
</Touchable>
|
|
252
|
-
)
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const transition = (
|
|
256
|
-
// <Transition.Sequence>
|
|
257
|
-
// {/* <Transition.Out type="fade" /> */}
|
|
258
|
-
<Transition.Together>
|
|
259
|
-
<Transition.Change interpolation="easeOut" />
|
|
260
|
-
<Transition.In type="fade" />
|
|
261
|
-
</Transition.Together>
|
|
262
|
-
// </Transition.Sequence>
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
const AvatarContainer: FunctionComponent<{
|
|
266
|
-
showAvatar: boolean
|
|
267
|
-
opacity: 0 | 1
|
|
268
|
-
}> = React.memo(function AvatarContainer({ children, showAvatar, opacity }) {
|
|
269
|
-
return (
|
|
270
|
-
<View
|
|
271
|
-
style={{
|
|
272
|
-
opacity,
|
|
273
|
-
transform: [{ rotate: !showAvatar ? '180deg' : '0deg' }],
|
|
274
|
-
}}
|
|
275
|
-
>
|
|
276
|
-
{children}
|
|
277
|
-
</View>
|
|
278
|
-
)
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
Message.displayName = 'Message'
|
|
282
|
-
|
|
283
|
-
export default React.memo(Message)
|
|
284
|
-
|
|
285
|
-
const styles = StyleSheet.create({
|
|
286
|
-
outer: {},
|
|
287
|
-
container: {
|
|
288
|
-
marginTop: 1,
|
|
289
|
-
alignItems: 'flex-end',
|
|
290
|
-
paddingHorizontal: 10,
|
|
291
|
-
},
|
|
292
|
-
// wrapper is concerned with which side the avatar is on relative to the bubble
|
|
293
|
-
wrapper: {
|
|
294
|
-
flex: 1,
|
|
295
|
-
alignItems: 'flex-end',
|
|
296
|
-
justifyContent: 'flex-start',
|
|
297
|
-
},
|
|
298
|
-
name: {
|
|
299
|
-
marginHorizontal: 10,
|
|
300
|
-
fontSize: 14,
|
|
301
|
-
color: 'gray',
|
|
302
|
-
paddingVertical: 5,
|
|
303
|
-
},
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
const meStyles = StyleSheet.create({
|
|
307
|
-
container: {
|
|
308
|
-
justifyContent: 'flex-end',
|
|
309
|
-
},
|
|
310
|
-
wrapper: {
|
|
311
|
-
flexDirection: 'row-reverse',
|
|
312
|
-
},
|
|
313
|
-
name: {
|
|
314
|
-
textAlign: 'right',
|
|
315
|
-
},
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
const otherStyles = StyleSheet.create({
|
|
319
|
-
container: {
|
|
320
|
-
justifyContent: 'flex-end',
|
|
321
|
-
},
|
|
322
|
-
wrapper: {
|
|
323
|
-
flexDirection: 'row',
|
|
324
|
-
},
|
|
325
|
-
name: {
|
|
326
|
-
textAlign: 'left',
|
|
327
|
-
},
|
|
328
|
-
})
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { View, Text, StyleSheet } from 'react-native'
|
|
3
|
-
import moment from 'moment'
|
|
4
|
-
import { SystemMessageProps } from '../types'
|
|
5
|
-
|
|
6
|
-
const SystemMessage = React.memo((props: SystemMessageProps) => {
|
|
7
|
-
return (
|
|
8
|
-
<View style={[styles.container, props.containerStyle]}>
|
|
9
|
-
<Text style={styles.date}>
|
|
10
|
-
{props.dateToStringFunc
|
|
11
|
-
? props.dateToStringFunc(props.createdAt)
|
|
12
|
-
: moment(props.createdAt).calendar(undefined, {
|
|
13
|
-
lastDay: '[Yesterday]',
|
|
14
|
-
sameDay: 'LT',
|
|
15
|
-
nextDay: '[Tomorrow at] LT',
|
|
16
|
-
lastWeek: 'dddd',
|
|
17
|
-
nextWeek: '[Next] dddd',
|
|
18
|
-
sameElse: 'L'
|
|
19
|
-
})}
|
|
20
|
-
</Text>
|
|
21
|
-
<Text style={styles.text}>{props.text}</Text>
|
|
22
|
-
</View>
|
|
23
|
-
)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
export default SystemMessage
|
|
27
|
-
|
|
28
|
-
const styles = StyleSheet.create({
|
|
29
|
-
container: {
|
|
30
|
-
paddingHorizontal: 10,
|
|
31
|
-
paddingVertical: 5
|
|
32
|
-
},
|
|
33
|
-
date: {
|
|
34
|
-
color: 'gray',
|
|
35
|
-
textAlign: 'center',
|
|
36
|
-
fontSize: 14
|
|
37
|
-
},
|
|
38
|
-
text: {
|
|
39
|
-
color: 'gray',
|
|
40
|
-
fontWeight: '500',
|
|
41
|
-
textAlign: 'center',
|
|
42
|
-
fontSize: 14
|
|
43
|
-
}
|
|
44
|
-
})
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
import { StyleSheet, View, Text } from 'react-native'
|
|
3
|
-
// import Juice from 'usechat'
|
|
4
|
-
import { TypingFooterProps } from '../types'
|
|
5
|
-
import TypingIndicator from '../../TypingIndicator'
|
|
6
|
-
|
|
7
|
-
export default React.memo(
|
|
8
|
-
({
|
|
9
|
-
typingText,
|
|
10
|
-
containerStyle,
|
|
11
|
-
numberOfUsersTyping,
|
|
12
|
-
...indicatorProps
|
|
13
|
-
}: TypingFooterProps) => {
|
|
14
|
-
const extension = useMemo(() => {
|
|
15
|
-
if (!numberOfUsersTyping) return ''
|
|
16
|
-
return numberOfUsersTyping > 1 ? 'are' : 'is'
|
|
17
|
-
}, [numberOfUsersTyping])
|
|
18
|
-
return (
|
|
19
|
-
<View style={[styles.container, containerStyle]}>
|
|
20
|
-
<View style={styles.wrapper}>
|
|
21
|
-
<TypingIndicator {...indicatorProps} />
|
|
22
|
-
{!!typingText && !!numberOfUsersTyping && (
|
|
23
|
-
<Text style={styles.text}>
|
|
24
|
-
{typingText} {extension} typing...
|
|
25
|
-
</Text>
|
|
26
|
-
)}
|
|
27
|
-
</View>
|
|
28
|
-
</View>
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
const styles = StyleSheet.create({
|
|
34
|
-
container: {
|
|
35
|
-
alignItems: 'flex-start',
|
|
36
|
-
padding: 10,
|
|
37
|
-
paddingBottom: 5
|
|
38
|
-
},
|
|
39
|
-
wrapper: {
|
|
40
|
-
flexDirection: 'row',
|
|
41
|
-
alignItems: 'center'
|
|
42
|
-
},
|
|
43
|
-
text: {
|
|
44
|
-
color: 'gray',
|
|
45
|
-
fontStyle: 'italic',
|
|
46
|
-
marginLeft: 10
|
|
47
|
-
}
|
|
48
|
-
})
|