GithubHelp home page GithubHelp logo

faridsafi / react-native-gifted-chat Goto Github PK

View Code? Open in Web Editor NEW
13.2K 195.0 3.5K 46.78 MB

๐Ÿ’ฌ The most complete chat UI for React Native

Home Page: https://gifted.chat

License: MIT License

JavaScript 18.91% TypeScript 81.09%
react-native chat component

react-native-gifted-chat's Introduction

ย  ย react-native-gifted-chat

๐Ÿ’ฌ Gifted Chat

The most complete chat UI for React Native & Web

npm downloads npm version

ย build

Demo Web ๐Ÿ–ฅ

Snack GiftedChat playground

Sponsor



Coding Bootcamp in Paris co-founded by Farid Safi

Click to learn more



Scalable chat API/Server written in Go

API Tour | React Native Gifted tutorial



A complete app engine featuring GiftedChat

Check out our GitHub

The future of GiftedChat ๐ŸŽ‰

Please give us your advice: Related PR

Please vote

GiftedChat depends on other packages and some needs a boost, please vote for PRs will improve it, thanks:

Features

  • ๐ŸŽ‰ react-native-webable (since 0.10.0) web configuration
  • Write with TypeScript (since 0.8.0)
  • Fully customizable components
  • Composer actions (to attach photos, etc.)
  • Load earlier messages
  • Copy messages to clipboard
  • Touchable links using react-native-parsed-text
  • Avatar as user's initials
  • Localized dates
  • Multi-line TextInput
  • InputToolbar avoiding keyboard
  • Redux support
  • System message
  • Quick Reply messages (bot)
  • Typing indicator react-native-typing-animation

Dependency

  • Use version 0.2.x for RN >= 0.44.0
  • Use version 0.1.x for RN >= 0.40.0
  • Use version 0.0.10 for RN < 0.40.0

Testing

TEST_ID is exported as constants that can be used in your testing library of choice

Gifted Chat uses onLayout to determine the height of the chat container. To trigger onLayout during your tests, you can run the following bits of code.

const WIDTH = 200; // or any number
const HEIGHT = 2000; // or any number

const loadingWrapper = getByTestId(TEST_ID.LOADING_WRAPPER)
fireEvent(loadingWrapper, 'layout', {
  nativeEvent: {
    layout: {
      width: WIDTH,
      height: HEIGHT,
    },
  },
})

Installation

  • Using npm: npm install react-native-gifted-chat --save
  • Using Yarn: yarn add react-native-gifted-chat

react-native-video and expo-av

  • Both dependencies are removed since 0.11.0.
  • You still be able to provide a video but you need to provide renderMessageVideo prop.

You have a question?

  1. Please check this readme and may find a response
  2. Please ask on StackOverflow first: https://stackoverflow.com/questions/tagged/react-native-gifted-chat
  3. Find response on existing issues
  4. Try to keep issues for issues

Example

import React, { useState, useCallback, useEffect } from 'react'
import { GiftedChat } from 'react-native-gifted-chat'

export function Example() {
  const [messages, setMessages] = useState([])

  useEffect(() => {
    setMessages([
      {
        _id: 1,
        text: 'Hello developer',
        createdAt: new Date(),
        user: {
          _id: 2,
          name: 'React Native',
          avatar: 'https://placeimg.com/140/140/any',
        },
      },
    ])
  }, [])

  const onSend = useCallback((messages = []) => {
    setMessages(previousMessages =>
      GiftedChat.append(previousMessages, messages),
    )
  }, [])

  return (
    <GiftedChat
      messages={messages}
      onSend={messages => onSend(messages)}
      user={{
        _id: 1,
      }}
    />
  )
}

Advanced example

See App.tsx for a working demo!

"Slack" example

See the files in example/example-slack-message for an example of how to override the default UI to make something that looks more like Slack -- with usernames displayed and all messages on the left.

Message object

e.g. Chat Message

export interface IMessage {
  _id: string | number
  text: string
  createdAt: Date | number
  user: User
  image?: string
  video?: string
  audio?: string
  system?: boolean
  sent?: boolean
  received?: boolean
  pending?: boolean
  quickReplies?: QuickReplies
}
{
  _id: 1,
  text: 'My message',
  createdAt: new Date(Date.UTC(2016, 5, 11, 17, 20, 0)),
  user: {
    _id: 2,
    name: 'React Native',
    avatar: 'https://facebook.github.io/react/img/logo_og.png',
  },
  image: 'https://facebook.github.io/react/img/logo_og.png',
  // You can also add a video prop:
  video: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4',
  // Mark the message as sent, using one tick
  sent: true,
  // Mark the message as received, using two tick
  received: true,
  // Mark the message as pending with a clock loader
  pending: true,
  // Any additional custom parameters are passed through
}

e.g. System Message

{
  _id: 1,
  text: 'This is a system message',
  createdAt: new Date(Date.UTC(2016, 5, 11, 17, 20, 0)),
  system: true,
  // Any additional custom parameters are passed through
}

e.g. Chat Message with Quick Reply options

See PR #1211

interface Reply {
  title: string
  value: string
  messageId?: any
}

interface QuickReplies {
  type: 'radio' | 'checkbox'
  values: Reply[]
  keepIt?: boolean
}
  {
    _id: 1,
    text: 'This is a quick reply. Do you love Gifted Chat? (radio) KEEP IT',
    createdAt: new Date(),
    quickReplies: {
      type: 'radio', // or 'checkbox',
      keepIt: true,
      values: [
        {
          title: '๐Ÿ˜‹ Yes',
          value: 'yes',
        },
        {
          title: '๐Ÿ“ท Yes, let me show you with a picture!',
          value: 'yes_picture',
        },
        {
          title: '๐Ÿ˜ž Nope. What?',
          value: 'no',
        },
      ],
    },
    user: {
      _id: 2,
      name: 'React Native',
    },
  },
  {
    _id: 2,
    text: 'This is a quick reply. Do you love Gifted Chat? (checkbox)',
    createdAt: new Date(),
    quickReplies: {
      type: 'checkbox', // or 'radio',
      values: [
        {
          title: 'Yes',
          value: 'yes',
        },
        {
          title: 'Yes, let me show you with a picture!',
          value: 'yes_picture',
        },
        {
          title: 'Nope. What?',
          value: 'no',
        },
      ],
    },
    user: {
      _id: 2,
      name: 'React Native',
    },
  }

Props

  • messageContainerRef (FlatList ref) - Ref to the flatlist
  • textInputRef (TextInput ref) - Ref to the text input
  • messages (Array) - Messages to display
  • isTyping (Bool) - Typing Indicator state; default false. If you userenderFooter it will override this.
  • text (String) - Input text; default is undefined, but if specified, it will override GiftedChat's internal state (e.g. for redux; see notes below)
  • placeholder (String) - Placeholder when text is empty; default is 'Type a message...'
  • messageIdGenerator (Function) - Generate an id for new messages. Defaults to UUID v4, generated by uuid
  • user (Object) - User sending the messages: { _id, name, avatar }
  • onSend (Function) - Callback when sending a message
  • alwaysShowSend (Bool) - Always show send button in input text composer; default false, show only when text input is not empty
  • locale (String) - Locale to localize the dates. You need first to import the locale you need (ie. require('dayjs/locale/de') or import 'dayjs/locale/fr')
  • timeFormat (String) - Format to use for rendering times; default is 'LT' (see Day.js Format)
  • dateFormat (String) - Format to use for rendering dates; default is 'll' (see Day.js Format)
  • loadEarlier (Bool) - Enables the "load earlier messages" button, required for infiniteScroll
  • isKeyboardInternallyHandled (Bool) - Determine whether to handle keyboard awareness inside the plugin. If you have your own keyboard handling outside the plugin set this to false; default is true
  • onLoadEarlier (Function) - Callback when loading earlier messages
  • isLoadingEarlier (Bool) - Display an ActivityIndicator when loading earlier messages
  • renderLoading (Function) - Render a loading view when initializing
  • renderLoadEarlier (Function) - Custom "Load earlier messages" button
  • renderAvatar (Function) - Custom message avatar; set to null to not render any avatar for the message
  • showUserAvatar (Bool) - Whether to render an avatar for the current user; default is false, only show avatars for other users
  • showAvatarForEveryMessage (Bool) - When false, avatars will only be displayed when a consecutive message is from the same user on the same day; default is false
  • onPressAvatar (Function(user)) - Callback when a message avatar is tapped
  • onLongPressAvatar (Function(user)) - Callback when a message avatar is long-pressed
  • renderAvatarOnTop (Bool) - Render the message avatar at the top of consecutive messages, rather than the bottom; default is false
  • renderBubble (Function) - Custom message bubble
  • renderTicks (Function(message)) - Custom ticks indicator to display message status
  • renderSystemMessage (Function) - Custom system message
  • onPress (Function(context, message)) - Callback when a message bubble is pressed
  • onLongPress (Function(context, message)) - Callback when a message bubble is long-pressed; default is to show an ActionSheet with "Copy Text" (see example using showActionSheetWithOptions())
  • inverted (Bool) - Reverses display order of messages; default is true
  • renderUsernameOnMessage (Bool) - Indicate whether to show the user's username inside the message bubble; default is false
  • renderUsername (Function) - Custom Username container
  • renderMessage (Function) - Custom message container
  • renderMessageText (Function) - Custom message text
  • renderMessageImage (Function) - Custom message image
  • renderMessageVideo (Function) - Custom message video
  • imageProps (Object) - Extra props to be passed to the <Image> component created by the default renderMessageImage
  • videoProps (Object) - Extra props to be passed to the video component created by the required renderMessageVideo
  • lightboxProps (Object) - Extra props to be passed to the MessageImage's Lightbox
  • isCustomViewBottom (Bool) - Determine whether renderCustomView is displayed before or after the text, image and video views; default is false
  • renderCustomView (Function) - Custom view inside the bubble
  • renderDay (Function) - Custom day above a message
  • renderTime (Function) - Custom time inside a message
  • renderFooter (Function) - Custom footer component on the ListView, e.g. 'User is typing...'; see App.tsx for an example. Overrides default typing indicator that triggers when isTyping is true.
  • renderChatEmpty (Function) - Custom component to render in the ListView when messages are empty
  • renderChatFooter (Function) - Custom component to render below the MessageContainer (separate from the ListView)
  • renderInputToolbar (Function) - Custom message composer container
  • renderComposer (Function) - Custom text input message composer
  • renderActions (Function) - Custom action button on the left of the message composer
  • renderSend (Function) - Custom send button; you can pass children to the original Send component quite easily, for example, to use a custom icon (example)
  • renderAccessory (Function) - Custom second line of actions below the message composer
  • onPressActionButton (Function) - Callback when the Action button is pressed (if set, the default actionSheet will not be used)
  • bottomOffset (Integer) - Distance of the chat from the bottom of the screen (e.g. useful if you display a tab bar)
  • minInputToolbarHeight (Integer) - Minimum height of the input toolbar; default is 44
  • listViewProps (Object) - Extra props to be passed to the messages <ListView>; some props can't be overridden, see the code in MessageContainer.render() for details
  • textInputProps (Object) - Extra props to be passed to the <TextInput>
  • textInputStyle (Object) - Custom style to be passed to the <TextInput>
  • multiline (Bool) - Indicates whether to allow the <TextInput> to be multiple lines or not; default true.
  • keyboardShouldPersistTaps (Enum) - Determines whether the keyboard should stay visible after a tap; see <ScrollView> docs
  • onInputTextChanged (Function) - Callback when the input text changes
  • maxInputLength (Integer) - Max message composer TextInput length
  • parsePatterns (Function) - Custom parse patterns for react-native-parsed-text used to linking message content (like URLs and phone numbers), e.g.:
 <GiftedChat
   parsePatterns={(linkStyle) => [
     { type: 'phone', style: linkStyle, onPress: this.onPressPhoneNumber },
     { pattern: /#(\w+)/, style: { ...linkStyle, styles.hashtag }, onPress: this.onPressHashtag },
   ]}
 />
  • 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.
  • scrollToBottom (Bool) - Enables the scroll to bottom Component (Default is false)
  • scrollToBottomComponent (Function) - Custom Scroll To Bottom Component container
  • scrollToBottomOffset (Integer) - Custom Height Offset upon which to begin showing Scroll To Bottom Component (Default is 200)
  • scrollToBottomStyle (Object) - Custom style for Bottom Component container
  • alignTop (Boolean) Controls whether or not the message bubbles appear at the top of the chat (Default is false - bubbles align to bottom)
  • onQuickReply (Function) - Callback when sending a quick reply (to backend server)
  • renderQuickReplies (Function) - Custom all quick reply view
  • quickReplyStyle (StyleProp) - Custom quick reply view style
  • renderQuickReplySend (Function) - Custom quick reply send view
  • shouldUpdateMessage (Function) - Lets the message component know when to update outside of normal cases.
  • infiniteScroll (Bool) - infinite scroll up when reach the top of messages container, automatically call onLoadEarlier function if exist (not yet supported for the web). You need to add loadEarlier prop too.

Notes for Redux

The messages prop should work out-of-the-box with Redux. In most cases, this is all you need.

If you decide to specify a text prop, GiftedChat will no longer manage its own internal text state and will defer entirely to your prop. This is great for using a tool like Redux, but there's one extra step you'll need to take: simply implement onInputTextChanged to receive typing events and reset events (e.g. to clear the text onSend):

<GiftedChat
  text={customText}
  onInputTextChanged={text => this.setCustomText(text)}
  /* ... */
/>

Notes for Android

If you are using Create React Native App / Expo, no Android specific installation steps are required -- you can skip this section. Otherwise, we recommend modifying your project configuration as follows.

  • Make sure you have android:windowSoftInputMode="adjustResize" in your AndroidManifest.xml:

    <activity
      android:name=".MainActivity"
      android:label="@string/app_name"
      android:windowSoftInputMode="adjustResize"
      android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
  • For Expo, there are at least 2 solutions to fix it:

    • Append KeyboardAvoidingView after GiftedChat. This should only be done for Android, as KeyboardAvoidingView may conflict with the iOS keyboard avoidance already built into GiftedChat, e.g.:
<View style={{ flex: 1 }}>
   <GiftedChat />
   {
      Platform.OS === 'android' && <KeyboardAvoidingView behavior="padding" />
   }
</View>

If you use React Navigation, additional handling may be required to account for navigation headers and tabs. KeyboardAvoidingView's keyboardVerticalOffset property can be set to the height of the navigation header and tabBarOptions.keyboardHidesTabBar can be set to keep the tab bar from being shown when the keyboard is up. Due to a bug with calculating height on Android phones with notches, KeyboardAvoidingView is recommended over other solutions that involve calculating the height of the window.

Notes for local development

Native

  1. Install yarn global add expo-cli
  2. Install dependenciesyarn install
  3. expo start

react-native-web

With expo

  1. Install yarn global add expo-cli
  2. Install dependenciesyarn install
  3. expo start -w

Upgrade snack version

With create-react-app

  1. yarn add -D react-app-rewired
  2. touch config-overrides.js
module.exports = function override(config, env) {
  config.module.rules.push({
    test: /\.js$/,
    exclude: /node_modules[/\\](?!react-native-gifted-chat|react-native-lightbox|react-native-parsed-text)/,
    use: {
      loader: 'babel-loader',
      options: {
        babelrc: false,
        configFile: false,
        presets: [
          ['@babel/preset-env', { useBuiltIns: 'usage' }],
          '@babel/preset-react',
        ],
        plugins: ['@babel/plugin-proposal-class-properties'],
      },
    },
  })

  return config
}

You will find an example and a web demo here: xcarpentier/gifted-chat-web-demo

Another example with Gatsby : xcarpentier/clean-archi-boilerplate

Questions

License

Author

Feel free to ask me questions on Twitter @FaridSafi! or @xcapetir!

Contributors

Hire an expert!

Looking for a ReactNative freelance expert with more than 14 years of experience? Contact Xavier from hisย website!

react-native-gifted-chat's People

Contributors

abdelmagied94 avatar alizbazar avatar amerikan avatar amiralies avatar apparition47 avatar bpeters avatar brunocascio avatar cooperka avatar danielmejiadev avatar davidleonardi avatar faridsafi avatar fengliu222 avatar gnl avatar greenkeeper[bot] avatar hanayashiki avatar haruelrovix avatar ianlin avatar jeromegrosse avatar johan-dutoit avatar kfiroo avatar koppelaar avatar luhui avatar nandiniparimi1107 avatar rcabarreto avatar scarmuega avatar shamilovtim avatar shauns avatar swapkats avatar tafelito avatar xcarpentier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-gifted-chat's Issues

Split this component in more components

In renderRow is better to have another component to render it, like

So, in next implementations we could have different types of Messages, like a message that has a photo, or a Gif or Location.

Or a component could have a List of , in this design we could have in the same Message more than one type of message, like text + gif + photo

focus

After sending a message, focus is lost

There is no "load earlier messages" button

There is no "load earlier messages" button in my component. Any clue?
Screenshot

Code:

<GiftedMessenger
    ref={(c) => this._GiftedMessenger = c}
    ...
    loadEarlierMessagesButton={true}
    loadEarlierMessagesButtonText="Load"
    ...
/>

Uncustomizable bubbles style

The style for the bubbles doesn't work!

styles={{
          bubbleLeft: {
            backgroundColor: '#e6e6eb',
            marginRight: 70,
          },
          bubbleRight: {
            backgroundColor: '#007aff',
            marginLeft: 70,
          },
        }}

Please, look at Bubble.js. You can find there the library styles only.

Text input feels sluggish in iOS simulator

When typing into the input field in the iOS simulator, the response time for the text input element is sluggish, taking a long time to show the individual charachters to appear.

onKeyboardWillHide and onKeyboardWillShow not properly respecting maxHeight

The only visible part shown should be the height of the textInput (which isn't possible to pass textInputHeight right now). Basically if I have buttons below my messenger, like a hamburger icon to go to a settings menu - then it won't respect the height of the hamburger icon container. Therefore when keyboard is shown, stuff like this happens:

screen shot 2015-12-14 at 1 36 42 am

Slack-like interface

Hey!

Really like your component, and it was a nice addition to what I was building. My current app works with a slack-like interface for messaging. Is this something I can achieve easily with this component or is it really opinionated toward a iMessage/Messenger like app?

TL;DR: Would it be more work to code my own interface instead of using this one in order to reproduce the slack UX.

Thanks for your amazing work,

Cheers

Unable to run the project

I am new on React Native and learning by looking at the examples... I was trying to setup and run this project but unable to do so... As per readme file I ran the command npm install react-native-gifted-messenger --save but after that I was running following command and getting error

Admins-MacBook-Pro:GiftedMessengerExample gathole$ react-native run-android
Command `run-android` unrecognized. Did you mean to run this inside a react-native project?

any help would be appreciated

"this._data[rowID].position" becomes undefined when using ES6

I copied your example and changed it into ES6 and it went wrong when I tried to do this._GiftedMessenger.setMessageStatus('ErrorButton', rowID);. It said undefined is not an object(evaluating'this._data[rowID].position').

(I have already bind this using =>)

invalid space with NavigatorIOS

I use react-native-invertible-scroll-view with NavigatorIOS

class GiftedMessengerExample extends Component {
  render(){
return (
<ListView
            ref='listView'
            dataSource={this.state.dataSource}
            renderRow={this.renderRow}
            renderFooter={this.renderLoadEarlierMessages}
            style={this.styles.listView}

            renderScrollComponent={props => <InvertibleScrollView {...props} inverted />}
/>
);
}
}
class Nav extends Component{
  render(){
    return (
      <NavigatorIOS
        style={{flex:1}}
        initialRoute={{
          title: 'flex:1',
          component: GiftedMessengerExample
        }} />

      );
  }
}

and it has a invalid space at the bottom of listView
image

what's the reason?

focus

After sending a message, focus is lost
Screen

bubble angle

Cool and beautiful component. But the chatting bubble missing the angle which pointer to the avatar. I wonder how to fix this

wrap the content

It seems wrapping the content within the bubble is a common stuff in every chatting apps.
But the flex row layout with flex=1 cannot wrap the content. You should specify a margin to permanently draw the size.
You could do with flex column layout just like the demo on https://rnplay.org/plays/6h_SzA?autoplay=true. But if layout in column the errorbutton and status text always lay in column with the bubble.
So how could it be fixed?

Should we make keyboardShouldPersistTaps={false} by default?

It seems to me that a user would want to be able to dismiss the keybaord whenever they click back on the messages window (like how normal iOS and Android messaging apps work). Do you agree we should make this the new default? Right now it is set to true.

How to add some obj to handleSend?

for example in handle send I want to add "channelId" field inside message before send it to server.

handleSend(message = {}, rowID = null) {
   /*state or props is not working here (i want dynamically get the channelId), because this are refer to message, not parent class itself*/
   message.channelId = this.state.channelId; 

  Meteor.call('Messages.insert', message);
};

Please Help

position left/right should not be stored in message json

Found out you store position 'left' or 'right' directly in the message and then all the rendering conditions are based on that. However it probably shouldn't be stored in the message, because the very same message is 'right' on sender side, but 'left' on recipient side...

I'd suggest all messages store author ID instead and then you check each message's author ID against current user ID to determine if it's left or right.

Trying to figure out some quick monkey patch now - any tips?

Performance issue

Hi:

No doubt this is a very cool component.

I tried and hit the performance issue of ListView. When the number of messages increases, the response of 'send' button will be getting noticeably slower.

Any solutions for this?

Multiline support in input field on iOS

Multiple line support would be a nice addition on the iOS version.
Currently if i hit the return key nothing happens, but i think it should format the text being input, and add a newline charachter to a given message.

Android Input Container Styling Not Working

On iOS, the container styling works fine, but for some reason on Android it's not calculating the height properly or something, or extra padding is getting added, or for some reason Android's keyboard show and hide events aren't respecting the actual height of the container properly? Not sure what's up here.

Attached some screenshots from what I've been tinkering/had issues with. You can reproduce this by adding a little black rectangle you want to show below the GiftedMessenger. Then when the keyboard is shown, make the black rectangle disappear basically so all you see is the list view of messages Then when keyboard is hidden, the black rectangle should be shown again.

screen shot 2016-02-05 at 12 24 04 pm
screen shot 2016-02-05 at 12 21 32 pm
screen shot 2016-02-05 at 12 21 24 pm

Here's the props I've had to use to cope with this issue:

          maxHeight={height - 70 - (Platform.OS === 'android' ? 23 : 0)}
          onKeyboardWillShow={(e) => {
            this._GiftedMessenger.listViewMaxHeight = height - inputHeight;
            let t = this._GiftedMessenger.listViewMaxHeight -
              (e.endCoordinates ? e.endCoordinates.height : e.end.height);
            Animated.timing(this._GiftedMessenger.state.height, {
              toValue: t,
              duration: 200,
            }).start();
          }}
          onKeyboardWillHide={() => {
            //this._GiftedMessenger.refs.textInput.blur();
            let z = this._GiftedMessenger.props.maxHeight - inputHeight;
            this._GiftedMessenger.listViewMaxHeight = z;
            Animated.timing(this._GiftedMessenger.state.height, {
              toValue: this._GiftedMessenger.listViewMaxHeight,
              duration: 150,
            }).start();
          }}

And that inputHeight is a constant defined as:

// TODO: not sure why this happens (see GitHub issue I just filed)
const inputHeight = Platform.OS === 'android' ? 67 : 44;

Broken first time scroll to bottom feature

Not sure if anyone faced my issue.
My GiftedMessenger does not auto scroll to bottom from first time display.
After digging the code, I found the reason is from the onLayout sequence.
My onLayout sequences is footerView(with footerY=0) -> ListView -> footerView(with correct footerY).
(I use redux and guess the onLayout sequence behaviours comes from re-render flow.)
Then first time scrollWithoutAnimationToBottom() will do nothing since the footerY is 0.

Here is an easy fix but not elegant and would like to see if anyone has similar issues.
master...Kudo:fixFirstScrollToBottom

TextInput and Message Content jumps to top

Hey there! I am trying to use this module for my RN Android APP (RN v0.20). When i initially open the component, everything seems to be fine. As soon as i type in a message the content will be displayed on top of the view:

screen shot 2016-03-08 at 14 12 27

The next time i open up the keyboard my textinput jumps to the top as well:

screen shot 2016-03-08 at 14 12 39

I am using the example code. Anyone with similar issue?

Sender and receive images

Hi,

I was wondering if its possible to display both the sender and receive images?

So if you take this image as an example both grey and the blue bubble will have image
image

When props are updated the UI doesn't reflect the update

If you have this.props.messages and messages gets updated after an action is triggered the ui doesn't reflect the changes but render is called again on the component with the new set of props.

Is their something i'm missing for receiving new props or is this a ๐Ÿ›

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.