react-native-gifted-chat 2.8.2-alpha.4 → 2.8.2-alpha.6
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/CHANGELOG_2.8.1_to_2.8.2-alpha.5.md +374 -0
- package/package.json +1 -1
- package/src/GiftedChat/index.tsx +6 -11
- package/src/LoadEarlierMessages.tsx +47 -50
- package/src/MessageContainer/components/DayAnimated/index.tsx +1 -0
- package/src/MessageContainer/index.tsx +5 -5
- package/src/MessageText.tsx +2 -1
- package/src/SystemMessage.tsx +29 -23
- package/src/__tests__/__snapshots__/Actions.test.tsx.snap +61 -57
- package/src/__tests__/__snapshots__/Bubble.test.tsx.snap +0 -1
- package/src/__tests__/__snapshots__/GiftedChat.test.tsx.snap +56 -36
- package/src/__tests__/__snapshots__/LoadEarlier.test.tsx.snap +64 -52
- package/src/__tests__/__snapshots__/Message.test.tsx.snap +0 -3
- package/src/__tests__/__snapshots__/MessageText.test.tsx.snap +0 -1
- package/src/__tests__/__snapshots__/Send.test.tsx.snap +120 -108
- package/src/__tests__/__snapshots__/SystemMessage.test.tsx.snap +38 -8
- package/src/components/TouchableOpacity.tsx +26 -15
- package/src/LoadEarlier.tsx +0 -95
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
# Changelog: v2.8.1 to v2.8.2-alpha.5
|
|
2
|
+
|
|
3
|
+
## 🚨 BREAKING CHANGES
|
|
4
|
+
|
|
5
|
+
### Removed Dependencies
|
|
6
|
+
- **Removed `react-native-lightbox-v2`**: The library now uses a custom Modal implementation for viewing images
|
|
7
|
+
- ❌ Removed prop: `lightboxProps` from `MessageImageProps`
|
|
8
|
+
- ❌ Removed prop: `lightboxProps` from `GiftedChatProps`
|
|
9
|
+
- The image viewer now uses `react-native-zoom-reanimated` for zoom functionality
|
|
10
|
+
|
|
11
|
+
### New Required Peer Dependencies
|
|
12
|
+
- ✅ **`react-native-gesture-handler`** (>=2.0.0) - now required
|
|
13
|
+
- ✅ **`react-native-safe-area-context`** (>=5.0.0) - now required
|
|
14
|
+
- Updated **`react-native-reanimated`** peer dependency to support both v3 and v4 (>=3.0.0 || ^4.0.0)
|
|
15
|
+
|
|
16
|
+
### Renamed Props (GiftedChatProps)
|
|
17
|
+
|
|
18
|
+
#### Action Sheet Props
|
|
19
|
+
- ❌ `options` → ✅ `actions` (type changed from `{ [key: string]: () => void }` to `Array<{ title: string, action: () => void }>`)
|
|
20
|
+
- ❌ `optionTintColor` → ✅ `actionSheetOptionTintColor`
|
|
21
|
+
|
|
22
|
+
#### Keyboard Props
|
|
23
|
+
- ❌ `bottomOffset` → ✅ `keyboardBottomOffset`
|
|
24
|
+
|
|
25
|
+
#### Message Event Handlers
|
|
26
|
+
- ❌ `onPress` → ✅ `onPressMessage`
|
|
27
|
+
- ❌ `onLongPress` → ✅ `onLongPressMessage`
|
|
28
|
+
|
|
29
|
+
#### LoadEarlier Component
|
|
30
|
+
- ❌ `LoadEarlier` → ✅ `LoadEarlierMessages` (component renamed)
|
|
31
|
+
- ❌ `LoadEarlierProps` → ✅ `LoadEarlierMessagesProps` (type renamed)
|
|
32
|
+
|
|
33
|
+
### Removed Props (GiftedChatProps)
|
|
34
|
+
|
|
35
|
+
#### Keyboard & Input Props
|
|
36
|
+
- ❌ `keyboardShouldPersistTaps` - removed (keyboard handling is now managed internally)
|
|
37
|
+
- ❌ `maxInputLength` - removed (use `textInputProps.maxLength` instead)
|
|
38
|
+
- ❌ `placeholder` - removed (use `textInputProps.placeholder` instead)
|
|
39
|
+
- ❌ `disableComposer` - removed (use `textInputProps.editable={false}` instead)
|
|
40
|
+
|
|
41
|
+
#### Load Earlier Props
|
|
42
|
+
- ❌ `loadEarlier` - removed from GiftedChatProps (use `loadEarlierMessagesProps.isAvailable` instead)
|
|
43
|
+
- ❌ `isLoadingEarlier` - removed from GiftedChatProps (use `loadEarlierMessagesProps.isLoading` instead)
|
|
44
|
+
- ❌ `onLoadEarlier` - removed from GiftedChatProps (use `loadEarlierMessagesProps.onPress` instead)
|
|
45
|
+
- ❌ `infiniteScroll` - removed (use `loadEarlierMessagesProps.isInfiniteScrollEnabled` instead)
|
|
46
|
+
|
|
47
|
+
#### ListView Props
|
|
48
|
+
- ❌ `listViewProps` - removed (use `listProps` via MessageContainerProps instead)
|
|
49
|
+
|
|
50
|
+
#### Parse Patterns
|
|
51
|
+
- ❌ `parsePatterns` - removed (replaced with `matchers`)
|
|
52
|
+
|
|
53
|
+
#### Explicit Props Moved to Parent Interface
|
|
54
|
+
The following props were explicitly listed in GiftedChatProps in v2.8.1 but are now only available through the extended `MessageContainerProps`:
|
|
55
|
+
- ❌ `messages` - removed as explicit prop (still available via MessageContainerProps)
|
|
56
|
+
- ❌ `isTyping` - removed as explicit prop (still available via MessageContainerProps)
|
|
57
|
+
- ❌ `inverted` - removed as explicit prop (still available via MessageContainerProps)
|
|
58
|
+
- ❌ `alignTop` - removed as explicit prop (still available via MessageContainerProps)
|
|
59
|
+
- ❌ `isScrollToBottomEnabled` - removed as explicit prop (still available via MessageContainerProps)
|
|
60
|
+
- ❌ `scrollToBottomStyle` - removed as explicit prop (still available via MessageContainerProps)
|
|
61
|
+
- ❌ `extraData` - removed as explicit prop (still available via MessageContainerProps)
|
|
62
|
+
- ❌ `renderMessage` - removed as explicit prop (still available via MessageContainerProps)
|
|
63
|
+
- ❌ `renderFooter` - removed as explicit prop (still available via MessageContainerProps)
|
|
64
|
+
- ❌ `renderChatEmpty` - removed as explicit prop (still available via MessageContainerProps)
|
|
65
|
+
- ❌ `renderDay` - removed as explicit prop (still available via MessageContainerProps)
|
|
66
|
+
- ❌ `renderLoadEarlier` - removed as explicit prop (still available via MessageContainerProps)
|
|
67
|
+
- ❌ `onQuickReply` - removed as explicit prop (still available via MessageContainerProps)
|
|
68
|
+
|
|
69
|
+
**Important:** Since `GiftedChatProps` extends `Partial<MessageContainerProps<TMessage>>` in both versions, all MessageContainerProps are still available on GiftedChat. The difference is they're no longer explicitly redefined in the GiftedChatProps interface.
|
|
70
|
+
|
|
71
|
+
### Removed Props (ComposerProps)
|
|
72
|
+
- ❌ `placeholder` - removed (use `textInputProps.placeholder` instead)
|
|
73
|
+
- ❌ `placeholderTextColor` - removed (use `textInputProps.placeholderTextColor` instead)
|
|
74
|
+
|
|
75
|
+
### Removed Props (InputToolbarProps)
|
|
76
|
+
- ❌ `options` → ✅ `actions` (renamed)
|
|
77
|
+
- ❌ `optionTintColor` → ✅ `actionSheetOptionTintColor` (renamed)
|
|
78
|
+
|
|
79
|
+
### Changed Props (GiftedChatProps)
|
|
80
|
+
|
|
81
|
+
#### Type Changes
|
|
82
|
+
- `textInputProps`: Changed from `object` to `Partial<React.ComponentProps<typeof TextInput>>`
|
|
83
|
+
- Now properly typed with all TextInput props available
|
|
84
|
+
- Use this for `placeholder`, `placeholderTextColor`, `maxLength`, `editable`, etc.
|
|
85
|
+
|
|
86
|
+
#### MessageContainer Props
|
|
87
|
+
- `invertibleScrollViewProps` removed - use individual props instead:
|
|
88
|
+
- `inverted` prop now passed directly
|
|
89
|
+
- Removed `keyboardShouldPersistTaps` (handled internally)
|
|
90
|
+
|
|
91
|
+
#### Link Parsing
|
|
92
|
+
- ❌ `parsePatterns` → ✅ `matchers`
|
|
93
|
+
- Now uses `react-native-autolink` instead of `react-native-parsed-text`
|
|
94
|
+
- See [react-native-autolink documentation](https://github.com/joshswan/react-native-autolink) for matcher configuration
|
|
95
|
+
|
|
96
|
+
### New Props
|
|
97
|
+
|
|
98
|
+
#### GiftedChatProps
|
|
99
|
+
- ✅ `messageTextProps` - Extra props to be passed to the MessageText component
|
|
100
|
+
- ✅ `matchers` - Custom parse patterns for react-native-autolink (replaces `parsePatterns`)
|
|
101
|
+
- ✅ `keyboardBottomOffset` - Distance of the chat from the bottom of the screen (replaces `bottomOffset`)
|
|
102
|
+
- ✅ `actions` - Array of action sheet options (replaces `options`)
|
|
103
|
+
- ✅ `actionSheetOptionTintColor` - Tint color for action sheet (replaces `optionTintColor`)
|
|
104
|
+
|
|
105
|
+
#### IMessage Interface
|
|
106
|
+
- ✅ `location` - Optional location data with latitude and longitude:
|
|
107
|
+
```typescript
|
|
108
|
+
location?: {
|
|
109
|
+
latitude: number
|
|
110
|
+
longitude: number
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 📦 Migration Guide
|
|
115
|
+
|
|
116
|
+
### 1. Install New Dependencies
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Yarn
|
|
120
|
+
yarn add react-native-gesture-handler react-native-safe-area-context
|
|
121
|
+
|
|
122
|
+
# npm
|
|
123
|
+
npm install react-native-gesture-handler react-native-safe-area-context
|
|
124
|
+
|
|
125
|
+
# Expo
|
|
126
|
+
npx expo install react-native-gesture-handler react-native-safe-area-context
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 2. Update Imports
|
|
130
|
+
|
|
131
|
+
If you were importing `LoadEarlier`:
|
|
132
|
+
```typescript
|
|
133
|
+
// Before
|
|
134
|
+
import { LoadEarlier, LoadEarlierProps } from 'react-native-gifted-chat'
|
|
135
|
+
|
|
136
|
+
// After
|
|
137
|
+
import { LoadEarlierMessages, LoadEarlierMessagesProps } from 'react-native-gifted-chat'
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 3. Update Props
|
|
141
|
+
|
|
142
|
+
#### Action Sheet Props
|
|
143
|
+
```typescript
|
|
144
|
+
// Before
|
|
145
|
+
<GiftedChat
|
|
146
|
+
options={{
|
|
147
|
+
'Action 1': () => console.log('Action 1'),
|
|
148
|
+
'Action 2': () => console.log('Action 2'),
|
|
149
|
+
}}
|
|
150
|
+
optionTintColor="#007AFF"
|
|
151
|
+
/>
|
|
152
|
+
|
|
153
|
+
// After
|
|
154
|
+
<GiftedChat
|
|
155
|
+
actions={[
|
|
156
|
+
{ title: 'Action 1', action: () => console.log('Action 1') },
|
|
157
|
+
{ title: 'Action 2', action: () => console.log('Action 2') },
|
|
158
|
+
]}
|
|
159
|
+
actionSheetOptionTintColor="#007AFF"
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### Keyboard Offset
|
|
164
|
+
```typescript
|
|
165
|
+
// Before
|
|
166
|
+
<GiftedChat bottomOffset={50} />
|
|
167
|
+
|
|
168
|
+
// After
|
|
169
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
170
|
+
|
|
171
|
+
function MyChat() {
|
|
172
|
+
const insets = useSafeAreaInsets()
|
|
173
|
+
const tabbarHeight = 50
|
|
174
|
+
const keyboardBottomOffset = insets.bottom + tabbarHeight
|
|
175
|
+
|
|
176
|
+
return <GiftedChat keyboardBottomOffset={keyboardBottomOffset} />
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Message Press Handlers
|
|
181
|
+
```typescript
|
|
182
|
+
// Before
|
|
183
|
+
<GiftedChat
|
|
184
|
+
onPress={(context, message) => console.log('Pressed')}
|
|
185
|
+
onLongPress={(context, message) => console.log('Long pressed')}
|
|
186
|
+
/>
|
|
187
|
+
|
|
188
|
+
// After
|
|
189
|
+
<GiftedChat
|
|
190
|
+
onPressMessage={(context, message) => console.log('Pressed')}
|
|
191
|
+
onLongPressMessage={(context, message) => console.log('Long pressed')}
|
|
192
|
+
/>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Text Input Props
|
|
196
|
+
```typescript
|
|
197
|
+
// Before
|
|
198
|
+
<GiftedChat
|
|
199
|
+
placeholder="Type a message..."
|
|
200
|
+
maxInputLength={1000}
|
|
201
|
+
disableComposer={false}
|
|
202
|
+
/>
|
|
203
|
+
|
|
204
|
+
// After
|
|
205
|
+
<GiftedChat
|
|
206
|
+
textInputProps={{
|
|
207
|
+
placeholder: "Type a message...",
|
|
208
|
+
maxLength: 1000,
|
|
209
|
+
editable: true,
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Load Earlier Messages
|
|
215
|
+
```typescript
|
|
216
|
+
// Before
|
|
217
|
+
<GiftedChat
|
|
218
|
+
loadEarlier={true}
|
|
219
|
+
isLoadingEarlier={isLoading}
|
|
220
|
+
onLoadEarlier={handleLoadEarlier}
|
|
221
|
+
renderLoadEarlier={(props) => <CustomLoadEarlier {...props} />}
|
|
222
|
+
/>
|
|
223
|
+
|
|
224
|
+
// After
|
|
225
|
+
<GiftedChat
|
|
226
|
+
loadEarlierMessagesProps={{
|
|
227
|
+
loadEarlier: true,
|
|
228
|
+
isLoadingEarlier: isLoading,
|
|
229
|
+
onLoadEarlier: handleLoadEarlier,
|
|
230
|
+
renderLoadEarlier: (props) => <CustomLoadEarlier {...props} />,
|
|
231
|
+
}}
|
|
232
|
+
/>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### Link Parsing
|
|
236
|
+
```typescript
|
|
237
|
+
// Before
|
|
238
|
+
<GiftedChat
|
|
239
|
+
parsePatterns={(linkStyle) => [
|
|
240
|
+
{ pattern: /#(\w+)/, style: linkStyle, onPress: (tag) => console.log(tag) },
|
|
241
|
+
]}
|
|
242
|
+
/>
|
|
243
|
+
|
|
244
|
+
// After
|
|
245
|
+
<GiftedChat
|
|
246
|
+
matchers={[
|
|
247
|
+
{
|
|
248
|
+
pattern: /#(\w+)/,
|
|
249
|
+
style: { color: 'blue' },
|
|
250
|
+
onPress: (url, match) => console.log(match),
|
|
251
|
+
},
|
|
252
|
+
]}
|
|
253
|
+
/>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### Lightbox Props (Image Viewer)
|
|
257
|
+
```typescript
|
|
258
|
+
// Before
|
|
259
|
+
<GiftedChat
|
|
260
|
+
lightboxProps={{
|
|
261
|
+
backgroundColor: 'black',
|
|
262
|
+
// other lightbox props
|
|
263
|
+
}}
|
|
264
|
+
/>
|
|
265
|
+
|
|
266
|
+
// After
|
|
267
|
+
// Custom image viewer is now built-in with react-native-zoom-reanimated
|
|
268
|
+
// No props needed - just works out of the box
|
|
269
|
+
<GiftedChat />
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## ✨ New Features
|
|
273
|
+
|
|
274
|
+
### TypeScript Improvements
|
|
275
|
+
- Complete TypeScript conversion of the library
|
|
276
|
+
- Better type safety for all props
|
|
277
|
+
- Properly typed `textInputProps` with TextInput component types
|
|
278
|
+
|
|
279
|
+
### Keyboard Handling
|
|
280
|
+
- Improved keyboard handling with `react-native-keyboard-controller`
|
|
281
|
+
- Better support for safe areas
|
|
282
|
+
- More predictable keyboard offset behavior
|
|
283
|
+
|
|
284
|
+
### Image Viewer
|
|
285
|
+
- Custom built-in image viewer using `react-native-zoom-reanimated`
|
|
286
|
+
- No external lightbox dependency needed
|
|
287
|
+
- Better cross-platform support (including web)
|
|
288
|
+
|
|
289
|
+
### SafeArea Integration
|
|
290
|
+
- Built-in SafeAreaProvider integration
|
|
291
|
+
- Better handling of notches and device-specific layouts
|
|
292
|
+
|
|
293
|
+
### Link Parsing
|
|
294
|
+
- Upgraded from `react-native-parsed-text` to `react-native-autolink`
|
|
295
|
+
- Better URL, email, and phone number detection
|
|
296
|
+
- More customizable matchers
|
|
297
|
+
|
|
298
|
+
### Load Earlier Messages
|
|
299
|
+
- Improved load earlier messages logic
|
|
300
|
+
- Better UX with proper safe area handling
|
|
301
|
+
- Consolidated props under `loadEarlierMessagesProps`
|
|
302
|
+
|
|
303
|
+
## 🐛 Bug Fixes
|
|
304
|
+
|
|
305
|
+
- Fixed scroll to bottom behavior on Android
|
|
306
|
+
- Fixed load earlier messages display
|
|
307
|
+
- Fixed keyboard offset calculations
|
|
308
|
+
- Fixed TypeScript type inconsistencies
|
|
309
|
+
- Fixed ESLint errors throughout the codebase
|
|
310
|
+
- Fixed snapshot tests
|
|
311
|
+
- Fixed message container reanimated issues
|
|
312
|
+
- Fixed DayAnimated component and proper test coverage for renderDay prop
|
|
313
|
+
- Fixed automatic scroll to bottom when `isScrollToBottomEnabled=false`
|
|
314
|
+
- Fixed MessageText container styles
|
|
315
|
+
- Fixed construct messages on send in examples
|
|
316
|
+
|
|
317
|
+
## 🔧 Internal Improvements
|
|
318
|
+
|
|
319
|
+
- Converted JavaScript to TypeScript throughout the library
|
|
320
|
+
- Improved ESLint configuration with import sorting
|
|
321
|
+
- Added support for Reanimated v3 and v4
|
|
322
|
+
- Memoized values and functions for better performance
|
|
323
|
+
- Better themed styles refactoring
|
|
324
|
+
- Improved example app with tabs and different examples
|
|
325
|
+
- Updated to latest React Native, Expo, and dependency versions
|
|
326
|
+
- Removed unused dependencies (`react-native-iphone-x-helper`, `react-native-lightbox-v2`)
|
|
327
|
+
- Replaced deprecated `TouchableWithoutFeedback` with `Pressable`
|
|
328
|
+
- Added useCallbackThrottled for better scroll to bottom visibility
|
|
329
|
+
- Removed redundant TextInput configs
|
|
330
|
+
|
|
331
|
+
## 📚 Documentation Updates
|
|
332
|
+
|
|
333
|
+
- Updated README with new installation instructions
|
|
334
|
+
- Added working Expo Snack link
|
|
335
|
+
- Better structure for props documentation
|
|
336
|
+
- Added missing props to README
|
|
337
|
+
- Fixed broken links
|
|
338
|
+
- Added dark theme support in examples
|
|
339
|
+
- Better keyboard offset documentation
|
|
340
|
+
- Improved example readmes
|
|
341
|
+
|
|
342
|
+
## 🧪 Testing
|
|
343
|
+
|
|
344
|
+
- Fixed tests to run in correct timezone (Europe/Paris)
|
|
345
|
+
- Updated snapshots for new components
|
|
346
|
+
- Added proper test coverage for DayAnimated
|
|
347
|
+
- Fixed test setup and configuration
|
|
348
|
+
|
|
349
|
+
## 📋 Repository Changes
|
|
350
|
+
|
|
351
|
+
- Added GitHub stale workflow
|
|
352
|
+
- Removed package-lock.json (yarn-only repository)
|
|
353
|
+
- Updated Node.js engine requirement to >=20
|
|
354
|
+
- Various CI/CD improvements
|
|
355
|
+
|
|
356
|
+
## ⚠️ Important Notes
|
|
357
|
+
|
|
358
|
+
1. **This is an alpha release** - Test thoroughly before using in production
|
|
359
|
+
2. **Backup your code** before upgrading
|
|
360
|
+
3. **Review all prop changes** - Many props have been renamed or removed
|
|
361
|
+
4. **New peer dependencies** - Make sure to install `react-native-gesture-handler` and `react-native-safe-area-context`
|
|
362
|
+
5. **TypeScript users** - You may need to update type imports and usages
|
|
363
|
+
6. **Keyboard behavior** - The keyboard is now handled internally by default. Set `isKeyboardInternallyHandled={false}` if you have custom keyboard handling
|
|
364
|
+
7. **Safe areas** - The library now includes SafeAreaProvider internally, but you should still wrap your app with it for best results
|
|
365
|
+
|
|
366
|
+
## 📊 Version History
|
|
367
|
+
|
|
368
|
+
- **2.8.1** - Last stable release
|
|
369
|
+
- **2.8.2-alpha.0** - Initial alpha release
|
|
370
|
+
- **2.8.2-alpha.5** - Current alpha release (this changelog)
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
For issues or questions, please visit: https://github.com/FaridSafi/react-native-gifted-chat/issues
|
package/package.json
CHANGED
package/src/GiftedChat/index.tsx
CHANGED
|
@@ -280,7 +280,6 @@ function GiftedChat<TMessage extends IMessage = IMessage> (
|
|
|
280
280
|
|
|
281
281
|
const onInitialLayoutViewLayout = useCallback(
|
|
282
282
|
(e: LayoutChangeEvent) => {
|
|
283
|
-
console.log('onInitialLayoutViewLayout', e.nativeEvent.layout.height)
|
|
284
283
|
if (isInitialized)
|
|
285
284
|
return
|
|
286
285
|
|
|
@@ -416,18 +415,14 @@ function GiftedChat<TMessage extends IMessage = IMessage> (
|
|
|
416
415
|
}
|
|
417
416
|
|
|
418
417
|
function GiftedChatWrapper<TMessage extends IMessage = IMessage> (props: GiftedChatProps<TMessage>) {
|
|
419
|
-
// Don't use KeyboardProvider when keyboard is not internally handled
|
|
420
|
-
if (!props.isKeyboardInternallyHandled)
|
|
421
|
-
return <GiftedChat<TMessage> {...props} />
|
|
422
|
-
|
|
423
418
|
return (
|
|
424
|
-
<
|
|
425
|
-
<
|
|
426
|
-
<
|
|
419
|
+
<KeyboardProvider>
|
|
420
|
+
<GestureHandlerRootView style={styles.fill}>
|
|
421
|
+
<SafeAreaProvider>
|
|
427
422
|
<GiftedChat<TMessage> {...props} />
|
|
428
|
-
</
|
|
429
|
-
</
|
|
430
|
-
</
|
|
423
|
+
</SafeAreaProvider>
|
|
424
|
+
</GestureHandlerRootView>
|
|
425
|
+
</KeyboardProvider>
|
|
431
426
|
)
|
|
432
427
|
}
|
|
433
428
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import {
|
|
3
3
|
ActivityIndicator,
|
|
4
|
-
Platform,
|
|
5
4
|
StyleSheet,
|
|
6
5
|
Text,
|
|
7
6
|
View,
|
|
@@ -13,36 +12,10 @@ import Color from './Color'
|
|
|
13
12
|
import { TouchableOpacity } from './components/TouchableOpacity'
|
|
14
13
|
import stylesCommon from './styles'
|
|
15
14
|
|
|
16
|
-
const styles = StyleSheet.create({
|
|
17
|
-
container: {
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
marginTop: 5,
|
|
20
|
-
marginBottom: 10,
|
|
21
|
-
},
|
|
22
|
-
wrapper: {
|
|
23
|
-
backgroundColor: Color.defaultColor,
|
|
24
|
-
borderRadius: 15,
|
|
25
|
-
height: 30,
|
|
26
|
-
paddingLeft: 10,
|
|
27
|
-
paddingRight: 10,
|
|
28
|
-
},
|
|
29
|
-
text: {
|
|
30
|
-
backgroundColor: Color.backgroundTransparent,
|
|
31
|
-
color: Color.white,
|
|
32
|
-
fontSize: 12,
|
|
33
|
-
},
|
|
34
|
-
activityIndicator: {
|
|
35
|
-
marginTop: Platform.select({
|
|
36
|
-
ios: -14,
|
|
37
|
-
android: -16,
|
|
38
|
-
default: -15,
|
|
39
|
-
}),
|
|
40
|
-
},
|
|
41
|
-
})
|
|
42
|
-
|
|
43
15
|
export interface LoadEarlierMessagesProps {
|
|
44
|
-
isAvailable
|
|
45
|
-
isLoading
|
|
16
|
+
isAvailable: boolean
|
|
17
|
+
isLoading: boolean
|
|
18
|
+
onPress: () => void
|
|
46
19
|
isInfiniteScrollEnabled?: boolean
|
|
47
20
|
label?: string
|
|
48
21
|
containerStyle?: StyleProp<ViewStyle>
|
|
@@ -51,7 +24,6 @@ export interface LoadEarlierMessagesProps {
|
|
|
51
24
|
activityIndicatorStyle?: StyleProp<ViewStyle>
|
|
52
25
|
activityIndicatorColor?: string
|
|
53
26
|
activityIndicatorSize?: number | 'small' | 'large'
|
|
54
|
-
onPress: () => void
|
|
55
27
|
}
|
|
56
28
|
|
|
57
29
|
export const LoadEarlierMessages: React.FC<LoadEarlierMessagesProps> = ({
|
|
@@ -65,23 +37,6 @@ export const LoadEarlierMessages: React.FC<LoadEarlierMessagesProps> = ({
|
|
|
65
37
|
activityIndicatorSize = 'small',
|
|
66
38
|
activityIndicatorStyle,
|
|
67
39
|
}) => {
|
|
68
|
-
const loadingContent = useMemo(() => (
|
|
69
|
-
<View>
|
|
70
|
-
<Text style={[styles.text, textStyle, { opacity: 0 }]}>
|
|
71
|
-
{label}
|
|
72
|
-
</Text>
|
|
73
|
-
<ActivityIndicator
|
|
74
|
-
color={activityIndicatorColor!}
|
|
75
|
-
size={activityIndicatorSize!}
|
|
76
|
-
style={[styles.activityIndicator, activityIndicatorStyle]}
|
|
77
|
-
/>
|
|
78
|
-
</View>
|
|
79
|
-
), [label, textStyle, activityIndicatorColor, activityIndicatorSize, activityIndicatorStyle])
|
|
80
|
-
|
|
81
|
-
const labelContent = useMemo(() => (
|
|
82
|
-
<Text style={[styles.text, textStyle]}>{label}</Text>
|
|
83
|
-
), [label, textStyle])
|
|
84
|
-
|
|
85
40
|
return (
|
|
86
41
|
<TouchableOpacity
|
|
87
42
|
style={[styles.container, containerStyle]}
|
|
@@ -90,8 +45,50 @@ export const LoadEarlierMessages: React.FC<LoadEarlierMessagesProps> = ({
|
|
|
90
45
|
accessibilityRole='button'
|
|
91
46
|
>
|
|
92
47
|
<View style={[stylesCommon.centerItems, styles.wrapper, wrapperStyle]}>
|
|
93
|
-
{
|
|
48
|
+
{
|
|
49
|
+
isLoading
|
|
50
|
+
? (
|
|
51
|
+
<ActivityIndicator
|
|
52
|
+
color={activityIndicatorColor}
|
|
53
|
+
size={activityIndicatorSize}
|
|
54
|
+
style={[styles.activityIndicator, activityIndicatorStyle]}
|
|
55
|
+
/>
|
|
56
|
+
)
|
|
57
|
+
: (
|
|
58
|
+
<View style={styles.textContainer}>
|
|
59
|
+
<Text style={[styles.text, textStyle]}>
|
|
60
|
+
{label}
|
|
61
|
+
</Text>
|
|
62
|
+
</View>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
94
65
|
</View>
|
|
95
66
|
</TouchableOpacity>
|
|
96
67
|
)
|
|
97
68
|
}
|
|
69
|
+
|
|
70
|
+
const styles = StyleSheet.create({
|
|
71
|
+
container: {
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
marginVertical: 10,
|
|
74
|
+
},
|
|
75
|
+
wrapper: {
|
|
76
|
+
backgroundColor: Color.defaultColor,
|
|
77
|
+
borderRadius: 15,
|
|
78
|
+
paddingHorizontal: 10,
|
|
79
|
+
paddingVertical: 5,
|
|
80
|
+
},
|
|
81
|
+
textContainer: {
|
|
82
|
+
paddingTop: 3,
|
|
83
|
+
paddingBottom: 4,
|
|
84
|
+
},
|
|
85
|
+
text: {
|
|
86
|
+
backgroundColor: Color.backgroundTransparent,
|
|
87
|
+
color: Color.white,
|
|
88
|
+
fontSize: 12,
|
|
89
|
+
lineHeight: 13,
|
|
90
|
+
},
|
|
91
|
+
activityIndicator: {
|
|
92
|
+
paddingHorizontal: 20,
|
|
93
|
+
},
|
|
94
|
+
})
|
|
@@ -134,6 +134,7 @@ const DayAnimated = ({ scrolledY, daysPositions, listHeight, renderDay, messages
|
|
|
134
134
|
<Animated.View
|
|
135
135
|
style={[stylesCommon.centerItems, styles.dayAnimated, style]}
|
|
136
136
|
onLayout={handleLayout}
|
|
137
|
+
pointerEvents='none'
|
|
137
138
|
>
|
|
138
139
|
<Animated.View
|
|
139
140
|
style={contentStyle}
|
|
@@ -79,7 +79,7 @@ function MessageContainer<TMessage extends IMessage = IMessage> (props: MessageC
|
|
|
79
79
|
}, [renderFooterProp, renderTypingIndicator, props])
|
|
80
80
|
|
|
81
81
|
const renderLoadEarlier = useCallback(() => {
|
|
82
|
-
if (loadEarlierMessagesProps?.
|
|
82
|
+
if (loadEarlierMessagesProps?.isAvailable) {
|
|
83
83
|
if (renderLoadEarlierProp)
|
|
84
84
|
return renderLoadEarlierProp(loadEarlierMessagesProps)
|
|
85
85
|
|
|
@@ -286,10 +286,10 @@ function MessageContainer<TMessage extends IMessage = IMessage> (props: MessageC
|
|
|
286
286
|
|
|
287
287
|
const onEndReached = useCallback(() => {
|
|
288
288
|
if (
|
|
289
|
-
loadEarlierMessagesProps
|
|
290
|
-
loadEarlierMessagesProps
|
|
291
|
-
loadEarlierMessagesProps
|
|
292
|
-
!loadEarlierMessagesProps
|
|
289
|
+
loadEarlierMessagesProps &&
|
|
290
|
+
loadEarlierMessagesProps.isAvailable &&
|
|
291
|
+
loadEarlierMessagesProps.isInfiniteScrollEnabled &&
|
|
292
|
+
!loadEarlierMessagesProps.isLoading
|
|
293
293
|
)
|
|
294
294
|
loadEarlierMessagesProps.onPress()
|
|
295
295
|
}, [loadEarlierMessagesProps])
|
package/src/MessageText.tsx
CHANGED
package/src/SystemMessage.tsx
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import {
|
|
3
3
|
StyleSheet,
|
|
4
|
-
Text,
|
|
5
4
|
View,
|
|
6
5
|
ViewStyle,
|
|
7
6
|
StyleProp,
|
|
8
7
|
TextStyle,
|
|
9
8
|
} from 'react-native'
|
|
10
9
|
import Color from './Color'
|
|
10
|
+
import { MessageText } from './MessageText'
|
|
11
11
|
import stylesCommon from './styles'
|
|
12
12
|
import { IMessage } from './types'
|
|
13
13
|
|
|
14
|
-
const styles = StyleSheet.create({
|
|
15
|
-
container: {
|
|
16
|
-
marginTop: 5,
|
|
17
|
-
marginBottom: 10,
|
|
18
|
-
},
|
|
19
|
-
text: {
|
|
20
|
-
backgroundColor: Color.backgroundTransparent,
|
|
21
|
-
color: Color.defaultColor,
|
|
22
|
-
fontSize: 12,
|
|
23
|
-
fontWeight: '300',
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
|
|
27
14
|
export interface SystemMessageProps<TMessage extends IMessage> {
|
|
28
15
|
currentMessage: TMessage
|
|
29
16
|
containerStyle?: StyleProp<ViewStyle>
|
|
@@ -39,22 +26,41 @@ export function SystemMessage<TMessage extends IMessage = IMessage> ({
|
|
|
39
26
|
textStyle,
|
|
40
27
|
children,
|
|
41
28
|
}: SystemMessageProps<TMessage>) {
|
|
42
|
-
const textContent = useMemo(() => {
|
|
43
|
-
if (!currentMessage?.text)
|
|
44
|
-
return null
|
|
45
|
-
|
|
46
|
-
return <Text style={[styles.text, textStyle]}>{currentMessage.text}</Text>
|
|
47
|
-
}, [currentMessage?.text, textStyle])
|
|
48
|
-
|
|
49
29
|
if (currentMessage == null || currentMessage.system === false)
|
|
50
30
|
return null
|
|
51
31
|
|
|
52
32
|
return (
|
|
53
33
|
<View style={[stylesCommon.fill, stylesCommon.centerItems, styles.container, containerStyle]}>
|
|
54
34
|
<View style={wrapperStyle}>
|
|
55
|
-
|
|
35
|
+
<MessageText
|
|
36
|
+
currentMessage={currentMessage}
|
|
37
|
+
customTextStyle={[styles.text, textStyle]}
|
|
38
|
+
containerStyle={{ left: styles.messageContainer, right: styles.messageContainer }}
|
|
39
|
+
/>
|
|
56
40
|
{children}
|
|
57
41
|
</View>
|
|
58
42
|
</View>
|
|
59
43
|
)
|
|
60
44
|
}
|
|
45
|
+
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
container: {
|
|
48
|
+
marginTop: 5,
|
|
49
|
+
marginBottom: 10,
|
|
50
|
+
marginHorizontal: 20,
|
|
51
|
+
},
|
|
52
|
+
messageContainer: {
|
|
53
|
+
borderRadius: 20,
|
|
54
|
+
borderWidth: 1,
|
|
55
|
+
borderColor: 'rgba(0,0,0,0.1)',
|
|
56
|
+
paddingHorizontal: 10,
|
|
57
|
+
paddingVertical: 10,
|
|
58
|
+
backgroundColor: 'rgba(0,0,0,0.05)',
|
|
59
|
+
},
|
|
60
|
+
text: {
|
|
61
|
+
backgroundColor: Color.backgroundTransparent,
|
|
62
|
+
fontStyle: 'italic',
|
|
63
|
+
fontSize: 12,
|
|
64
|
+
fontWeight: '300',
|
|
65
|
+
},
|
|
66
|
+
})
|