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,307 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useRef } from 'react'
|
|
2
|
-
import { RectButton } from 'react-native-gesture-handler'
|
|
3
|
-
import { View, StyleSheet } from 'react-native'
|
|
4
|
-
import Title from './Title'
|
|
5
|
-
import ItemDate from './ItemDate'
|
|
6
|
-
import {
|
|
7
|
-
InboxItemProps,
|
|
8
|
-
InitialsProps,
|
|
9
|
-
SwipeableProps,
|
|
10
|
-
UnreadIndicatorProps
|
|
11
|
-
} from '../types'
|
|
12
|
-
import { ExistingRoomModel } from '../../../classes/Room/types'
|
|
13
|
-
import UnreadIndicator from './UnreadIndicator'
|
|
14
|
-
import Subtitle from './Subtitle'
|
|
15
|
-
import Avatar from '../../Avatar'
|
|
16
|
-
import Initials from './Initials'
|
|
17
|
-
import Swipeable from './Swipeable/index'
|
|
18
|
-
import TypingIndicator from '../../TypingIndicator'
|
|
19
|
-
|
|
20
|
-
function Item<InboxItem extends ExistingRoomModel = ExistingRoomModel>(
|
|
21
|
-
props: InboxItemProps<InboxItem>
|
|
22
|
-
) {
|
|
23
|
-
const renderCount = useRef(1)
|
|
24
|
-
renderCount.current++
|
|
25
|
-
function renderTitle() {
|
|
26
|
-
if (props.renderTitle) return props.renderTitle(props.name)
|
|
27
|
-
if (props.renderTitle === null) return null
|
|
28
|
-
|
|
29
|
-
const TitleComponent = props.TitleComponent || Title
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<TitleComponent
|
|
33
|
-
title={props.name}
|
|
34
|
-
style={props.titleStyle}
|
|
35
|
-
containerStyle={props.titleContainerStyle}
|
|
36
|
-
/>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
function renderDate() {
|
|
40
|
-
if (props.renderDate) return props.renderDate(props.lastMessageCreatedAt)
|
|
41
|
-
if (props.renderDate === null) return null
|
|
42
|
-
|
|
43
|
-
const DateComponent = props.DateComponent || ItemDate
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<DateComponent
|
|
47
|
-
dateToStringFunc={props.dateToStringFunc}
|
|
48
|
-
date={props.lastMessageCreatedAt}
|
|
49
|
-
style={props.dateStyle}
|
|
50
|
-
/>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
function renderUnreadIndicator() {
|
|
54
|
-
if (!props.showUnreadIndicator) return null
|
|
55
|
-
|
|
56
|
-
let position = 'center' as UnreadIndicatorProps['position']
|
|
57
|
-
if (
|
|
58
|
-
props.unreadIndicatorPosition &&
|
|
59
|
-
props.unreadIndicatorPosition.includes('-')
|
|
60
|
-
) {
|
|
61
|
-
// ex: turn bottom-left into bottom
|
|
62
|
-
// why? this component is only concerned w vertical position
|
|
63
|
-
position = props.unreadIndicatorPosition.split(
|
|
64
|
-
'-'
|
|
65
|
-
)[0] as UnreadIndicatorProps['position']
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const backgroundColor = props.unreadIndicatorColor || 'blue'
|
|
69
|
-
|
|
70
|
-
const indicatorProps: UnreadIndicatorProps = {
|
|
71
|
-
unreadCount: props.unreadCount,
|
|
72
|
-
textColor: props.unreadTextColor,
|
|
73
|
-
showCount: props.showUnreadIndicatorCount,
|
|
74
|
-
backgroundStyle: props.unreadIndicatorStyle,
|
|
75
|
-
textStyle: props.unreadIndicatorTextStyle,
|
|
76
|
-
position,
|
|
77
|
-
backgroundColor,
|
|
78
|
-
type: props.unreadIndicatorType || 'gradient',
|
|
79
|
-
gradientProps: props.unreadIndicatorGradientProps || {
|
|
80
|
-
colors: ['red', 'blue']
|
|
81
|
-
},
|
|
82
|
-
show: props.showUnreadIndicator,
|
|
83
|
-
size: props.unreadIndicatorSize
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (props.renderUnreadIndicator)
|
|
87
|
-
return props.renderUnreadIndicator(indicatorProps)
|
|
88
|
-
if (props.renderUnreadIndicator === null) return null
|
|
89
|
-
|
|
90
|
-
const UnreadIndicatorComponent =
|
|
91
|
-
props.UnreadIndicatorComponent || UnreadIndicator
|
|
92
|
-
|
|
93
|
-
return <UnreadIndicatorComponent {...indicatorProps} />
|
|
94
|
-
}
|
|
95
|
-
function renderSubtitle() {
|
|
96
|
-
if (props.renderSubtitle === null) return null
|
|
97
|
-
if (props.showTypingIndicator && props.numberOfPeopleTyping)
|
|
98
|
-
return renderTypingIndicator()
|
|
99
|
-
|
|
100
|
-
if (props.renderSubtitle) return props.renderSubtitle(props.lastMessageText)
|
|
101
|
-
|
|
102
|
-
const SubtitleComponent = props.SubtitleComponent || Subtitle
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<SubtitleComponent
|
|
106
|
-
textStyle={props.subtitleTextStyle}
|
|
107
|
-
lastMessageText={props.lastMessageText}
|
|
108
|
-
/>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// function renderAvatarOrInitials() {
|
|
113
|
-
// // not destructuring for clarity of where the variables come from
|
|
114
|
-
// const avatar = props.avatar
|
|
115
|
-
// const prioritizeAvatar = props.prioritizeAvatarOverInitials
|
|
116
|
-
// const size = props.avatarSize
|
|
117
|
-
// const members = props.members
|
|
118
|
-
|
|
119
|
-
// if (avatar && prioritizeAvatar) {
|
|
120
|
-
// const imageProps = props.avatarImageProps
|
|
121
|
-
// if (props.renderAvatar)
|
|
122
|
-
// props.renderAvatar({ imageProps, size, avatar, members })
|
|
123
|
-
// if (props.renderAvatar === null) return null
|
|
124
|
-
|
|
125
|
-
// const AvatarComponent = props.AvatarComponent || Avatar
|
|
126
|
-
|
|
127
|
-
// return <AvatarComponent {...imageProps} size={size} avatar={avatar} />
|
|
128
|
-
// }
|
|
129
|
-
// }
|
|
130
|
-
|
|
131
|
-
function renderAvatarOrInitials() {
|
|
132
|
-
if (props.disableAvatar) return null
|
|
133
|
-
|
|
134
|
-
const avatar = props.avatar
|
|
135
|
-
const initials = props.initials
|
|
136
|
-
const prioritizeAvatar = props.prioritizeAvatarOverInitials !== false
|
|
137
|
-
let size = props.avatarSize || 55
|
|
138
|
-
const imageProps = props.avatarImageProps
|
|
139
|
-
const textStyle = props.initialsTextStyle
|
|
140
|
-
const initialsContainerStyle = props.initialsContainerStyle
|
|
141
|
-
|
|
142
|
-
const InitialsComponent = props.InitialsComponent || Initials
|
|
143
|
-
const AvatarComponent = props.AvatarComponent || Avatar
|
|
144
|
-
|
|
145
|
-
if (Array.isArray(avatar)) {
|
|
146
|
-
size /= 2
|
|
147
|
-
return (
|
|
148
|
-
<>
|
|
149
|
-
{avatar.map((member, i) => {
|
|
150
|
-
if (member.avatar && prioritizeAvatar) {
|
|
151
|
-
const avatarProps = {
|
|
152
|
-
imageProps,
|
|
153
|
-
size,
|
|
154
|
-
avatar: member.avatar
|
|
155
|
-
}
|
|
156
|
-
if (props.renderAvatar) return props.renderAvatar(avatarProps)
|
|
157
|
-
if (props.renderAvatar === null) return null
|
|
158
|
-
|
|
159
|
-
return <AvatarComponent {...avatarProps} />
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const initialsProps: InitialsProps = {
|
|
163
|
-
textStyle,
|
|
164
|
-
containerStyle: initialsContainerStyle,
|
|
165
|
-
initials,
|
|
166
|
-
size,
|
|
167
|
-
textColor: props.initialsTextColor,
|
|
168
|
-
backgroundColor: props.initialsBackgroundColor
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (props.renderInitials) return props.renderInitials(initialProps)
|
|
172
|
-
if (props.renderInitials === null) return null
|
|
173
|
-
|
|
174
|
-
return (
|
|
175
|
-
<InitialsComponent
|
|
176
|
-
key={initials + i.toString()}
|
|
177
|
-
{...initialsProps}
|
|
178
|
-
/>
|
|
179
|
-
)
|
|
180
|
-
})}
|
|
181
|
-
</>
|
|
182
|
-
)
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (avatar && prioritizeAvatar) {
|
|
186
|
-
const avatarProps = {
|
|
187
|
-
imageProps,
|
|
188
|
-
size,
|
|
189
|
-
avatar
|
|
190
|
-
}
|
|
191
|
-
if (props.renderAvatar) return props.renderAvatar(avatarProps)
|
|
192
|
-
if (props.renderAvatar === null) return null
|
|
193
|
-
|
|
194
|
-
return <AvatarComponent {...avatarProps} />
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const initialProps: InitialsProps = {
|
|
198
|
-
initials,
|
|
199
|
-
size,
|
|
200
|
-
textStyle,
|
|
201
|
-
containerStyle: initialsContainerStyle,
|
|
202
|
-
textColor: props.initialsTextColor,
|
|
203
|
-
backgroundColor: props.initialsBackgroundColor
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (props.renderInitials) return props.renderInitials(initialProps)
|
|
207
|
-
if (props.renderInitials === null) return null
|
|
208
|
-
|
|
209
|
-
return <InitialsComponent {...initialProps} />
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function typingIndicator() {
|
|
213
|
-
if (props.renderTypingIndicator) return props.renderTypingIndicator()
|
|
214
|
-
if (props.renderTypingIndicator === null) return null
|
|
215
|
-
|
|
216
|
-
return (
|
|
217
|
-
<View style={{ marginTop: 5 }}>
|
|
218
|
-
<TypingIndicator />
|
|
219
|
-
</View>
|
|
220
|
-
)
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const renderTypingIndicator = useCallback(typingIndicator, [
|
|
224
|
-
props.renderTypingIndicator
|
|
225
|
-
])
|
|
226
|
-
|
|
227
|
-
const unreadIndicatorIsOnRight = !!(
|
|
228
|
-
props.showTypingIndicator &&
|
|
229
|
-
props.unreadIndicatorPosition &&
|
|
230
|
-
props.unreadIndicatorPosition.includes('right')
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
const flexDirection = unreadIndicatorIsOnRight ? 'row-reverse' : 'row'
|
|
234
|
-
|
|
235
|
-
// if row-reverse, this flips to the other side
|
|
236
|
-
const paddingLeft = props.showUnreadIndicator ? 5 : 10
|
|
237
|
-
|
|
238
|
-
const swipeableProps: SwipeableProps = {
|
|
239
|
-
id: props.id,
|
|
240
|
-
rightActions: props.swipeRightActions,
|
|
241
|
-
leftActions: props.swipeLeftActions,
|
|
242
|
-
renderAction: props.renderSwipeAction,
|
|
243
|
-
actionWidth: props.swipeActionWidth,
|
|
244
|
-
gestureHandlerProps: props.swipeableRowProps,
|
|
245
|
-
renderLeftActions: props.renderLeftActions,
|
|
246
|
-
renderRightActions: props.renderRightActions,
|
|
247
|
-
textStyle: props.actionTextStyle
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const ContainerComponent = props.swipeable ? Swipeable : View
|
|
251
|
-
|
|
252
|
-
return (
|
|
253
|
-
<ContainerComponent {...swipeableProps}>
|
|
254
|
-
<RectButton
|
|
255
|
-
onPress={props.onPress}
|
|
256
|
-
style={{ backgroundColor: props.backgroundColor }}
|
|
257
|
-
>
|
|
258
|
-
<View
|
|
259
|
-
style={[
|
|
260
|
-
{
|
|
261
|
-
paddingLeft,
|
|
262
|
-
...styles.container,
|
|
263
|
-
...(props.containerStyle || {})
|
|
264
|
-
},
|
|
265
|
-
{ flexDirection }
|
|
266
|
-
]}
|
|
267
|
-
>
|
|
268
|
-
{renderUnreadIndicator()}
|
|
269
|
-
<View style={[styles.wrapper]}>
|
|
270
|
-
{renderAvatarOrInitials()}
|
|
271
|
-
<View style={styles.inner}>
|
|
272
|
-
<View style={styles.content}>
|
|
273
|
-
{renderTitle()}
|
|
274
|
-
{renderDate()}
|
|
275
|
-
</View>
|
|
276
|
-
{renderSubtitle()}
|
|
277
|
-
</View>
|
|
278
|
-
</View>
|
|
279
|
-
</View>
|
|
280
|
-
</RectButton>
|
|
281
|
-
</ContainerComponent>
|
|
282
|
-
)
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export default React.memo(Item)
|
|
286
|
-
|
|
287
|
-
const styles = StyleSheet.create({
|
|
288
|
-
container: {
|
|
289
|
-
flexDirection: 'row',
|
|
290
|
-
paddingVertical: 10,
|
|
291
|
-
justifyContent: 'center',
|
|
292
|
-
marginBottom: 5,
|
|
293
|
-
paddingRight: 10
|
|
294
|
-
},
|
|
295
|
-
wrapper: {
|
|
296
|
-
flex: 1,
|
|
297
|
-
flexDirection: 'row'
|
|
298
|
-
},
|
|
299
|
-
content: {
|
|
300
|
-
flexDirection: 'row',
|
|
301
|
-
justifyContent: 'space-between'
|
|
302
|
-
},
|
|
303
|
-
inner: {
|
|
304
|
-
flex: 1,
|
|
305
|
-
paddingLeft: 10
|
|
306
|
-
}
|
|
307
|
-
})
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Animated,
|
|
4
|
-
ListRenderItemInfo,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
SafeAreaView
|
|
7
|
-
} from 'react-native'
|
|
8
|
-
import InboxProps, { InboxMethodProps, InboxItemProps } from './types'
|
|
9
|
-
import { ExistingRoomModel } from '../../classes/Room/types'
|
|
10
|
-
import Item from './Item'
|
|
11
|
-
import Room from '../../classes/Room'
|
|
12
|
-
import { getInitials } from '../../helpers/getInitials'
|
|
13
|
-
import Separator from './Item/Separator'
|
|
14
|
-
import Reanimated, {
|
|
15
|
-
Transitioning,
|
|
16
|
-
Transition,
|
|
17
|
-
TransitioningView
|
|
18
|
-
} from 'react-native-reanimated'
|
|
19
|
-
|
|
20
|
-
export default function<InboxItem extends ExistingRoomModel>(
|
|
21
|
-
props: InboxProps<InboxItem>
|
|
22
|
-
) {
|
|
23
|
-
// "constructor" variables
|
|
24
|
-
|
|
25
|
-
// used to shuffle/transition the inbox when it changes
|
|
26
|
-
const transitionRef = useRef<TransitioningView>(null)
|
|
27
|
-
|
|
28
|
-
const numberOfRoomsWithUsersTyping = (props.rooms || []).filter(
|
|
29
|
-
room => new Room(room).getUsersTyping().length
|
|
30
|
-
).length
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (props.enableRoomTransitions !== false && transitionRef.current)
|
|
34
|
-
transitionRef.current.animateNextTransition()
|
|
35
|
-
}, [props.rooms, props.enableRoomTransitions, numberOfRoomsWithUsersTyping])
|
|
36
|
-
|
|
37
|
-
// track animated position of scroll
|
|
38
|
-
const scrollY: Animated.Value =
|
|
39
|
-
props.animatedScrollNode || new Animated.Value(0)
|
|
40
|
-
|
|
41
|
-
// upate position of scroll variable
|
|
42
|
-
const onScroll = Animated.event(
|
|
43
|
-
[{ nativeEvent: { contentOffset: { y: scrollY } } }],
|
|
44
|
-
{ useNativeDriver: true }
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
// render room list
|
|
48
|
-
function renderList() {
|
|
49
|
-
// give a unique key to each item (flatlist prop)
|
|
50
|
-
function keyExtractor(item: InboxItem, index: number) {
|
|
51
|
-
return props.keyExtractor
|
|
52
|
-
? props.keyExtractor(item, index)
|
|
53
|
-
: (item && item.id) || index.toString()
|
|
54
|
-
}
|
|
55
|
-
return (
|
|
56
|
-
<Animated.FlatList
|
|
57
|
-
onScroll={onScroll}
|
|
58
|
-
extraData={props.extraData}
|
|
59
|
-
contentContainerStyle={styles.contentContainer}
|
|
60
|
-
ItemSeparatorComponent={() => (
|
|
61
|
-
<Separator size={props.separatorSize} color={props.separatorColor} />
|
|
62
|
-
)}
|
|
63
|
-
{...props.flatListProps}
|
|
64
|
-
keyExtractor={keyExtractor}
|
|
65
|
-
renderItem={renderItem}
|
|
66
|
-
data={props.rooms}
|
|
67
|
-
/>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// optionally render header
|
|
72
|
-
function renderHeader() {
|
|
73
|
-
const headerProps: InboxMethodProps<InboxItem>['renderHeader'] = {
|
|
74
|
-
scrollY,
|
|
75
|
-
big: props.bigHeader !== false,
|
|
76
|
-
onPressNewRoom: props.onPressNewRoom
|
|
77
|
-
}
|
|
78
|
-
if (props.renderHeader) return props.renderHeader(headerProps)
|
|
79
|
-
if (props.renderHeader === null) return null
|
|
80
|
-
|
|
81
|
-
const HeaderComponent = props.HeaderComponent || Animated.View
|
|
82
|
-
|
|
83
|
-
return <HeaderComponent {...headerProps} />
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// optionally render footer
|
|
87
|
-
function renderFooter() {
|
|
88
|
-
const footerProps: InboxMethodProps<InboxItem>['renderFooter'] = {
|
|
89
|
-
scrollY
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (props.renderFooter) return props.renderFooter(footerProps)
|
|
93
|
-
if (props.renderFooter === null) return null
|
|
94
|
-
|
|
95
|
-
const FooterComponent = props.FooterComponent || Animated.View
|
|
96
|
-
|
|
97
|
-
return <FooterComponent {...footerProps} />
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// flatlist methods
|
|
101
|
-
|
|
102
|
-
// render each room item
|
|
103
|
-
function renderItem(itemInfo: ListRenderItemInfo<InboxItem>) {
|
|
104
|
-
// not sure why you'd wanna return null, but just in case...
|
|
105
|
-
if (props.renderItem === null) return null
|
|
106
|
-
// render item raw – without our constructed props
|
|
107
|
-
if (props.renderItem) return props.renderItem(itemInfo)
|
|
108
|
-
|
|
109
|
-
const maxNumberOfInitials = props.maxNumberOfInitials || 2
|
|
110
|
-
|
|
111
|
-
const {
|
|
112
|
-
lastMessage,
|
|
113
|
-
members,
|
|
114
|
-
id,
|
|
115
|
-
unreadCount = 0,
|
|
116
|
-
name: roomName = ''
|
|
117
|
-
} = itemInfo.item
|
|
118
|
-
|
|
119
|
-
const room = new Room({ members, id, name: roomName })
|
|
120
|
-
|
|
121
|
-
const name = props.roomNameFunc
|
|
122
|
-
? props.roomNameFunc({ members, name: roomName })
|
|
123
|
-
: room.getName()
|
|
124
|
-
|
|
125
|
-
// first check for a room avatar
|
|
126
|
-
const roomAvatar = itemInfo.item.avatar
|
|
127
|
-
|
|
128
|
-
// either one image or an array
|
|
129
|
-
let avatar: InboxItemProps<InboxItem>['avatar'] = roomAvatar || ''
|
|
130
|
-
const initials: string = props.roomInitialsFunc
|
|
131
|
-
? props.roomInitialsFunc({
|
|
132
|
-
members,
|
|
133
|
-
name,
|
|
134
|
-
maxNumberOfInitials
|
|
135
|
-
})
|
|
136
|
-
: room.getInitials(maxNumberOfInitials)
|
|
137
|
-
|
|
138
|
-
const otherMembers = room.getArrayOfMembersOtherThanMe()
|
|
139
|
-
|
|
140
|
-
/*
|
|
141
|
-
|
|
142
|
-
This next block of verbose code concerns itself with
|
|
143
|
-
the avatar / initials icon
|
|
144
|
-
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
// if the room has no name, and we prefer to show avatars
|
|
148
|
-
// then we want to get as close as we can to showing the avatar
|
|
149
|
-
if (props.prioritizeAvatarOverInitials && !roomName) {
|
|
150
|
-
// if there's currently no avatar
|
|
151
|
-
// and only one member
|
|
152
|
-
// then make the avatar that person's picture
|
|
153
|
-
if (!avatar && otherMembers.length === 1 && otherMembers[0]) {
|
|
154
|
-
avatar = (otherMembers[0] && otherMembers[0].avatar) || ''
|
|
155
|
-
}
|
|
156
|
-
// alternatively, if there are multiple people,
|
|
157
|
-
// no room avatar,
|
|
158
|
-
// and we want to show multiple avatars as a fallback
|
|
159
|
-
if (
|
|
160
|
-
otherMembers.length > 1 &&
|
|
161
|
-
!roomAvatar &&
|
|
162
|
-
props.fallbackToMultipleAvatarsIfNoGroupAvatar !== false
|
|
163
|
-
) {
|
|
164
|
-
// TODO something here is weird, this doesn't make sense
|
|
165
|
-
|
|
166
|
-
// avatar then becomes an array which also includes the initials
|
|
167
|
-
// for each member user, an array with this => { avatar, initials }
|
|
168
|
-
// then, in the item component, if avatar is prioritized and existent, we render that
|
|
169
|
-
avatar = otherMembers
|
|
170
|
-
.map(member => ({
|
|
171
|
-
initials: getInitials(member.name, props.maxNumberOfInitials),
|
|
172
|
-
avatar: member.avatar || ''
|
|
173
|
-
}))
|
|
174
|
-
.sort((a, b) => (a.avatar > b.avatar ? 1 : -1))
|
|
175
|
-
}
|
|
176
|
-
// 😅 glad that's done
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const onPress = (pointerInside?: boolean) =>
|
|
180
|
-
props.onPressItem
|
|
181
|
-
? props.onPressItem(id, pointerInside)
|
|
182
|
-
: console.log(
|
|
183
|
-
id,
|
|
184
|
-
'pressed. change onPressItem prop on the <Inbox /> component to handle this function.'
|
|
185
|
-
)
|
|
186
|
-
|
|
187
|
-
const onLongPress = (pointerInside?: boolean) =>
|
|
188
|
-
props.onLongPressItem
|
|
189
|
-
? props.onLongPressItem(id, pointerInside)
|
|
190
|
-
: console.log(
|
|
191
|
-
'long pressed ',
|
|
192
|
-
id,
|
|
193
|
-
'edit onLongPressItem prop to handle this function'
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
// well those are some props.
|
|
197
|
-
// each room receives these
|
|
198
|
-
// most of them are passed directly from the parent component props
|
|
199
|
-
// the ones marked <someprop>: props.<someprop> !== false are default true
|
|
200
|
-
const itemProps: InboxItemProps<InboxItem> = {
|
|
201
|
-
lastMessageCreatedAt: lastMessage.createdAt,
|
|
202
|
-
lastMessageText: lastMessage.text,
|
|
203
|
-
avatar,
|
|
204
|
-
name,
|
|
205
|
-
initials,
|
|
206
|
-
onPress,
|
|
207
|
-
unreadCount,
|
|
208
|
-
renderTitle: props.renderItemTitle,
|
|
209
|
-
renderDate: props.renderItemDate,
|
|
210
|
-
TitleComponent: props.ItemTitleComponent,
|
|
211
|
-
titleStyle: props.titleStyle,
|
|
212
|
-
titleContainerStyle: props.titleContainerStyle,
|
|
213
|
-
DateComponent: props.ItemDateComponent,
|
|
214
|
-
unreadIndicatorColor: props.unreadIndicatorColor,
|
|
215
|
-
unreadTextColor: props.unreadTextColor,
|
|
216
|
-
showUnreadIndicator: props.showUnreadIndicator !== false,
|
|
217
|
-
showUnreadIndicatorCount: props.showUnreadIndicatorCount !== false,
|
|
218
|
-
UnreadIndicatorComponent: props.UnreadIndicatorComponent,
|
|
219
|
-
renderUnreadIndicator: props.renderUnreadIndicator,
|
|
220
|
-
unreadIndicatorStyle: props.unreadIndicatorStyle,
|
|
221
|
-
unreadIndicatorTextStyle: props.unreadIndicatorTextStyle,
|
|
222
|
-
unreadIndicatorPosition: props.unreadIndicatorPostion,
|
|
223
|
-
dateToStringFunc: props.dateToStringFunc,
|
|
224
|
-
onLongPress,
|
|
225
|
-
prioritizeAvatarOverInitials:
|
|
226
|
-
props.prioritizeAvatarOverInitials !== false, // default true
|
|
227
|
-
renderAvatar: props.renderAvatar,
|
|
228
|
-
renderInitials: props.renderInitials,
|
|
229
|
-
renderSubtitle: props.renderItemSubtitle,
|
|
230
|
-
SubtitleComponent: props.ItemSubtitleComponent,
|
|
231
|
-
subtitleTextStyle: props.itemSubtitleTextStyle,
|
|
232
|
-
AvatarComponent: props.ItemAvatarComponent,
|
|
233
|
-
InitialsComponent: props.ItemInitialsComponent,
|
|
234
|
-
roomInitialsFunc: props.roomInitialsFunc,
|
|
235
|
-
avatarImageProps: props.avatarImageProps,
|
|
236
|
-
avatarSize: props.avatarSize,
|
|
237
|
-
initialsContainerStyle: props.initialsContainerStyle,
|
|
238
|
-
initialsTextStyle: props.initialsTextStyle,
|
|
239
|
-
disableAvatar: props.disableAvatar,
|
|
240
|
-
initialsBackgroundColor: props.initialsBackgroundColor,
|
|
241
|
-
initialsTextColor: props.initialsTextColor,
|
|
242
|
-
swipeable: props.swipeableRow !== false,
|
|
243
|
-
id,
|
|
244
|
-
renderSwipeAction: props.renderSwipeAction,
|
|
245
|
-
swipeLeftActions: props.swipeLeftActions,
|
|
246
|
-
swipeRightActions: props.swipeRightActions,
|
|
247
|
-
swipeActionWidth: props.swipeActionWidth,
|
|
248
|
-
backgroundColor: props.itemBackgroundColor || 'white',
|
|
249
|
-
swipeableRowProps: props.swipeableRowProps,
|
|
250
|
-
unreadIndicatorType: props.unreadIndicatorType,
|
|
251
|
-
unreadIndicatorGradientProps: props.unreadIndicatorGradientProps,
|
|
252
|
-
unreadIndicatorSize: props.unreadIndicatorSize,
|
|
253
|
-
containerStyle: props.itemContainerStyle,
|
|
254
|
-
dateStyle: props.dateStyle,
|
|
255
|
-
renderLeftActions: props.renderLeftActions,
|
|
256
|
-
renderRightActions: props.renderRightActions,
|
|
257
|
-
actionTextStyle: props.actionTextStyle,
|
|
258
|
-
showTypingIndicator: props.showTypingIndicator !== false,
|
|
259
|
-
renderTypingIndicator: props.renderTypingIndicator,
|
|
260
|
-
numberOfPeopleTyping: room.getUsersTyping().length
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// if you want to use your own renderItem function, but include the props we made
|
|
264
|
-
// the alternative is a normal props.renderItem() which gets the raw flatlist data
|
|
265
|
-
if (props.renderItemWithProps) return props.renderItemWithProps(itemProps)
|
|
266
|
-
|
|
267
|
-
// custom InboxItem component, or the one we used
|
|
268
|
-
const InboxItemComponent = props.InboxItemComponent || Item
|
|
269
|
-
return <InboxItemComponent {...itemProps} />
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// component props
|
|
273
|
-
const Container =
|
|
274
|
-
props.ContainerComponent ||
|
|
275
|
-
(props.safeArea
|
|
276
|
-
? Reanimated.createAnimatedComponent(SafeAreaView)
|
|
277
|
-
: Reanimated.View)
|
|
278
|
-
const containerStyles = [styles.container, props.containerStyle]
|
|
279
|
-
|
|
280
|
-
// inbox shuffle transition config
|
|
281
|
-
const transition: InboxProps<
|
|
282
|
-
InboxItem
|
|
283
|
-
>['roomTransitionConfig'] = props.roomTransitionConfig || (
|
|
284
|
-
<Transition.Together>
|
|
285
|
-
<Transition.Change
|
|
286
|
-
interpolation="easeInOut"
|
|
287
|
-
durationMs={400}
|
|
288
|
-
propagation="top"
|
|
289
|
-
/>
|
|
290
|
-
</Transition.Together>
|
|
291
|
-
)
|
|
292
|
-
|
|
293
|
-
return (
|
|
294
|
-
<Transitioning.View
|
|
295
|
-
transition={transition}
|
|
296
|
-
ref={transitionRef}
|
|
297
|
-
style={containerStyles}
|
|
298
|
-
>
|
|
299
|
-
<Container style={containerStyles}>
|
|
300
|
-
{renderHeader()}
|
|
301
|
-
{renderList()}
|
|
302
|
-
{renderFooter()}
|
|
303
|
-
</Container>
|
|
304
|
-
</Transitioning.View>
|
|
305
|
-
)
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const styles = StyleSheet.create({
|
|
309
|
-
container: {
|
|
310
|
-
flex: 1
|
|
311
|
-
},
|
|
312
|
-
contentContainer: {
|
|
313
|
-
flexGrow: 1
|
|
314
|
-
}
|
|
315
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Any idea on how to achieve this fix with react hooks in a function component? Not sure what to do since you can't use `this`.
|
|
2
|
-
|
|
3
|
-
I have an `onViewableItemsChanged` function that relies on two outside variables: `messages` and `roomId`. I tried using `useCallback`, but I still get this error, since an updated `messages` array refreshes onViewableItemsChanged.
|
|
4
|
-
|
|
5
|
-
**Example:**
|
|
6
|
-
|
|
7
|
-
```javascript
|
|
8
|
-
const onViewableItemsChanged = useCallback(
|
|
9
|
-
info => {
|
|
10
|
-
info.viewableItems.forEach(({ item }) => {
|
|
11
|
-
const mostRecentMessage = messages[messages.length - 1]
|
|
12
|
-
if (item.id === mostRecentMessage) viewMessage(roomId, item.id)
|
|
13
|
-
})
|
|
14
|
-
},
|
|
15
|
-
[messages, roomId]
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
...
|
|
19
|
-
|
|
20
|
-
return <FlatList onViewableItemsChanged={onViewableItemsChanged} />
|
|
21
|
-
```
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Juice Inbox Component
|
|
2
|
-
|
|
3
|
-
This react native component is a drop-in for an entire inbox UI.
|
|
4
|
-
|
|
5
|
-
It directly integrates with Juice's `useInbox` hook.
|
|
6
|
-
|
|
7
|
-
## Quick example
|
|
8
|
-
|
|
9
|
-
This example shows a **fully backend-connected**, **real-time** inbox. 🤯
|
|
10
|
-
|
|
11
|
-
```javascript
|
|
12
|
-
import * as React from 'react'
|
|
13
|
-
import Juice, { useInbox } from 'usechat'
|
|
14
|
-
|
|
15
|
-
export default function() {
|
|
16
|
-
const [{ data, loading }] = useInbox()
|
|
17
|
-
return <Juice.Inbox rooms={data} onPressItem={id => console.log(id)} />
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
You can use it with your own backend if you'd like, since it's fully customizable. This component has a ton of props, so everything is extensible. But it was definitely made with `useInbox` in mind.
|