@kesha-antonov/react-native-chat 6.0.0 → 6.1.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/README.md +28 -5
- package/lib/Actions.d.ts.map +1 -1
- package/lib/Actions.js +33 -27
- package/lib/Actions.js.map +1 -1
- package/lib/Chat/Chat.d.ts.map +1 -1
- package/lib/Chat/Chat.js +253 -203
- package/lib/Chat/Chat.js.map +1 -1
- package/lib/Chat/ChatMessageList.d.ts.map +1 -1
- package/lib/Chat/ChatMessageList.js +4 -0
- package/lib/Chat/ChatMessageList.js.map +1 -1
- package/lib/Chat/index.d.ts +9 -1
- package/lib/Chat/index.d.ts.map +1 -1
- package/lib/Chat/index.js +14 -1
- package/lib/Chat/index.js.map +1 -1
- package/lib/Chat/types.d.ts +29 -0
- package/lib/Chat/types.d.ts.map +1 -1
- package/lib/Chat/types.js.map +1 -1
- package/lib/Chat/useMessageActions.d.ts +1 -0
- package/lib/Chat/useMessageActions.d.ts.map +1 -1
- package/lib/Chat/useMessageActions.js +97 -89
- package/lib/Chat/useMessageActions.js.map +1 -1
- package/lib/ChatHeader.d.ts +50 -0
- package/lib/ChatHeader.d.ts.map +1 -0
- package/lib/ChatHeader.js +356 -0
- package/lib/ChatHeader.js.map +1 -0
- package/lib/ChatList/ChatListCell.d.ts +1 -1
- package/lib/ChatList/ChatListCell.d.ts.map +1 -1
- package/lib/ChatList/ChatListCell.js +42 -11
- package/lib/ChatList/ChatListCell.js.map +1 -1
- package/lib/ChatList/index.js +332 -323
- package/lib/ChatList/index.js.map +1 -1
- package/lib/ChatList/types.d.ts +17 -1
- package/lib/ChatList/types.d.ts.map +1 -1
- package/lib/ChatList/types.js.map +1 -1
- package/lib/ChatList/utils.d.ts +4 -1
- package/lib/ChatList/utils.d.ts.map +1 -1
- package/lib/ChatList/utils.js +3 -2
- package/lib/ChatList/utils.js.map +1 -1
- package/lib/Composer.js +5 -1
- package/lib/Composer.js.map +1 -1
- package/lib/InputToolbar/fragments.d.ts +1 -1
- package/lib/InputToolbar/fragments.d.ts.map +1 -1
- package/lib/InputToolbar/fragments.js +9 -7
- package/lib/InputToolbar/fragments.js.map +1 -1
- package/lib/InputToolbar/index.d.ts.map +1 -1
- package/lib/InputToolbar/index.js +3 -2
- package/lib/InputToolbar/index.js.map +1 -1
- package/lib/InputToolbar/types.d.ts +6 -0
- package/lib/InputToolbar/types.d.ts.map +1 -1
- package/lib/InputToolbar/types.js.map +1 -1
- package/lib/InputToolbar/useActionsFragment.d.ts.map +1 -1
- package/lib/InputToolbar/useActionsFragment.js +83 -59
- package/lib/InputToolbar/useActionsFragment.js.map +1 -1
- package/lib/InputToolbar/useKeyboardInset.d.ts +1 -1
- package/lib/InputToolbar/useKeyboardInset.d.ts.map +1 -1
- package/lib/InputToolbar/useKeyboardInset.js +2 -2
- package/lib/InputToolbar/useKeyboardInset.js.map +1 -1
- package/lib/MessageText.d.ts.map +1 -1
- package/lib/MessageText.js +39 -33
- package/lib/MessageText.js.map +1 -1
- package/lib/MessagesContainer/index.d.ts.map +1 -1
- package/lib/MessagesContainer/index.js +113 -94
- package/lib/MessagesContainer/index.js.map +1 -1
- package/lib/MessagesContainer/types.d.ts +5 -2
- package/lib/MessagesContainer/types.d.ts.map +1 -1
- package/lib/MessagesContainer/types.js.map +1 -1
- package/lib/MessagesContainer/useChained.d.ts +6 -0
- package/lib/MessagesContainer/useChained.d.ts.map +1 -0
- package/lib/MessagesContainer/useChained.js +38 -0
- package/lib/MessagesContainer/useChained.js.map +1 -0
- package/lib/MessagesContainer/useListChrome.d.ts.map +1 -1
- package/lib/MessagesContainer/useListChrome.js +1 -1
- package/lib/MessagesContainer/useListChrome.js.map +1 -1
- package/lib/Models.d.ts +2 -1
- package/lib/Models.d.ts.map +1 -1
- package/lib/Models.js.map +1 -1
- package/lib/Send.d.ts.map +1 -1
- package/lib/Send.js +18 -13
- package/lib/Send.js.map +1 -1
- package/lib/Theme.d.ts +11 -0
- package/lib/Theme.d.ts.map +1 -1
- package/lib/Theme.js +17 -1
- package/lib/Theme.js.map +1 -1
- package/lib/attachments/AttachmentButton.js +17 -15
- package/lib/attachments/AttachmentButton.js.map +1 -1
- package/lib/attachments/AttachmentMenu/GalleryGrid.d.ts +3 -1
- package/lib/attachments/AttachmentMenu/GalleryGrid.d.ts.map +1 -1
- package/lib/attachments/AttachmentMenu/GalleryGrid.js +69 -68
- package/lib/attachments/AttachmentMenu/GalleryGrid.js.map +1 -1
- package/lib/attachments/AttachmentMenu/TabPanel.d.ts +3 -1
- package/lib/attachments/AttachmentMenu/TabPanel.d.ts.map +1 -1
- package/lib/attachments/AttachmentMenu/TabPanel.js +23 -21
- package/lib/attachments/AttachmentMenu/TabPanel.js.map +1 -1
- package/lib/attachments/AttachmentMenu/index.d.ts +6 -2
- package/lib/attachments/AttachmentMenu/index.d.ts.map +1 -1
- package/lib/attachments/AttachmentMenu/index.js +259 -247
- package/lib/attachments/AttachmentMenu/index.js.map +1 -1
- package/lib/attachments/buildMessages.d.ts +4 -4
- package/lib/attachments/buildMessages.d.ts.map +1 -1
- package/lib/attachments/buildMessages.js +9 -8
- package/lib/attachments/buildMessages.js.map +1 -1
- package/lib/attachments/types.d.ts +19 -0
- package/lib/attachments/types.d.ts.map +1 -1
- package/lib/attachments/types.js.map +1 -1
- package/lib/components/TouchableOpacity.d.ts +5 -0
- package/lib/components/TouchableOpacity.d.ts.map +1 -1
- package/lib/components/TouchableOpacity.js +59 -54
- package/lib/components/TouchableOpacity.js.map +1 -1
- package/lib/components/defaultMessageActions.d.ts +3 -1
- package/lib/components/defaultMessageActions.d.ts.map +1 -1
- package/lib/components/defaultMessageActions.js +9 -1
- package/lib/components/defaultMessageActions.js.map +1 -1
- package/lib/components/textHighlight.d.ts +14 -0
- package/lib/components/textHighlight.d.ts.map +1 -0
- package/lib/components/textHighlight.js +39 -0
- package/lib/components/textHighlight.js.map +1 -0
- package/lib/hooks/useKeyboardVerticalOffset.d.ts +6 -0
- package/lib/hooks/useKeyboardVerticalOffset.d.ts.map +1 -1
- package/lib/hooks/useKeyboardVerticalOffset.js +35 -13
- package/lib/hooks/useKeyboardVerticalOffset.js.map +1 -1
- package/lib/i18n.d.ts +2 -0
- package/lib/i18n.d.ts.map +1 -1
- package/lib/i18n.js +1 -0
- package/lib/i18n.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/linkParser.d.ts +4 -1
- package/lib/linkParser.d.ts.map +1 -1
- package/lib/linkParser.js +115 -78
- package/lib/linkParser.js.map +1 -1
- package/lib/locales/ar.d.ts.map +1 -1
- package/lib/locales/ar.js +1 -0
- package/lib/locales/ar.js.map +1 -1
- package/lib/locales/de.d.ts.map +1 -1
- package/lib/locales/de.js +1 -0
- package/lib/locales/de.js.map +1 -1
- package/lib/locales/es.d.ts.map +1 -1
- package/lib/locales/es.js +1 -0
- package/lib/locales/es.js.map +1 -1
- package/lib/locales/fr.d.ts.map +1 -1
- package/lib/locales/fr.js +1 -0
- package/lib/locales/fr.js.map +1 -1
- package/lib/locales/hi.d.ts.map +1 -1
- package/lib/locales/hi.js +1 -0
- package/lib/locales/hi.js.map +1 -1
- package/lib/locales/id.d.ts.map +1 -1
- package/lib/locales/id.js +1 -0
- package/lib/locales/id.js.map +1 -1
- package/lib/locales/it.d.ts.map +1 -1
- package/lib/locales/it.js +1 -0
- package/lib/locales/it.js.map +1 -1
- package/lib/locales/ja.d.ts.map +1 -1
- package/lib/locales/ja.js +1 -0
- package/lib/locales/ja.js.map +1 -1
- package/lib/locales/ko.d.ts.map +1 -1
- package/lib/locales/ko.js +1 -0
- package/lib/locales/ko.js.map +1 -1
- package/lib/locales/nl.d.ts.map +1 -1
- package/lib/locales/nl.js +1 -0
- package/lib/locales/nl.js.map +1 -1
- package/lib/locales/pl.d.ts.map +1 -1
- package/lib/locales/pl.js +1 -0
- package/lib/locales/pl.js.map +1 -1
- package/lib/locales/pt.d.ts.map +1 -1
- package/lib/locales/pt.js +1 -0
- package/lib/locales/pt.js.map +1 -1
- package/lib/locales/ru.d.ts.map +1 -1
- package/lib/locales/ru.js +1 -0
- package/lib/locales/ru.js.map +1 -1
- package/lib/locales/tr.d.ts.map +1 -1
- package/lib/locales/tr.js +1 -0
- package/lib/locales/tr.js.map +1 -1
- package/lib/locales/zh.d.ts.map +1 -1
- package/lib/locales/zh.js +1 -0
- package/lib/locales/zh.js.map +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import React, { useContext, useMemo } from 'react';
|
|
3
|
+
import { Pressable, StyleSheet, Text, useColorScheme, View } from 'react-native';
|
|
4
|
+
import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
5
|
+
import { ChatContext } from './ChatContext';
|
|
6
|
+
import { ChatListAvatar } from './ChatList/ChatListAvatar';
|
|
7
|
+
import { Icon } from './components/Icon';
|
|
8
|
+
import { TypingStatus } from './components/TypingStatus';
|
|
9
|
+
import { normalizeColorScheme } from './hooks/useColorScheme';
|
|
10
|
+
import { resolveLabels } from './i18n';
|
|
11
|
+
import { isRTLLocale } from './rtl';
|
|
12
|
+
import { resolveTheme } from './Theme';
|
|
13
|
+
const HEADER_HEIGHT = 56;
|
|
14
|
+
const AVATAR_SIZE = 42;
|
|
15
|
+
/**
|
|
16
|
+
* A chat screen's top bar, as a messenger draws it: back arrow, a 42 avatar, the name in 18 medium
|
|
17
|
+
* with a 14 status line under it ("online" and "typing" in the accent color), and buttons at the
|
|
18
|
+
* end. Colors come from `theme.chatList` (`headerBackground`, `headerText`, `headerSubtitle`,
|
|
19
|
+
* `headerSubtitleActive`), so it matches `ChatList`'s header.
|
|
20
|
+
*/
|
|
21
|
+
export function ChatHeader(props) {
|
|
22
|
+
const $ = _c(35);
|
|
23
|
+
const {
|
|
24
|
+
theme,
|
|
25
|
+
darkTheme,
|
|
26
|
+
colorScheme: colorSchemeProp,
|
|
27
|
+
locale,
|
|
28
|
+
labels,
|
|
29
|
+
icons
|
|
30
|
+
} = props;
|
|
31
|
+
const systemColorScheme = useColorScheme();
|
|
32
|
+
const t0 = colorSchemeProp !== undefined ? colorSchemeProp : systemColorScheme;
|
|
33
|
+
let t1;
|
|
34
|
+
if ($[0] !== t0) {
|
|
35
|
+
t1 = normalizeColorScheme(t0);
|
|
36
|
+
$[0] = t0;
|
|
37
|
+
$[1] = t1;
|
|
38
|
+
} else {
|
|
39
|
+
t1 = $[1];
|
|
40
|
+
}
|
|
41
|
+
const colorScheme = t1;
|
|
42
|
+
let t2;
|
|
43
|
+
if ($[2] !== colorScheme || $[3] !== darkTheme || $[4] !== theme) {
|
|
44
|
+
t2 = resolveTheme(colorScheme, theme, darkTheme);
|
|
45
|
+
$[2] = colorScheme;
|
|
46
|
+
$[3] = darkTheme;
|
|
47
|
+
$[4] = theme;
|
|
48
|
+
$[5] = t2;
|
|
49
|
+
} else {
|
|
50
|
+
t2 = $[5];
|
|
51
|
+
}
|
|
52
|
+
const resolvedTheme = t2;
|
|
53
|
+
let t3;
|
|
54
|
+
if ($[6] !== labels || $[7] !== locale) {
|
|
55
|
+
t3 = resolveLabels(locale, labels);
|
|
56
|
+
$[6] = labels;
|
|
57
|
+
$[7] = locale;
|
|
58
|
+
$[8] = t3;
|
|
59
|
+
} else {
|
|
60
|
+
t3 = $[8];
|
|
61
|
+
}
|
|
62
|
+
const resolvedLabels = t3;
|
|
63
|
+
let t4;
|
|
64
|
+
if ($[9] !== locale) {
|
|
65
|
+
t4 = isRTLLocale(locale);
|
|
66
|
+
$[9] = locale;
|
|
67
|
+
$[10] = t4;
|
|
68
|
+
} else {
|
|
69
|
+
t4 = $[10];
|
|
70
|
+
}
|
|
71
|
+
const isRTL = t4;
|
|
72
|
+
let t5;
|
|
73
|
+
if ($[11] !== locale) {
|
|
74
|
+
t5 = () => locale ?? "en";
|
|
75
|
+
$[11] = locale;
|
|
76
|
+
$[12] = t5;
|
|
77
|
+
} else {
|
|
78
|
+
t5 = $[12];
|
|
79
|
+
}
|
|
80
|
+
let t6;
|
|
81
|
+
if ($[13] !== isRTL) {
|
|
82
|
+
t6 = () => isRTL;
|
|
83
|
+
$[13] = isRTL;
|
|
84
|
+
$[14] = t6;
|
|
85
|
+
} else {
|
|
86
|
+
t6 = $[14];
|
|
87
|
+
}
|
|
88
|
+
let t7;
|
|
89
|
+
if ($[15] !== colorScheme) {
|
|
90
|
+
t7 = () => colorScheme;
|
|
91
|
+
$[15] = colorScheme;
|
|
92
|
+
$[16] = t7;
|
|
93
|
+
} else {
|
|
94
|
+
t7 = $[16];
|
|
95
|
+
}
|
|
96
|
+
let t8;
|
|
97
|
+
if ($[17] !== resolvedTheme) {
|
|
98
|
+
t8 = () => resolvedTheme;
|
|
99
|
+
$[17] = resolvedTheme;
|
|
100
|
+
$[18] = t8;
|
|
101
|
+
} else {
|
|
102
|
+
t8 = $[18];
|
|
103
|
+
}
|
|
104
|
+
let t9;
|
|
105
|
+
if ($[19] !== icons) {
|
|
106
|
+
t9 = () => icons;
|
|
107
|
+
$[19] = icons;
|
|
108
|
+
$[20] = t9;
|
|
109
|
+
} else {
|
|
110
|
+
t9 = $[20];
|
|
111
|
+
}
|
|
112
|
+
let t10;
|
|
113
|
+
if ($[21] !== resolvedLabels) {
|
|
114
|
+
t10 = () => resolvedLabels;
|
|
115
|
+
$[21] = resolvedLabels;
|
|
116
|
+
$[22] = t10;
|
|
117
|
+
} else {
|
|
118
|
+
t10 = $[22];
|
|
119
|
+
}
|
|
120
|
+
let t11;
|
|
121
|
+
if ($[23] !== t10 || $[24] !== t5 || $[25] !== t6 || $[26] !== t7 || $[27] !== t8 || $[28] !== t9) {
|
|
122
|
+
t11 = {
|
|
123
|
+
actionSheet: _temp2,
|
|
124
|
+
getLocale: t5,
|
|
125
|
+
getIsRTL: t6,
|
|
126
|
+
getColorScheme: t7,
|
|
127
|
+
getTheme: t8,
|
|
128
|
+
getIcons: t9,
|
|
129
|
+
getLabels: t10
|
|
130
|
+
};
|
|
131
|
+
$[23] = t10;
|
|
132
|
+
$[24] = t5;
|
|
133
|
+
$[25] = t6;
|
|
134
|
+
$[26] = t7;
|
|
135
|
+
$[27] = t8;
|
|
136
|
+
$[28] = t9;
|
|
137
|
+
$[29] = t11;
|
|
138
|
+
} else {
|
|
139
|
+
t11 = $[29];
|
|
140
|
+
}
|
|
141
|
+
const context = t11;
|
|
142
|
+
let t12;
|
|
143
|
+
if ($[30] !== props) {
|
|
144
|
+
t12 = <ChatHeaderContent {...props} />;
|
|
145
|
+
$[30] = props;
|
|
146
|
+
$[31] = t12;
|
|
147
|
+
} else {
|
|
148
|
+
t12 = $[31];
|
|
149
|
+
}
|
|
150
|
+
let t13;
|
|
151
|
+
if ($[32] !== context || $[33] !== t12) {
|
|
152
|
+
t13 = <ChatContext.Provider value={context}>{t12}</ChatContext.Provider>;
|
|
153
|
+
$[32] = context;
|
|
154
|
+
$[33] = t12;
|
|
155
|
+
$[34] = t13;
|
|
156
|
+
} else {
|
|
157
|
+
t13 = $[34];
|
|
158
|
+
}
|
|
159
|
+
return t13;
|
|
160
|
+
}
|
|
161
|
+
function _temp2() {
|
|
162
|
+
return {
|
|
163
|
+
showActionSheetWithOptions: _temp
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function _temp() {}
|
|
167
|
+
function ChatHeaderContent(t0) {
|
|
168
|
+
const $ = _c(41);
|
|
169
|
+
const {
|
|
170
|
+
title,
|
|
171
|
+
subtitle,
|
|
172
|
+
isSubtitleActive: t1,
|
|
173
|
+
typingUsers,
|
|
174
|
+
typingAction,
|
|
175
|
+
isGroup: t2,
|
|
176
|
+
avatar,
|
|
177
|
+
onBack,
|
|
178
|
+
onPressTitle,
|
|
179
|
+
renderRight,
|
|
180
|
+
renderTitle,
|
|
181
|
+
isTopInsetApplied: t3,
|
|
182
|
+
style
|
|
183
|
+
} = t0;
|
|
184
|
+
const isSubtitleActive = t1 === undefined ? false : t1;
|
|
185
|
+
const isGroup = t2 === undefined ? false : t2;
|
|
186
|
+
const isTopInsetApplied = t3 === undefined ? true : t3;
|
|
187
|
+
const {
|
|
188
|
+
getTheme,
|
|
189
|
+
getLabels
|
|
190
|
+
} = useContext(ChatContext);
|
|
191
|
+
let t4;
|
|
192
|
+
if ($[0] !== getTheme) {
|
|
193
|
+
t4 = getTheme();
|
|
194
|
+
$[0] = getTheme;
|
|
195
|
+
$[1] = t4;
|
|
196
|
+
} else {
|
|
197
|
+
t4 = $[1];
|
|
198
|
+
}
|
|
199
|
+
const colors = t4.chatList;
|
|
200
|
+
let t5;
|
|
201
|
+
if ($[2] !== getLabels) {
|
|
202
|
+
t5 = getLabels();
|
|
203
|
+
$[2] = getLabels;
|
|
204
|
+
$[3] = t5;
|
|
205
|
+
} else {
|
|
206
|
+
t5 = $[3];
|
|
207
|
+
}
|
|
208
|
+
const labels = t5;
|
|
209
|
+
const insets = useContext(SafeAreaInsetsContext);
|
|
210
|
+
const topInset = isTopInsetApplied ? insets?.top ?? 0 : 0;
|
|
211
|
+
const isTyping = !!typingUsers?.length;
|
|
212
|
+
let t6;
|
|
213
|
+
if ($[4] !== colors.headerSubtitle || $[5] !== colors.headerSubtitleActive || $[6] !== colors.headerText || $[7] !== isGroup || $[8] !== isSubtitleActive || $[9] !== isTyping || $[10] !== subtitle || $[11] !== title || $[12] !== typingAction || $[13] !== typingUsers) {
|
|
214
|
+
t6 = () => <View style={styles.text}><Text style={[styles.title, {
|
|
215
|
+
color: colors.headerText
|
|
216
|
+
}]} numberOfLines={1}>{title}</Text>{isTyping ? <TypingStatus users={typingUsers} action={typingAction} isGroup={isGroup} color={colors.headerSubtitleActive} textStyle={styles.subtitle} /> : !!subtitle && <Text style={[styles.subtitle, {
|
|
217
|
+
color: isSubtitleActive ? colors.headerSubtitleActive : colors.headerSubtitle
|
|
218
|
+
}]} numberOfLines={1}>{subtitle}</Text>}</View>;
|
|
219
|
+
$[4] = colors.headerSubtitle;
|
|
220
|
+
$[5] = colors.headerSubtitleActive;
|
|
221
|
+
$[6] = colors.headerText;
|
|
222
|
+
$[7] = isGroup;
|
|
223
|
+
$[8] = isSubtitleActive;
|
|
224
|
+
$[9] = isTyping;
|
|
225
|
+
$[10] = subtitle;
|
|
226
|
+
$[11] = title;
|
|
227
|
+
$[12] = typingAction;
|
|
228
|
+
$[13] = typingUsers;
|
|
229
|
+
$[14] = t6;
|
|
230
|
+
} else {
|
|
231
|
+
t6 = $[14];
|
|
232
|
+
}
|
|
233
|
+
const renderText = t6;
|
|
234
|
+
let t7;
|
|
235
|
+
if ($[15] !== colors.headerBackground || $[16] !== topInset) {
|
|
236
|
+
t7 = {
|
|
237
|
+
paddingTop: topInset,
|
|
238
|
+
backgroundColor: colors.headerBackground
|
|
239
|
+
};
|
|
240
|
+
$[15] = colors.headerBackground;
|
|
241
|
+
$[16] = topInset;
|
|
242
|
+
$[17] = t7;
|
|
243
|
+
} else {
|
|
244
|
+
t7 = $[17];
|
|
245
|
+
}
|
|
246
|
+
let t8;
|
|
247
|
+
if ($[18] !== style || $[19] !== t7) {
|
|
248
|
+
t8 = [styles.header, t7, style];
|
|
249
|
+
$[18] = style;
|
|
250
|
+
$[19] = t7;
|
|
251
|
+
$[20] = t8;
|
|
252
|
+
} else {
|
|
253
|
+
t8 = $[20];
|
|
254
|
+
}
|
|
255
|
+
let t9;
|
|
256
|
+
if ($[21] !== colors.headerText || $[22] !== labels || $[23] !== onBack) {
|
|
257
|
+
t9 = onBack ? <Pressable onPress={onBack} hitSlop={4} style={styles.button} accessibilityRole="button" accessibilityLabel={labels.chatListBack}><Icon name="arrowLeft" size={24} color={colors.headerText} fallback={<Text style={{
|
|
258
|
+
color: colors.headerText
|
|
259
|
+
}}>{"<"}</Text>} /></Pressable> : <View style={styles.edge} />;
|
|
260
|
+
$[21] = colors.headerText;
|
|
261
|
+
$[22] = labels;
|
|
262
|
+
$[23] = onBack;
|
|
263
|
+
$[24] = t9;
|
|
264
|
+
} else {
|
|
265
|
+
t9 = $[24];
|
|
266
|
+
}
|
|
267
|
+
let t10;
|
|
268
|
+
if ($[25] !== avatar || $[26] !== colors.headerBackground || $[27] !== onPressTitle || $[28] !== renderText || $[29] !== renderTitle || $[30] !== title) {
|
|
269
|
+
t10 = renderTitle ? <View style={styles.titleArea}>{renderTitle()}</View> : <Pressable onPress={onPressTitle} disabled={!onPressTitle} style={styles.titleArea} accessibilityRole={onPressTitle ? "button" : undefined}>{!!avatar && <View style={styles.avatar}><ChatListAvatar id={avatar.id} title={title} uri={avatar.uri} size={AVATAR_SIZE} ringColor={colors.headerBackground} /></View>}{renderText()}</Pressable>;
|
|
270
|
+
$[25] = avatar;
|
|
271
|
+
$[26] = colors.headerBackground;
|
|
272
|
+
$[27] = onPressTitle;
|
|
273
|
+
$[28] = renderText;
|
|
274
|
+
$[29] = renderTitle;
|
|
275
|
+
$[30] = title;
|
|
276
|
+
$[31] = t10;
|
|
277
|
+
} else {
|
|
278
|
+
t10 = $[31];
|
|
279
|
+
}
|
|
280
|
+
let t11;
|
|
281
|
+
if ($[32] !== renderRight) {
|
|
282
|
+
t11 = renderRight?.();
|
|
283
|
+
$[32] = renderRight;
|
|
284
|
+
$[33] = t11;
|
|
285
|
+
} else {
|
|
286
|
+
t11 = $[33];
|
|
287
|
+
}
|
|
288
|
+
let t12;
|
|
289
|
+
if ($[34] !== t10 || $[35] !== t11 || $[36] !== t9) {
|
|
290
|
+
t12 = <View style={styles.bar}>{t9}{t10}{t11}</View>;
|
|
291
|
+
$[34] = t10;
|
|
292
|
+
$[35] = t11;
|
|
293
|
+
$[36] = t9;
|
|
294
|
+
$[37] = t12;
|
|
295
|
+
} else {
|
|
296
|
+
t12 = $[37];
|
|
297
|
+
}
|
|
298
|
+
let t13;
|
|
299
|
+
if ($[38] !== t12 || $[39] !== t8) {
|
|
300
|
+
t13 = <View style={t8}>{t12}</View>;
|
|
301
|
+
$[38] = t12;
|
|
302
|
+
$[39] = t8;
|
|
303
|
+
$[40] = t13;
|
|
304
|
+
} else {
|
|
305
|
+
t13 = $[40];
|
|
306
|
+
}
|
|
307
|
+
return t13;
|
|
308
|
+
}
|
|
309
|
+
const styles = StyleSheet.create({
|
|
310
|
+
header: {
|
|
311
|
+
zIndex: 1,
|
|
312
|
+
boxShadow: '0 0.5px 0 rgba(0, 0, 0, 0.12)'
|
|
313
|
+
},
|
|
314
|
+
bar: {
|
|
315
|
+
height: HEADER_HEIGHT,
|
|
316
|
+
flexDirection: 'row',
|
|
317
|
+
alignItems: 'center',
|
|
318
|
+
paddingHorizontal: 4
|
|
319
|
+
},
|
|
320
|
+
button: {
|
|
321
|
+
width: 48,
|
|
322
|
+
height: 48,
|
|
323
|
+
alignItems: 'center',
|
|
324
|
+
justifyContent: 'center'
|
|
325
|
+
},
|
|
326
|
+
edge: {
|
|
327
|
+
width: 10
|
|
328
|
+
},
|
|
329
|
+
titleArea: {
|
|
330
|
+
flex: 1,
|
|
331
|
+
alignSelf: 'stretch',
|
|
332
|
+
flexDirection: 'row',
|
|
333
|
+
alignItems: 'center'
|
|
334
|
+
},
|
|
335
|
+
avatar: {
|
|
336
|
+
marginStart: 4
|
|
337
|
+
},
|
|
338
|
+
// The text starts 55 after the avatar's left edge: 42 + 13.
|
|
339
|
+
text: {
|
|
340
|
+
flex: 1,
|
|
341
|
+
marginStart: 13,
|
|
342
|
+
justifyContent: 'center'
|
|
343
|
+
},
|
|
344
|
+
title: {
|
|
345
|
+
flexShrink: 1,
|
|
346
|
+
fontSize: 18,
|
|
347
|
+
fontWeight: '500',
|
|
348
|
+
textAlign: 'left'
|
|
349
|
+
},
|
|
350
|
+
subtitle: {
|
|
351
|
+
fontSize: 14,
|
|
352
|
+
marginTop: 1,
|
|
353
|
+
textAlign: 'left'
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
//# sourceMappingURL=ChatHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatHeader.js","names":["React","useContext","useMemo","Pressable","StyleSheet","Text","useColorScheme","View","SafeAreaInsetsContext","ChatContext","ChatListAvatar","Icon","TypingStatus","normalizeColorScheme","resolveLabels","isRTLLocale","resolveTheme","HEADER_HEIGHT","AVATAR_SIZE","ChatHeader","props","$","_c","theme","darkTheme","colorScheme","colorSchemeProp","locale","labels","icons","systemColorScheme","t0","undefined","t1","t2","resolvedTheme","t3","resolvedLabels","t4","isRTL","t5","t6","t7","t8","t9","t10","t11","actionSheet","_temp2","getLocale","getIsRTL","getColorScheme","getTheme","getIcons","getLabels","context","t12","t13","showActionSheetWithOptions","_temp","ChatHeaderContent","title","subtitle","isSubtitleActive","typingUsers","typingAction","isGroup","avatar","onBack","onPressTitle","renderRight","renderTitle","isTopInsetApplied","style","colors","chatList","insets","topInset","top","isTyping","length","headerSubtitle","headerSubtitleActive","headerText","styles","text","color","renderText","headerBackground","paddingTop","backgroundColor","header","button","chatListBack","edge","titleArea","id","uri","bar","create","zIndex","boxShadow","height","flexDirection","alignItems","paddingHorizontal","width","justifyContent","flex","alignSelf","marginStart","flexShrink","fontSize","fontWeight","textAlign","marginTop"],"sources":["../src/ChatHeader.tsx"],"sourcesContent":["import React, { ReactNode, useContext, useMemo } from 'react'\nimport { ColorSchemeName, Pressable, StyleProp, StyleSheet, Text, useColorScheme, View, ViewStyle } from 'react-native'\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context'\n\nimport { ChatContext, IChatContext } from './ChatContext'\nimport { ChatListAvatar } from './ChatList/ChatListAvatar'\nimport { Icon } from './components/Icon'\nimport { TypingAction, TypingStatus } from './components/TypingStatus'\nimport { normalizeColorScheme } from './hooks/useColorScheme'\nimport { ChatLabels, resolveLabels } from './i18n'\nimport { ChatIcons } from './Icons'\nimport { User } from './Models'\nimport { isRTLLocale } from './rtl'\nimport { PartialChatTheme, resolveTheme } from './Theme'\n\nconst HEADER_HEIGHT = 56\nconst AVATAR_SIZE = 42\n\nexport interface ChatHeaderProps {\n /** The chat's name, on one line. */\n title: string\n /** The line under the name: \"online\", \"last seen recently\", \"3 members\"... */\n subtitle?: string\n /** Draws the subtitle in the accent color, as for \"online\". */\n isSubtitleActive?: boolean\n /** Shown in place of the subtitle while someone types: \"typing\", \"Anna is typing\"... */\n typingUsers?: User[]\n typingAction?: TypingAction\n /** Names the people typing, as a group does. */\n isGroup?: boolean\n /** The avatar: a photo, or initials on the chat's color picked by `id`. Hidden without it. */\n avatar?: { id: string | number, uri?: string }\n /** Shows the back arrow. */\n onBack?: () => void\n /** Makes the avatar and the name a button, e.g. to open the profile. */\n onPressTitle?: () => void\n /** Buttons at the end of the bar: a call, a menu. */\n renderRight?: () => ReactNode\n /** Replaces the name and the subtitle, e.g. with a search field. */\n renderTitle?: () => ReactNode\n /** Pads the bar by the top safe-area inset. Default true; turn off when it sits below the status bar already. */\n isTopInsetApplied?: boolean\n style?: StyleProp<ViewStyle>\n theme?: PartialChatTheme\n darkTheme?: PartialChatTheme\n colorScheme?: ColorSchemeName\n locale?: string\n labels?: Partial<ChatLabels>\n icons?: ChatIcons\n}\n\n/**\n * A chat screen's top bar, as a messenger draws it: back arrow, a 42 avatar, the name in 18 medium\n * with a 14 status line under it (\"online\" and \"typing\" in the accent color), and buttons at the\n * end. Colors come from `theme.chatList` (`headerBackground`, `headerText`, `headerSubtitle`,\n * `headerSubtitleActive`), so it matches `ChatList`'s header.\n */\nexport function ChatHeader (props: ChatHeaderProps) {\n const { theme, darkTheme, colorScheme: colorSchemeProp, locale, labels, icons } = props\n const systemColorScheme = useColorScheme()\n const colorScheme = normalizeColorScheme(colorSchemeProp !== undefined ? colorSchemeProp : systemColorScheme)\n const resolvedTheme = useMemo(() => resolveTheme(colorScheme, theme, darkTheme), [colorScheme, theme, darkTheme])\n const resolvedLabels = useMemo(() => resolveLabels(locale, labels), [locale, labels])\n const isRTL = useMemo(() => isRTLLocale(locale), [locale])\n const context = useMemo<IChatContext>(() => ({\n actionSheet: () => ({ showActionSheetWithOptions: () => {} }),\n getLocale: () => locale ?? 'en',\n getIsRTL: () => isRTL,\n getColorScheme: () => colorScheme,\n getTheme: () => resolvedTheme,\n getIcons: () => icons,\n getLabels: () => resolvedLabels,\n }), [locale, isRTL, colorScheme, resolvedTheme, icons, resolvedLabels])\n\n return (\n <ChatContext.Provider value={context}>\n <ChatHeaderContent {...props} />\n </ChatContext.Provider>\n )\n}\n\nfunction ChatHeaderContent ({\n title,\n subtitle,\n isSubtitleActive = false,\n typingUsers,\n typingAction,\n isGroup = false,\n avatar,\n onBack,\n onPressTitle,\n renderRight,\n renderTitle,\n isTopInsetApplied = true,\n style,\n}: ChatHeaderProps) {\n const { getTheme, getLabels } = useContext(ChatContext)\n const colors = getTheme!()!.chatList\n const labels = getLabels!()!\n const insets = useContext(SafeAreaInsetsContext)\n const topInset = isTopInsetApplied ? insets?.top ?? 0 : 0\n const isTyping = !!typingUsers?.length\n\n const renderText = () => (\n <View style={styles.text}>\n <Text style={[styles.title, { color: colors.headerText }]} numberOfLines={1}>{title}</Text>\n {isTyping\n ? <TypingStatus users={typingUsers!} action={typingAction} isGroup={isGroup} color={colors.headerSubtitleActive} textStyle={styles.subtitle} />\n : !!subtitle && (\n <Text\n style={[styles.subtitle, { color: isSubtitleActive ? colors.headerSubtitleActive : colors.headerSubtitle }]}\n numberOfLines={1}\n >\n {subtitle}\n </Text>\n )}\n </View>\n )\n\n return (\n <View style={[styles.header, { paddingTop: topInset, backgroundColor: colors.headerBackground }, style]}>\n <View style={styles.bar}>\n {onBack\n ? (\n <Pressable onPress={onBack} hitSlop={4} style={styles.button} accessibilityRole='button' accessibilityLabel={labels.chatListBack}>\n <Icon name='arrowLeft' size={24} color={colors.headerText} fallback={<Text style={{ color: colors.headerText }}>{'<'}</Text>} />\n </Pressable>\n )\n : <View style={styles.edge} />}\n {renderTitle\n ? <View style={styles.titleArea}>{renderTitle()}</View>\n : (\n <Pressable\n onPress={onPressTitle}\n disabled={!onPressTitle}\n style={styles.titleArea}\n accessibilityRole={onPressTitle ? 'button' : undefined}\n >\n {!!avatar && (\n <View style={styles.avatar}>\n <ChatListAvatar id={avatar.id} title={title} uri={avatar.uri} size={AVATAR_SIZE} ringColor={colors.headerBackground} />\n </View>\n )}\n {renderText()}\n </Pressable>\n )}\n {renderRight?.()}\n </View>\n </View>\n )\n}\n\nconst styles = StyleSheet.create({\n header: {\n zIndex: 1,\n boxShadow: '0 0.5px 0 rgba(0, 0, 0, 0.12)',\n },\n bar: {\n height: HEADER_HEIGHT,\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 4,\n },\n button: {\n width: 48,\n height: 48,\n alignItems: 'center',\n justifyContent: 'center',\n },\n edge: {\n width: 10,\n },\n titleArea: {\n flex: 1,\n alignSelf: 'stretch',\n flexDirection: 'row',\n alignItems: 'center',\n },\n avatar: {\n marginStart: 4,\n },\n // The text starts 55 after the avatar's left edge: 42 + 13.\n text: {\n flex: 1,\n marginStart: 13,\n justifyContent: 'center',\n },\n title: {\n flexShrink: 1,\n fontSize: 18,\n fontWeight: '500',\n textAlign: 'left',\n },\n subtitle: {\n fontSize: 14,\n marginTop: 1,\n textAlign: 'left',\n },\n})\n"],"mappings":";AAAA,OAAOA,KAAK,IAAeC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC7D,SAA0BC,SAAS,EAAaC,UAAU,EAAEC,IAAI,EAAEC,cAAc,EAAEC,IAAI,QAAmB,cAAc;AACvH,SAASC,qBAAqB,QAAQ,gCAAgC;AAEtE,SAASC,WAAW,QAAsB,eAAe;AACzD,SAASC,cAAc,QAAQ,2BAA2B;AAC1D,SAASC,IAAI,QAAQ,mBAAmB;AACxC,SAAuBC,YAAY,QAAQ,2BAA2B;AACtE,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAAqBC,aAAa,QAAQ,QAAQ;AAGlD,SAASC,WAAW,QAAQ,OAAO;AACnC,SAA2BC,YAAY,QAAQ,SAAS;AAExD,MAAMC,aAAa,GAAG,EAAE;AACxB,MAAMC,WAAW,GAAG,EAAE;AAmCtB;A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;EACDrC,MAAM,EAAE;IACN2C,WAAW,EAAE;EACf,CAAC;EACD;EACAzB,IAAI,EAAE;IACJuB,IAAI,EAAE,CAAC;IACPE,WAAW,EAAE,EAAE;IACfH,cAAc,EAAE;EAClB,CAAC;EACD9C,KAAK,EAAE;IACLkD,UAAU,EAAE,CAAC;IACbC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjBC,SAAS,EAAE;EACb,CAAC;EACDpD,QAAQ,EAAE;IACRkD,QAAQ,EAAE,EAAE;IACZG,SAAS,EAAE,CAAC;IACZD,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ export declare const CHAT_LIST_ROW_HEIGHT = 70;
|
|
|
5
5
|
* A chat's row: avatar, name, time, the last message (or a draft, or who is typing), the unread
|
|
6
6
|
* counter or pin, a swipe to archive, and dragging when pinned chats can be reordered.
|
|
7
7
|
*/
|
|
8
|
-
declare function ChatListCellInner<TChat extends ChatListItem>({ chat, user, isSelected, isSelectionMode, onPress, onLongPress, onSwipe, isLast, reorder, isReordering, }: ChatListCellProps<TChat>): React.JSX.Element;
|
|
8
|
+
declare function ChatListCellInner<TChat extends ChatListItem>({ chat, user, isSelected, isSelectionMode, onPress, onLongPress, onSwipe, isLast, reorder, isReordering, timeFormat, dateFormat, }: ChatListCellProps<TChat>): React.JSX.Element;
|
|
9
9
|
/**
|
|
10
10
|
* A chat's row: avatar, name, time, the last message (or a draft, or who is typing), the unread
|
|
11
11
|
* counter or pin, a swipe to archive, and dragging when pinned chats can be reordered. Rows only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatListCell.d.ts","sourceRoot":"","sources":["../../src/ChatList/ChatListCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAuBxD,OAAO,EAAE,iBAAiB,EAAgB,YAAY,EAAE,MAAM,SAAS,CAAA;AAIvE,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAgCtC;;;GAGG;AACH,iBAAS,iBAAiB,CAAC,KAAK,SAAS,YAAY,EAAG,EACtD,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,eAAe,EACf,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,EACN,OAAO,EACP,YAAoB,
|
|
1
|
+
{"version":3,"file":"ChatListCell.d.ts","sourceRoot":"","sources":["../../src/ChatList/ChatListCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAA;AAuBxD,OAAO,EAAE,iBAAiB,EAAgB,YAAY,EAAE,MAAM,SAAS,CAAA;AAIvE,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAgCtC;;;GAGG;AACH,iBAAS,iBAAiB,CAAC,KAAK,SAAS,YAAY,EAAG,EACtD,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,eAAe,EACf,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,EACN,OAAO,EACP,YAAoB,EACpB,UAAU,EACV,UAAU,GACX,EAAE,iBAAiB,CAAC,KAAK,CAAC,qBAgS1B;AAqBD;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAsD,OAAO,iBAAiB,CAAA"}
|
|
@@ -75,7 +75,9 @@ function ChatListCellInner({
|
|
|
75
75
|
onSwipe,
|
|
76
76
|
isLast,
|
|
77
77
|
reorder,
|
|
78
|
-
isReordering = false
|
|
78
|
+
isReordering = false,
|
|
79
|
+
timeFormat,
|
|
80
|
+
dateFormat
|
|
79
81
|
}) {
|
|
80
82
|
// The gesture callbacks read shared values; React Compiler would memoize them into render.
|
|
81
83
|
'use no memo';
|
|
@@ -90,6 +92,13 @@ function ChatListCellInner({
|
|
|
90
92
|
width
|
|
91
93
|
} = useWindowDimensions();
|
|
92
94
|
|
|
95
|
+
// The worklets below call these JS functions with no arguments. Handing `chat` itself to a worklet
|
|
96
|
+
// would copy the whole item to the UI thread, which fails on anything it cannot copy (a Date in
|
|
97
|
+
// `lastMessage.createdAt`, an app's own objects) - so the row's chat stays here, on the JS side.
|
|
98
|
+
const swipeChat = () => onSwipe?.(chat);
|
|
99
|
+
const startDrag = () => reorder?.onStart?.(chat);
|
|
100
|
+
const dropChat = to => reorder?.onDrop?.(chat, to);
|
|
101
|
+
|
|
93
102
|
// The row swipes towards the start edge, revealing the action at the end.
|
|
94
103
|
const direction = I18nManager.isRTL ? 1 : -1;
|
|
95
104
|
const reveal = useSharedValue(0);
|
|
@@ -120,7 +129,7 @@ function ChatListCellInner({
|
|
|
120
129
|
const isFling = velocity > SWIPE_ESCAPE_VELOCITY;
|
|
121
130
|
if (onSwipe && (isPast || isFling)) {
|
|
122
131
|
rowOffset.value = withTiming(width * direction, SWIPE_CANCEL, isFinished => {
|
|
123
|
-
if (isFinished) runOnJS(
|
|
132
|
+
if (isFinished) runOnJS(swipeChat)();
|
|
124
133
|
});
|
|
125
134
|
return;
|
|
126
135
|
}
|
|
@@ -145,7 +154,7 @@ function ChatListCellInner({
|
|
|
145
154
|
drag.from.set(index);
|
|
146
155
|
drag.y.set(0);
|
|
147
156
|
drag.isActive.set(true);
|
|
148
|
-
if (onDragStart) runOnJS(
|
|
157
|
+
if (onDragStart) runOnJS(startDrag)();
|
|
149
158
|
},
|
|
150
159
|
onUpdate: event => {
|
|
151
160
|
if (!drag) return;
|
|
@@ -156,9 +165,9 @@ function ChatListCellInner({
|
|
|
156
165
|
},
|
|
157
166
|
onDeactivate: () => {
|
|
158
167
|
if (!drag || drag.id.value !== chatKey) return;
|
|
159
|
-
const
|
|
160
|
-
drag.y.set(withTiming((
|
|
161
|
-
if (onDrop) runOnJS(
|
|
168
|
+
const to_0 = hoverIndex(drag, count);
|
|
169
|
+
drag.y.set(withTiming((to_0 - index) * ROW_HEIGHT, SETTLE, () => {
|
|
170
|
+
if (onDrop) runOnJS(dropChat)(to_0);
|
|
162
171
|
}));
|
|
163
172
|
}
|
|
164
173
|
});
|
|
@@ -170,8 +179,8 @@ function ChatListCellInner({
|
|
|
170
179
|
let target = 0;
|
|
171
180
|
if (drag && drag.isActive.value && drag.id.value !== chatKey) {
|
|
172
181
|
const from = drag.from.value;
|
|
173
|
-
const
|
|
174
|
-
if (from < index && index <=
|
|
182
|
+
const to_1 = hoverIndex(drag, count);
|
|
183
|
+
if (from < index && index <= to_1) target = -ROW_HEIGHT;else if (to_1 <= index && index < from) target = ROW_HEIGHT;
|
|
175
184
|
}
|
|
176
185
|
if (target === lastTarget.value) return;
|
|
177
186
|
lastTarget.value = target;
|
|
@@ -271,11 +280,20 @@ function ChatListCellInner({
|
|
|
271
280
|
</View>}
|
|
272
281
|
</View>
|
|
273
282
|
{isOutgoing && !chat.draft && <View style={styles.checks}>
|
|
274
|
-
|
|
283
|
+
{lastMessage?.isFailed
|
|
284
|
+
// Not sent: the bubble's red badge, not a check that reads as delivered
|
|
285
|
+
? <View testID='chat-list-failed-badge' style={[styles.failed, {
|
|
286
|
+
backgroundColor: theme.colors.error
|
|
287
|
+
}]}>
|
|
288
|
+
<Text style={styles.failedText} allowFontScaling={false}>!</Text>
|
|
289
|
+
</View> : <Icon name={statusIcon} size={16} color={colors.check} fallback={null} />}
|
|
275
290
|
</View>}
|
|
276
291
|
{lastMessage?.createdAt != null && <Text style={[styles.time, {
|
|
277
292
|
color: colors.date
|
|
278
|
-
}]}>{formatChatListDate(lastMessage.createdAt, getLocale()
|
|
293
|
+
}]}>{formatChatListDate(lastMessage.createdAt, getLocale(), {
|
|
294
|
+
timeFormat,
|
|
295
|
+
dateFormat
|
|
296
|
+
})}</Text>}
|
|
279
297
|
</View>
|
|
280
298
|
|
|
281
299
|
<View style={styles.bottomLine}>
|
|
@@ -337,7 +355,7 @@ function ChatListCellInner({
|
|
|
337
355
|
|
|
338
356
|
/** The drag props are rebuilt with the list; what matters is what they say. */
|
|
339
357
|
const isSameReorder = (a, b) => a === b || !!a && !!b && a.index === b.index && a.count === b.count && a.drag === b.drag && a.onStart === b.onStart && a.onDrop === b.onDrop;
|
|
340
|
-
const arePropsEqual = (previous, next) => previous.chat === next.chat && previous.user === next.user && previous.isSelected === next.isSelected && previous.isSelectionMode === next.isSelectionMode && previous.onPress === next.onPress && previous.onLongPress === next.onLongPress && previous.onSwipe === next.onSwipe && previous.isLast === next.isLast && previous.isReordering === next.isReordering && isSameReorder(previous.reorder, next.reorder);
|
|
358
|
+
const arePropsEqual = (previous, next) => previous.chat === next.chat && previous.user === next.user && previous.isSelected === next.isSelected && previous.isSelectionMode === next.isSelectionMode && previous.onPress === next.onPress && previous.onLongPress === next.onLongPress && previous.onSwipe === next.onSwipe && previous.isLast === next.isLast && previous.isReordering === next.isReordering && previous.timeFormat === next.timeFormat && previous.dateFormat === next.dateFormat && isSameReorder(previous.reorder, next.reorder);
|
|
341
359
|
|
|
342
360
|
/**
|
|
343
361
|
* A chat's row: avatar, name, time, the last message (or a draft, or who is typing), the unread
|
|
@@ -427,6 +445,19 @@ const styles = StyleSheet.create({
|
|
|
427
445
|
nameIcon: {
|
|
428
446
|
marginStart: 4
|
|
429
447
|
},
|
|
448
|
+
failed: {
|
|
449
|
+
width: 14,
|
|
450
|
+
height: 14,
|
|
451
|
+
borderRadius: 7,
|
|
452
|
+
alignItems: 'center',
|
|
453
|
+
justifyContent: 'center'
|
|
454
|
+
},
|
|
455
|
+
failedText: {
|
|
456
|
+
color: '#FFFFFF',
|
|
457
|
+
fontSize: 10,
|
|
458
|
+
lineHeight: 12,
|
|
459
|
+
fontWeight: '700'
|
|
460
|
+
},
|
|
430
461
|
// The checks sit 5 before the time.
|
|
431
462
|
checks: {
|
|
432
463
|
marginStart: 6,
|