Skip to content

Commit d2b8362

Browse files
Merge pull request #346 from GetStream/vishal/keyboard
Revamp of KeyboardCompatibleView
2 parents d5a608b + e5f11ee commit d2b8362

File tree

13 files changed

+3703
-2381
lines changed

13 files changed

+3703
-2381
lines changed

CHANGELOG.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@
44

55
**BREAKING CHANGES**
66

7-
*ChannelList*
7+
## MessageInput
8+
9+
- Replaced the default image picker [react-native-image-picker](https://github.com/react-native-community/react-native-image-picker) for [react-native-image-crop-picker](https://github.com/ivpusic/react-native-image-crop-picker) and added `compressImageQuality` prop to support image compression out-of-the-box
10+
- Added `FileUploadPreview` and `ImageUploadPreview` props to support custom overrides to those components
11+
12+
## KeyboardCompatibleView and Channel component
13+
14+
Implementation of internal KeyboardCompatibleView has been changed so as to make animations smoother and fix existing issues with keyboard behavior.
15+
Support for following props have been dropped from Channel and KeyboardCompatibleView
16+
17+
- keyboardDismissAnimationDuration
18+
- keyboardOpenAnimationDuration
19+
20+
Following new props have been introduced on `Channel` component. They are the same props accepted by KeyboardAvoidingView of react-native.
21+
22+
- keyboardBehavior ['height' | 'position' | 'padding']
23+
- keyboardVerticalOffset
24+
25+
26+
## ChannelList
827

928
- We converted the ChannelList component from a class to a function and abstracted the event listener logic into custom hooks. The default event handlers can still be overridden by providing custom prop functions to the ChannelList component. Custom logic can be provided for the following events:
1029

@@ -21,34 +40,43 @@
2140
- 1st argument: `setChannels` reference to the `useState` hook that sets the `channels` in the React Native FlatList
2241
- 2nd argument: `event` object returned by the StreamChat instance
2342

43+
e.g.,
44+
45+
```js
46+
// In following example we will override the default handler for notification.added_to_channel
47+
<ChannelList
48+
filters={}
49+
onAddedToChannel={(setChannels, event) => {
50+
setChannels(channels => {
51+
// Do additional actions on channels array.
52+
return channels;
53+
})
54+
}}
55+
>
56+
```
2457
- On upgrading to this release, ensure events and any custom handling functions (ex: `onAddedToChannel` or `onMessageNew`) are properly processed and update the list UI as expected.
2558

26-
*FileUploadPreview*
59+
## FileUploadPreview
2760

2861
- We fixed a bug for being unable to remove a file from the `MessageInput` and made it consistent to `ImageUploadPreview`
2962
- We have removed support for the `fileUploadPreview.dismissText` theme value
3063
- We have added support for `fileUploadPreview.dismiss`, `fileUploadPreview.dismissImage`, and `fileUploadPreview.imageContainer` theme values
3164

32-
*MessageInput*
33-
34-
- We replaced the default image picker [react-native-image-picker](https://github.com/react-native-community/react-native-image-picker) for [react-native-image-crop-picker](https://github.com/ivpusic/react-native-image-crop-picker) and added `compressImageQuality` prop to support image compression out-of-the-box
35-
- Added `FileUploadPreview` and `ImageUploadPreview` props to support custom overrides to those components
36-
37-
*Deprecated Props*
65+
## Deprecated Props
3866

39-
- We have removed support for the `MessageList` component's `onMessageTouch` prop. Since this prop no longer exists, we have also removed `dismissKeyboardOnMessageTouch`. Please use the `onPress` prop on the `MessageSimple` component to perform an action on touch of a message.
67+
- We have removed support for the `MessageList` component's `onMessageTouch` prop. Please use the `onPress` prop on the `MessageSimple` component to perform an action on touch of a message.
4068

4169
- We have removed support for the `Message` component's `readOnly` prop. Please use the `disabled` value from the `ChannelContext` instead.
4270

4371
- We have also dropped support for the following `MessageList` props:
4472
- `dateSeparator` (use DateSeparator instead)
4573
- `headerComponent` (use HeaderComponent instead)
4674

47-
*this Reference Removal*
75+
## this Reference Removal
4876

4977
- We have removed the `this` class component reference from the prop functions in `MessageSimple`. For example, if you wish to override the SDK's standard long press behavior on a message, the `onLongPress` function passed in to `MessageSimple` no longer takes the `this` component reference as it's first argument. The message and the event object become the first and second arguments, respectively.
5078

51-
*renderText Function*
79+
## renderText Function
5280

5381
- The `renderText` function utilized in the `MessageTextContainer` component now accepts a single object containing `markdownRules`, `markdownStyles`, and `message`. Previously each value was a separate function parameter.
5482

expo-package/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "stream-chat-expo",
3-
"version": "1.2.0",
3+
"version": "1.3.0-kcv.1",
44
"author": {
55
"company": "Stream.io Inc"
66
},
77
"main": "src/index.js",
88
"types": "types/index.d.ts",
99
"dependencies": {
1010
"react-native-unimodules": "^0.5.4",
11-
"stream-chat-react-native-core": "v1.2.0"
11+
"stream-chat-react-native-core": "v1.3.0-kcv.1"
1212
},
1313
"peerDependencies": {
1414
"expo": "^32.0.0",

native-package/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stream-chat-react-native",
3-
"version": "1.2.0",
3+
"version": "1.3.0-kcv.1",
44
"author": {
55
"company": "Stream.io Inc",
66
"name": "Stream.io Inc"
@@ -10,7 +10,7 @@
1010
"types": "types/index.d.ts",
1111
"dependencies": {
1212
"es6-symbol": "^3.1.3",
13-
"stream-chat-react-native-core": "v1.2.0"
13+
"stream-chat-react-native-core": "v1.3.0-kcv.1"
1414
},
1515
"peerDependencies": {
1616
"@react-native-community/netinfo": ">=2.0.7",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stream-chat-react-native-core",
3-
"version": "1.2.0",
3+
"version": "1.3.0-kcv.1",
44
"author": {
55
"company": "Stream.io Inc",
66
"name": "Stream.io Inc"

src/components/Channel/Channel.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const Channel = (props) => {
2929
channel,
3030
children,
3131
disableIfFrozenChannel = true,
32-
disableKeyboardCompatibleView = false,
3332
emojiData = emojiDataDefault,
3433
EmptyStateIndicator = EmptyStateIndicatorDefault,
3534
KeyboardCompatibleView = KeyboardCompatibleViewDefault,
@@ -189,6 +188,8 @@ const Channel = (props) => {
189188
const initChannel = async () => {
190189
let initError = false;
191190
setError(false);
191+
setLoading(true);
192+
192193
if (!channel.initialized && channel.cid) {
193194
try {
194195
await channel.watch();
@@ -506,8 +507,17 @@ const Channel = (props) => {
506507
return <LoadingIndicator listType='message' />;
507508
}
508509

510+
const {
511+
disableKeyboardCompatibleView,
512+
keyboardBehavior,
513+
keyboardVerticalOffset,
514+
} = props;
509515
return (
510-
<KeyboardCompatibleView enabled={!disableKeyboardCompatibleView}>
516+
<KeyboardCompatibleView
517+
behavior={keyboardBehavior}
518+
enabled={!disableKeyboardCompatibleView}
519+
keyboardVerticalOffset={keyboardVerticalOffset}
520+
>
511521
<ChannelContext.Provider value={channelContext}>
512522
<SuggestionsProvider>{children}</SuggestionsProvider>
513523
</ChannelContext.Provider>

0 commit comments

Comments
 (0)