Permalink
Browse files

Adding minComposerHeight and maxComposerHeight props. (#1069)

* Adding minComposerHeight and maxComposerHeight props.

* as per review comments

* As per review comments.
  • Loading branch information...
nandiniparimi1107 authored and xcarpentier committed Jan 7, 2019
1 parent 0cd69b2 commit b7de25ff4c85753e5671f166e899876286045b2d
Showing with 17 additions and 2 deletions.
  1. +2 −0 README.md
  2. +4 −0 index.d.ts
  3. +11 −2 src/GiftedChat.js
@@ -209,6 +209,8 @@ e.g. System Message
* **`maxInputLength`** _(Integer)_ - Max message composer TextInput length
* **`parsePatterns`** _(Function)_ - Custom parse patterns for [react-native-parsed-text](https://github.com/taskrabbit/react-native-parsed-text) used to linkify message content (like URLs and phone numbers), e.g.:
* **`extraData`** _(Object)_ - Extra props for re-rendering flatlist on demand. This will be useful for rendering footer etc.
* **`minComposerHeight`** _(Object)_ - Custom min height of the composer.
* **`maxComposerHeight`** _(Object)_ - Custom max height of the composer.

```js
<GiftedChat
@@ -236,6 +236,10 @@ export interface GiftedChatProps<TMessage extends IMessage = IMessage> {
imageStyle?: ViewStyle
/* This can be used to pass any data which needs to be re-rendered */
extraData?: any;
/* composer min Height */
minComposerHeight?: number;
/* composer min Height */
maxComposerHeight?: number;
}

export class GiftedChat extends React.Component<GiftedChatProps> {
@@ -373,8 +373,13 @@ class GiftedChat extends React.Component {
}

onInputSizeChanged(size) {
const newComposerHeight = Math.max(MIN_COMPOSER_HEIGHT, Math.min(MAX_COMPOSER_HEIGHT, size.height));
const newMessagesContainerHeight = this.getMessagesContainerHeightWithKeyboard(newComposerHeight);
const newComposerHeight = Math.max(
this.props.minComposerHeight,
Math.min(this.props.maxComposerHeight, size.height),
);
const newMessagesContainerHeight = this.getMessagesContainerHeightWithKeyboard(
newComposerHeight,
);
this.setState({
composerHeight: newComposerHeight,
messagesContainerHeight: this.prepareMessagesContainerHeight(newMessagesContainerHeight),
@@ -560,6 +565,8 @@ GiftedChat.defaultProps = {
forceGetKeyboardHeight: false,
inverted: true,
extraData: null,
minComposerHeight: MIN_COMPOSER_HEIGHT,
maxComposerHeight: MAX_COMPOSER_HEIGHT,
};

GiftedChat.propTypes = {
@@ -613,6 +620,8 @@ GiftedChat.propTypes = {
inverted: PropTypes.bool,
textInputProps: PropTypes.object,
extraData: PropTypes.object,
minComposerHeight: PropTypes.number,
maxComposerHeight: PropTypes.number,
};

export {

0 comments on commit b7de25f

Please sign in to comment.