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,161 +0,0 @@
|
|
|
1
|
-
import { FieldValue, Timestamp } from '@firebase/firestore-types'
|
|
2
|
-
import * as firebase from 'firebase'
|
|
3
|
-
|
|
4
|
-
export interface LastMessage {
|
|
5
|
-
createdAt: Date
|
|
6
|
-
text: string
|
|
7
|
-
name: string
|
|
8
|
-
system: boolean
|
|
9
|
-
id: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface LastMessageServer extends Omit<LastMessage, 'createdAt'> {
|
|
13
|
-
createdAt: FieldValue
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Unread count schema in the members dictionary for each room
|
|
18
|
-
*/
|
|
19
|
-
export interface UnreadCount {
|
|
20
|
-
count: number
|
|
21
|
-
/**
|
|
22
|
-
* The timestamp of the last time you cleared messages.
|
|
23
|
-
*/
|
|
24
|
-
lastCleared: Date
|
|
25
|
-
/**
|
|
26
|
-
* Details of the last message you saw.
|
|
27
|
-
*/
|
|
28
|
-
lastSeen: {
|
|
29
|
-
id: string
|
|
30
|
-
createdAt: Date
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface UnreadCountDocument extends Omit<UnreadCount, 'lastCleared'> {
|
|
35
|
-
lastCleared: firebase.firestore.Timestamp
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface UnreadCountServer extends Omit<UnreadCount, 'lastCleared'> {
|
|
39
|
-
lastCleared: firebase.firestore.FieldValue
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface RoomPropertiesModel {
|
|
43
|
-
id: string
|
|
44
|
-
// avatar url for this room
|
|
45
|
-
avatar?: string
|
|
46
|
-
members?: RoomMembers
|
|
47
|
-
name?: string
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface Typing {
|
|
51
|
-
state: 'typing' | 'nothing'
|
|
52
|
-
lastChanged: typeof firebase.database.ServerValue.TIMESTAMP
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface RoomMember {
|
|
56
|
-
// typing?: boolean
|
|
57
|
-
typing?: Typing
|
|
58
|
-
exists: boolean
|
|
59
|
-
// we should probably do this one via cloud function
|
|
60
|
-
name: string
|
|
61
|
-
nickname?: string
|
|
62
|
-
avatar?: string
|
|
63
|
-
joinedAt: FieldValue
|
|
64
|
-
unreadCount?: UnreadCount
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface ExistingRoomMember {
|
|
68
|
-
// optional nickname specific to this room
|
|
69
|
-
nickname?: string
|
|
70
|
-
// url to specific image for this room
|
|
71
|
-
avatar?: string
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface NewRoomMember extends RoomMember {}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Dictionary of members in the room.
|
|
78
|
-
*/
|
|
79
|
-
export interface RoomMembers {
|
|
80
|
-
[id: string]: RoomMember
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Configuration for the room class. Members doesn't need to include me.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```
|
|
88
|
-
* const room = new Room(config: NewRoomModel)
|
|
89
|
-
* await room.create()
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export interface NewRoomModel extends Omit<RoomPropertiesModel, 'id'> {
|
|
93
|
-
members: RoomMembers
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface CreateCallableRoomModel extends Partial<RoomPropertiesModel> {
|
|
97
|
-
recipients: string[]
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface EditRoomModel extends Omit<RoomPropertiesModel, 'members'> {
|
|
101
|
-
members?: RoomMembers
|
|
102
|
-
name?: string
|
|
103
|
-
lastMessage?: LastMessage
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface ExistingRoomModel extends RoomPropertiesModel {
|
|
107
|
-
lastMessage: LastMessage
|
|
108
|
-
members: RoomMembers
|
|
109
|
-
unreadCount?: number
|
|
110
|
-
createdAt: FieldValue
|
|
111
|
-
lastEdited: FieldValue
|
|
112
|
-
currentMembers: string[]
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface CreateRoomModel
|
|
116
|
-
extends Omit<Omit<ExistingRoomModel, 'id'>, 'lastMessage'> {
|
|
117
|
-
lastMessage: LastMessageServer
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface CreateRoomCallableModel
|
|
121
|
-
extends Omit<RoomPropertiesModel, 'id'> {
|
|
122
|
-
members: RoomMembers
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
interface LastMessageDocument extends Omit<LastMessage, 'createdAt'> {
|
|
126
|
-
createdAt: Timestamp
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface ExistingRoomDocument
|
|
130
|
-
extends Omit<ExistingRoomModel, 'lastMessage'> {
|
|
131
|
-
lastMessage: LastMessageDocument
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export type RoomModel =
|
|
135
|
-
| RoomPropertiesModel
|
|
136
|
-
| NewRoomModel
|
|
137
|
-
| ExistingRoomModel
|
|
138
|
-
| CreateCallableRoomModel
|
|
139
|
-
|
|
140
|
-
// typescript type guard functions
|
|
141
|
-
// see: https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
|
|
142
|
-
|
|
143
|
-
export function currentUserExists(
|
|
144
|
-
user: firebase.User | null
|
|
145
|
-
): user is firebase.User {
|
|
146
|
-
return !!(user as firebase.User)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export function roomIsEditModel(room: RoomModel): room is EditRoomModel {
|
|
150
|
-
return !!(room as EditRoomModel)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function roomIsNewModel(room: RoomModel): room is NewRoomModel {
|
|
154
|
-
return !!(room as NewRoomModel)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function roomIsCreateCallable(
|
|
158
|
-
room: RoomModel
|
|
159
|
-
): room is CreateCallableRoomModel {
|
|
160
|
-
return !!(room as CreateCallableRoomModel)
|
|
161
|
-
}
|
package/src/classes/index.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Image, StyleSheet, View } from 'react-native'
|
|
3
|
-
import { AvatarProps } from '../Inbox/types'
|
|
4
|
-
|
|
5
|
-
export default React.memo(function(props: AvatarProps) {
|
|
6
|
-
const size = props.size
|
|
7
|
-
const borderRadius = size / 2
|
|
8
|
-
const Img = props.ImageComponent || Image
|
|
9
|
-
return (
|
|
10
|
-
<View style={[styles.container, { borderRadius }]}>
|
|
11
|
-
<Img
|
|
12
|
-
style={[{ height: size, width: size }]}
|
|
13
|
-
resizeMode="cover"
|
|
14
|
-
{...(props.imageProps || {})}
|
|
15
|
-
source={{ uri: props.avatar }}
|
|
16
|
-
/>
|
|
17
|
-
</View>
|
|
18
|
-
)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const styles = StyleSheet.create({
|
|
22
|
-
container: {
|
|
23
|
-
overflow: 'hidden'
|
|
24
|
-
}
|
|
25
|
-
})
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, FunctionComponent, useCallback } from 'react'
|
|
2
|
-
import { BubbleProps } from '../types'
|
|
3
|
-
import { View, Text, StyleSheet } from 'react-native'
|
|
4
|
-
import { LinearGradient } from 'expo-linear-gradient'
|
|
5
|
-
import { MessageMedia } from '../../../classes/Message/types'
|
|
6
|
-
import Media from '../Media'
|
|
7
|
-
|
|
8
|
-
const isValidColor = (color: string) =>
|
|
9
|
-
/(#(?:[0-9a-f]{ 2 }){ 2,4 }|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[d\.]+%?\)|\b(transparent|black|silver|gray|whitesmoke|maroon|red|purple|fuchsia|green|lime|olivedrab|yellow|navy|blue|teal|aquamarine|orange|aliceblue|antiquewhite|aqua|azure|beige|bisque|blanchedalmond|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|gainsboro|ghostwhite|goldenrod|gold|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavenderblush|lavender|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|limegreen|linen|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|oldlace|olive|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|thistle|tomato|turquoise|violet|wheat|white|yellowgreen|rebeccapurple)\b)/i.test(
|
|
10
|
-
color
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
const Bubble: FunctionComponent<BubbleProps> = props => {
|
|
14
|
-
const containerStyles = useMemo(() => {
|
|
15
|
-
return [
|
|
16
|
-
styles.container,
|
|
17
|
-
props.isMe ? meStyles.container : otherStyles.container,
|
|
18
|
-
props.style
|
|
19
|
-
]
|
|
20
|
-
}, [props.style, props.isMe])
|
|
21
|
-
|
|
22
|
-
const textStyles = useMemo(() => {
|
|
23
|
-
const color = (props.textColor && { color: props.textColor }) || {}
|
|
24
|
-
return [
|
|
25
|
-
styles.text,
|
|
26
|
-
props.isMe ? meStyles.text : otherStyles.text,
|
|
27
|
-
color,
|
|
28
|
-
props.textStyle
|
|
29
|
-
]
|
|
30
|
-
}, [props.textStyle, props.isMe, props.textColor])
|
|
31
|
-
|
|
32
|
-
const backgroundColor = useMemo(() => {
|
|
33
|
-
let color: string[] = []
|
|
34
|
-
if (Array.isArray(props.backgroundColor)) {
|
|
35
|
-
color = props.backgroundColor
|
|
36
|
-
}
|
|
37
|
-
if (typeof props.backgroundColor === 'string') {
|
|
38
|
-
color = [props.backgroundColor, props.backgroundColor]
|
|
39
|
-
}
|
|
40
|
-
const invalidColors = [
|
|
41
|
-
...Array.from(new Set(color.filter(color => !isValidColor(color))))
|
|
42
|
-
]
|
|
43
|
-
if (invalidColors.length) {
|
|
44
|
-
console.warn(
|
|
45
|
-
`🍏 Juice warning: The background color value you gave to the Bubble component doesn't seem to be valid. Each color should be a HEX color or CSS color string, matching this format: #abc123, but instead, it got these: ${invalidColors}, which don't match the format. If you gave a valid CSS color and it works, you can ignore this.`
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
return (
|
|
49
|
-
color || (props.isMe ? ['#7B16FF', '#7114EA'] : ['#f1f7f8', '#f8f8f8'])
|
|
50
|
-
)
|
|
51
|
-
}, [props.backgroundColor, props.isMe])
|
|
52
|
-
|
|
53
|
-
const { renderMedia: propsRenderMedia } = props
|
|
54
|
-
const renderMedia = useCallback(() => {
|
|
55
|
-
if (propsRenderMedia === null) return null
|
|
56
|
-
|
|
57
|
-
if (!props.mediaContentType) return null
|
|
58
|
-
|
|
59
|
-
const media: MessageMedia = {
|
|
60
|
-
url: props.mediaUrl || '',
|
|
61
|
-
uri: props.mediaUri,
|
|
62
|
-
height: props.mediaHeight || 0,
|
|
63
|
-
width: props.mediaWidth || 0,
|
|
64
|
-
contentType: props.mediaContentType
|
|
65
|
-
}
|
|
66
|
-
if (propsRenderMedia) return propsRenderMedia({ media })
|
|
67
|
-
|
|
68
|
-
return <Media {...media} />
|
|
69
|
-
}, [
|
|
70
|
-
props.mediaUrl,
|
|
71
|
-
props.mediaUri,
|
|
72
|
-
props.mediaHeight,
|
|
73
|
-
props.mediaWidth,
|
|
74
|
-
props.mediaContentType,
|
|
75
|
-
propsRenderMedia
|
|
76
|
-
])
|
|
77
|
-
|
|
78
|
-
const { text, renderText: propsRenderText } = props
|
|
79
|
-
const renderText = useCallback(() => {
|
|
80
|
-
if (text) {
|
|
81
|
-
if (propsRenderText) return propsRenderText({ style: textStyles, text })
|
|
82
|
-
return <Text style={textStyles}>{text}</Text>
|
|
83
|
-
}
|
|
84
|
-
return null
|
|
85
|
-
}, [textStyles, text, propsRenderText])
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<View style={containerStyles} ref={props.bubbleRef}>
|
|
89
|
-
<LinearGradient
|
|
90
|
-
colors={backgroundColor}
|
|
91
|
-
start={[0.1, 0.1]}
|
|
92
|
-
end={[0.9, 0.9]}
|
|
93
|
-
style={styles.gradient}
|
|
94
|
-
>
|
|
95
|
-
{renderMedia()}
|
|
96
|
-
{renderText()}
|
|
97
|
-
</LinearGradient>
|
|
98
|
-
</View>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export default React.memo(Bubble)
|
|
103
|
-
|
|
104
|
-
const styles = StyleSheet.create({
|
|
105
|
-
container: {
|
|
106
|
-
maxWidth: '80%',
|
|
107
|
-
borderRadius: 20,
|
|
108
|
-
overflow: 'hidden'
|
|
109
|
-
},
|
|
110
|
-
text: {
|
|
111
|
-
textAlign: 'left',
|
|
112
|
-
fontSize: 16,
|
|
113
|
-
paddingHorizontal: 12,
|
|
114
|
-
paddingVertical: 10
|
|
115
|
-
},
|
|
116
|
-
gradient: {
|
|
117
|
-
flex: 1
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
const meStyles = StyleSheet.create({
|
|
122
|
-
container: {
|
|
123
|
-
// backgroundColor: 'rgb(123, 22, 255)',
|
|
124
|
-
marginLeft: 5
|
|
125
|
-
},
|
|
126
|
-
text: {
|
|
127
|
-
color: 'white'
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
const otherStyles = StyleSheet.create({
|
|
132
|
-
container: {
|
|
133
|
-
// backgroundColor: 'lightgray',
|
|
134
|
-
marginRight: 5
|
|
135
|
-
},
|
|
136
|
-
text: {
|
|
137
|
-
color: 'black'
|
|
138
|
-
}
|
|
139
|
-
})
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { TextInput, StyleSheet, View } from 'react-native'
|
|
3
|
-
import { InputProps } from '../../types'
|
|
4
|
-
|
|
5
|
-
const Input = (props: InputProps) => {
|
|
6
|
-
return (
|
|
7
|
-
<View style={[styles.container, props.containerStyle]}>
|
|
8
|
-
<TextInput
|
|
9
|
-
{...props.inputProps}
|
|
10
|
-
placeholder={props.placeholderText || 'Type a new message...'}
|
|
11
|
-
placeholderTextColor={props.placeholderColor || 'lightgray'}
|
|
12
|
-
selectionColor={props.tintColor || 'blue'}
|
|
13
|
-
onChangeText={props.onChangeText}
|
|
14
|
-
value={props.text}
|
|
15
|
-
style={[styles.input, props.style]}
|
|
16
|
-
multiline
|
|
17
|
-
ref={props.inputRef}
|
|
18
|
-
returnKeyLabel={props.sendOnKeyboardReturn ? 'Send' : undefined}
|
|
19
|
-
returnKeyType={props.sendOnKeyboardReturn ? 'send' : undefined}
|
|
20
|
-
onSubmitEditing={props.onSubmitEditing}
|
|
21
|
-
/>
|
|
22
|
-
</View>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
Input.displayName = 'Juice.Input'
|
|
27
|
-
|
|
28
|
-
export default React.memo(Input)
|
|
29
|
-
|
|
30
|
-
const styles = StyleSheet.create({
|
|
31
|
-
container: {
|
|
32
|
-
flex: 1,
|
|
33
|
-
flexDirection: 'row',
|
|
34
|
-
marginHorizontal: 10,
|
|
35
|
-
borderRadius: 20,
|
|
36
|
-
borderWidth: 1,
|
|
37
|
-
borderColor: 'lightgray'
|
|
38
|
-
},
|
|
39
|
-
input: {
|
|
40
|
-
flex: 1,
|
|
41
|
-
padding: 10,
|
|
42
|
-
paddingTop: 10,
|
|
43
|
-
fontSize: 16
|
|
44
|
-
}
|
|
45
|
-
})
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react'
|
|
2
|
-
import { Button, StyleSheet, TouchableOpacity, View } from 'react-native'
|
|
3
|
-
import { Ionicons } from '@expo/vector-icons'
|
|
4
|
-
import { SendButtonProps } from '../../types'
|
|
5
|
-
|
|
6
|
-
const Send = (props: SendButtonProps) => {
|
|
7
|
-
if (props.mode === 'hidden') return null
|
|
8
|
-
const { containerStyle } = props
|
|
9
|
-
const Container = useCallback(
|
|
10
|
-
({ children }) => {
|
|
11
|
-
const style = {
|
|
12
|
-
...styles.container,
|
|
13
|
-
...(containerStyle || {}),
|
|
14
|
-
}
|
|
15
|
-
return <View style={style}>{children}</View>
|
|
16
|
-
},
|
|
17
|
-
[containerStyle],
|
|
18
|
-
)
|
|
19
|
-
if (props.mode === 'icon')
|
|
20
|
-
return (
|
|
21
|
-
<Container>
|
|
22
|
-
<TouchableOpacity onPress={props.onSend} style={[styles.button, { backgroundColor: props.tintColor || 'blue' }]}>
|
|
23
|
-
<Ionicons name="ios-arrow-round-up" size={size * 1.5} color={'white'} />
|
|
24
|
-
</TouchableOpacity>
|
|
25
|
-
</Container>
|
|
26
|
-
)
|
|
27
|
-
return (
|
|
28
|
-
<Container>
|
|
29
|
-
<Button title="Send" onPress={props.onSend} color={props.tintColor || 'blue'} />
|
|
30
|
-
</Container>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default React.memo(Send)
|
|
35
|
-
|
|
36
|
-
const size = 20
|
|
37
|
-
|
|
38
|
-
const styles = StyleSheet.create({
|
|
39
|
-
container: {
|
|
40
|
-
paddingRight: 5,
|
|
41
|
-
paddingBottom: 5,
|
|
42
|
-
},
|
|
43
|
-
button: {
|
|
44
|
-
borderRadius: size,
|
|
45
|
-
height: size * 1.5,
|
|
46
|
-
width: size * 1.5,
|
|
47
|
-
justifyContent: 'center',
|
|
48
|
-
alignItems: 'center',
|
|
49
|
-
// padding: size / 2
|
|
50
|
-
},
|
|
51
|
-
})
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import React, { useState, useCallback, useMemo, useEffect } from 'react'
|
|
2
|
-
import uuid from 'uuid'
|
|
3
|
-
import { View, StyleSheet, Keyboard } from 'react-native'
|
|
4
|
-
import { isIphoneX, getBottomSpace } from 'react-native-iphone-x-helper'
|
|
5
|
-
import { ComposerProps, InputProps, SendButtonProps, ChatProps } from '../types'
|
|
6
|
-
import Input from './Input'
|
|
7
|
-
import Send from './Send'
|
|
8
|
-
import { MessageMedia, NewMessageModel } from '../../../classes/Message/types'
|
|
9
|
-
|
|
10
|
-
// const emptyMedia: ComposerProps['media'][] = []
|
|
11
|
-
|
|
12
|
-
const Composer = (props: ComposerProps) => {
|
|
13
|
-
// First, we set up a state manager for the composer's text.
|
|
14
|
-
const [textState, setText] = useState(props.initialText || '')
|
|
15
|
-
// if you pass a text prop, use that state instead
|
|
16
|
-
const [text, onChangeText] = useMemo(
|
|
17
|
-
() => [
|
|
18
|
-
props.text !== undefined ? props.text : textState,
|
|
19
|
-
props.text !== undefined ? props.onInputTextChanged : setText
|
|
20
|
-
],
|
|
21
|
-
[props.text, textState, props.onInputTextChanged]
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
const [mediaState, setMedia] = useState<ComposerProps['media'][]>([])
|
|
25
|
-
const [media, onChangeMedia] = [
|
|
26
|
-
props.media || mediaState,
|
|
27
|
-
(props.media && props.onChangeMedia) || setMedia
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
// track whether or not the keyboard is open to style the bottom based on where or not you're on an iPhone X
|
|
31
|
-
const [keyboardOpen, setKeyboardOpen] = useState(false)
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const show = () => {
|
|
34
|
-
setKeyboardOpen(true)
|
|
35
|
-
}
|
|
36
|
-
const hide = () => {
|
|
37
|
-
setKeyboardOpen(false)
|
|
38
|
-
}
|
|
39
|
-
Keyboard.addListener('keyboardWillShow', show)
|
|
40
|
-
Keyboard.addListener('keyboardWillHide', hide)
|
|
41
|
-
return () => {
|
|
42
|
-
Keyboard.removeListener('keyboardWillShow', show)
|
|
43
|
-
Keyboard.removeListener('keyboardWillHide', hide)
|
|
44
|
-
}
|
|
45
|
-
}, [])
|
|
46
|
-
|
|
47
|
-
const { user } = props
|
|
48
|
-
const messagesReadyToSend = useMemo(() => {
|
|
49
|
-
const messages: NewMessageModel[] = []
|
|
50
|
-
if (media && media.length) {
|
|
51
|
-
;(media as MessageMedia[]).forEach((item: MessageMedia) => {
|
|
52
|
-
const message: NewMessageModel = {
|
|
53
|
-
user,
|
|
54
|
-
text: '',
|
|
55
|
-
id: uuid.v4(),
|
|
56
|
-
createdAt: new Date(),
|
|
57
|
-
media: item
|
|
58
|
-
}
|
|
59
|
-
messages.push(message)
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
if (text) {
|
|
63
|
-
const message: NewMessageModel = {
|
|
64
|
-
user,
|
|
65
|
-
text: text && text.trim(),
|
|
66
|
-
id: uuid.v4(),
|
|
67
|
-
createdAt: new Date()
|
|
68
|
-
}
|
|
69
|
-
messages.push(message)
|
|
70
|
-
}
|
|
71
|
-
return messages
|
|
72
|
-
}, [user, text, media])
|
|
73
|
-
|
|
74
|
-
const { onSend } = props
|
|
75
|
-
const send = useCallback(() => {
|
|
76
|
-
if (messagesReadyToSend.length) {
|
|
77
|
-
if (onChangeText) onChangeText('')
|
|
78
|
-
if (onChangeMedia) onChangeMedia([])
|
|
79
|
-
onSend(messagesReadyToSend)
|
|
80
|
-
}
|
|
81
|
-
}, [onChangeText, onChangeMedia, messagesReadyToSend, onSend])
|
|
82
|
-
|
|
83
|
-
const { textInputProps, renderTextInput } = props
|
|
84
|
-
const renderInput = useCallback(() => {
|
|
85
|
-
if (renderTextInput === null) return null
|
|
86
|
-
|
|
87
|
-
const onSubmitEditing: InputProps['onSubmitEditing'] = () => {
|
|
88
|
-
if (props.sendOnKeyboardReturn) send()
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const inputProps: InputProps = {
|
|
92
|
-
inputProps: textInputProps,
|
|
93
|
-
onChangeText,
|
|
94
|
-
text,
|
|
95
|
-
containerStyle: props.inputContainerStyle,
|
|
96
|
-
placeholderColor: props.placeholderColor,
|
|
97
|
-
placeholderText: props.placeholderText,
|
|
98
|
-
style: props.inputStyle,
|
|
99
|
-
tintColor: props.tintColor,
|
|
100
|
-
inputRef: props.inputRef,
|
|
101
|
-
sendOnKeyboardReturn: props.sendOnKeyboardReturn,
|
|
102
|
-
onSubmitEditing
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (renderTextInput) return renderTextInput(inputProps)
|
|
106
|
-
|
|
107
|
-
return <Input {...inputProps} />
|
|
108
|
-
}, [
|
|
109
|
-
onChangeText,
|
|
110
|
-
text,
|
|
111
|
-
textInputProps,
|
|
112
|
-
renderTextInput,
|
|
113
|
-
props.inputContainerStyle,
|
|
114
|
-
props.placeholderColor,
|
|
115
|
-
props.placeholderText,
|
|
116
|
-
props.inputStyle,
|
|
117
|
-
props.tintColor,
|
|
118
|
-
// TODO leave or take out?
|
|
119
|
-
props.inputRef,
|
|
120
|
-
props.sendOnKeyboardReturn,
|
|
121
|
-
send
|
|
122
|
-
])
|
|
123
|
-
|
|
124
|
-
const { renderSendButton, sendButtonMode } = props
|
|
125
|
-
const renderSend = useCallback(() => {
|
|
126
|
-
if (renderSendButton === null) return null
|
|
127
|
-
|
|
128
|
-
const mode: ChatProps['sendButtonMode'] = {
|
|
129
|
-
empty: 'hidden',
|
|
130
|
-
withText: 'icon',
|
|
131
|
-
...(sendButtonMode || {})
|
|
132
|
-
}
|
|
133
|
-
const sendProps: SendButtonProps = {
|
|
134
|
-
onSend: send,
|
|
135
|
-
text,
|
|
136
|
-
media: media as MessageMedia[],
|
|
137
|
-
user,
|
|
138
|
-
mode: (text && text.trim ? mode.withText : mode.empty) || 'icon',
|
|
139
|
-
containerStyle: props.sendButtonContainerStyle,
|
|
140
|
-
tintColor: props.tintColor
|
|
141
|
-
}
|
|
142
|
-
if (renderSendButton) return renderSendButton(sendProps)
|
|
143
|
-
|
|
144
|
-
return <Send {...sendProps} />
|
|
145
|
-
}, [
|
|
146
|
-
send,
|
|
147
|
-
text,
|
|
148
|
-
user,
|
|
149
|
-
media,
|
|
150
|
-
renderSendButton,
|
|
151
|
-
sendButtonMode,
|
|
152
|
-
props.sendButtonContainerStyle,
|
|
153
|
-
props.tintColor
|
|
154
|
-
])
|
|
155
|
-
|
|
156
|
-
const containerStyle = useMemo(() => {
|
|
157
|
-
const paddingBottom = keyboardOpen && isIphoneX() ? 10 : getBottomSpace()
|
|
158
|
-
return [styles.container, { paddingBottom }, props.containerStyle]
|
|
159
|
-
}, [props.containerStyle, keyboardOpen])
|
|
160
|
-
|
|
161
|
-
return (
|
|
162
|
-
<View style={[containerStyle]}>
|
|
163
|
-
<View style={styles.wrapper}>
|
|
164
|
-
{renderInput()}
|
|
165
|
-
{renderSend()}
|
|
166
|
-
</View>
|
|
167
|
-
</View>
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
Composer.displayName = 'Juice.Composer'
|
|
172
|
-
|
|
173
|
-
export default React.memo(Composer)
|
|
174
|
-
|
|
175
|
-
const styles = StyleSheet.create({
|
|
176
|
-
container: {
|
|
177
|
-
paddingBottom: 10,
|
|
178
|
-
paddingTop: 5
|
|
179
|
-
},
|
|
180
|
-
wrapper: {
|
|
181
|
-
flexDirection: 'row',
|
|
182
|
-
alignItems: 'flex-end'
|
|
183
|
-
}
|
|
184
|
-
})
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
import { Image, Dimensions, ImageStyle } from 'react-native'
|
|
3
|
-
import { MessageMedia } from '../../../../classes/Message/types'
|
|
4
|
-
|
|
5
|
-
const Img = (props: Omit<MessageMedia, 'contentType'>) => {
|
|
6
|
-
const dimensions = useMemo((): ImageStyle => {
|
|
7
|
-
const aspectRatio = props.width / props.height
|
|
8
|
-
const isVertical = props.height > props.width
|
|
9
|
-
const { width: screenWidth } = Dimensions.get('window')
|
|
10
|
-
const width = isVertical ? screenWidth * 0.6 : screenWidth * 0.7
|
|
11
|
-
const height = width / aspectRatio
|
|
12
|
-
|
|
13
|
-
return { height, width }
|
|
14
|
-
}, [props.height, props.width])
|
|
15
|
-
return (
|
|
16
|
-
<Image
|
|
17
|
-
source={{ uri: props.url || props.uri }}
|
|
18
|
-
style={dimensions}
|
|
19
|
-
resizeMode="cover"
|
|
20
|
-
/>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
Img.displayName = 'Juice.Image'
|
|
25
|
-
|
|
26
|
-
export default React.memo(Img)
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { MessageMedia } from '../../../classes/Message/types'
|
|
3
|
-
import Image from './Image'
|
|
4
|
-
|
|
5
|
-
const Media = ({ contentType, ...props }: MessageMedia) => {
|
|
6
|
-
if (contentType === 'image') return <Image {...props} />
|
|
7
|
-
if (contentType === 'video') return null
|
|
8
|
-
return null
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default React.memo(Media)
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react'
|
|
2
|
-
import Swipeable from 'react-native-gesture-handler/Swipeable'
|
|
3
|
-
import { SwipeableProps, SwipeActionProps } from '../../types'
|
|
4
|
-
import Action from './Action'
|
|
5
|
-
|
|
6
|
-
const Swiper = (props: SwipeableProps) => {
|
|
7
|
-
const { renderSwipeAction } = props
|
|
8
|
-
const renderAction = useCallback(
|
|
9
|
-
(actionProps: SwipeActionProps) => {
|
|
10
|
-
if (renderSwipeAction) return renderSwipeAction(actionProps)
|
|
11
|
-
|
|
12
|
-
return <Action {...actionProps} />
|
|
13
|
-
},
|
|
14
|
-
[renderSwipeAction]
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
const { swipeActions } = props
|
|
18
|
-
const leftActions = swipeActions && swipeActions.left
|
|
19
|
-
const rightActions = swipeActions && swipeActions.right
|
|
20
|
-
|
|
21
|
-
const renderRightActions = useCallback(() => {
|
|
22
|
-
if (rightActions) {
|
|
23
|
-
rightActions.forEach(action => {})
|
|
24
|
-
}
|
|
25
|
-
}, [rightActions])
|
|
26
|
-
|
|
27
|
-
const renderActionList = useCallback(() => {}, [])
|
|
28
|
-
|
|
29
|
-
return <Swipeable></Swipeable>
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default Swiper
|