0.1.4 • Published 8 years ago

react-native-gifted-messenger v0.1.4

Weekly downloads
40
License
MIT
Repository
github
Last release
8 years ago

Gifted Messenger

Ready-to-use chat interface for iOS and Android React-Native apps

npm.io npm.io npm.io

Changelog

0.1.0 - Breaking changes for a better Gifted Messenger

  • Breaking: appendMessage, prependMessage are now deprecated, messages list are now managed only using states - See example
  • Breaking: All messages should now contain a uniqueId property
  • Breaking: setMessageStatus is now deprecated, use the message attribute status instead
  • Breaking: New prop isLoadingEarlierMessages to display a loader when loading earlier messages
  • New prop typingMessage for displaying 'User is typing a message...'
  • New prop leftControlBar - PR @gnl
  • Android improvements
  • react-native-parsed-text has been re-implemented
  • ESLint implementation - PR @sethx
  • ES6 & Example refactoring
  • Fixing scroll when loading earlier messages
  • Various fixes and improvements by @swapkats, @ianlin, @zxcpoiu, @cnjon
  • Special thanks to @yogiben, @koppelaar & @sethx for their contributions

0.1.2

  • New prop: dateLocale - @gnl
  • New prop: renderCustomDate - @pcxiong
  • center position for messages (eg. for server messages) - @gnl
  • Method setTextInputValue - @wenkesj
  • Replace lodash with deep-equal - @austinkelleher

0.1.3

  • Fix initial scrollToBottom issue
  • Allow custom view for images - @aksonov

Example

See GiftedMessengerExample/GiftedMessengerContainer.js

Installation

npm install react-native-gifted-messenger --save

Props

Props nameTypeDescriptionPlatformDefault
autoFocusBooleanTextInput auto focusBothtrue
blurOnSubmitBooleanDismiss the keyboard when clicking on submitBothfalse
dateLocaleStringThe moment.js locale used for displaying timestamps (see Locale.js)Both''
displayNamesBooleanDisplay or not the name of the interlocutor(s)Bothtrue
displayNamesInsideBubbleBooleanDisplay the name of the interlocutor(s) inside the bubbleBothfalse
forceRenderImageBooleanAlways render the users images (avatar)Bothfalse
handleEmailPressFunctionCalled when a parsed email is pressediOS(email) => {}
handlePhonePressFunctionCalled when a parsed phone number is pressediOS(phone) => {}
handleSendFunctionCalled when a message is SentBoth(message, rowID) => {}
handleUrlPressFunctionCalled when a parsed url is pressediOS(url) => {}
hideTextInputBooleanHide or not the text inputBothfalse
isLoadingEarlierMessagesBooleanDisplay a loader when loading earlier messagesBothfalse
keyboardDismissModeStringMethod to dismiss the keyboard when dragging (none, interactive, on-drag)Bothinteractive
keyboardShouldPersistTapsBooleanWhen false, tapping the scrollview dismisses the keyboard.Bothtrue
leftControlBarElementOptional control element displayed left of the TextInputBothnull
loadEarlierMessagesButtonBooleanDisplay or not the button to load earlier messageBothfalse
loadEarlierMessagesButtonTextStringLabel of the 'Load Earlier Messages' buttonBoth'Load earlier messages'
maxHeightIntegerMax height of the componentBothDimensions.get('window').height
messagesArrayList of messages to displayBoth[]
onChangeTextFunctionCalled on every keypress in the TextInputBoth(text) => {}
onCustomSendFunctionIf you want to implement a progress bar. See PR #16Both(message) => {}
onErrorButtonPressFunctionCalled when the re-send button is pressedBoth(message, rowID) => {}
onImagePressFunctionCalled when the image of a message is pressedBoth(rowData, rowID) => {}
onLoadEarlierMessagesFunctionCalled when 'Load Earlier Message' button is pressedBoth(oldestMessage, callback) => {}
onMessageLongPressFunctionCalled when doing long press on a messageBoth(rowData) => {}
parseTextBooleanIf the text has to be parsed with taskrabbit/react-native-parsed-textiOStrue
placeholderStringTextInput placeholderBoth'Type a message...'
placeholderTextColorStringTextInput text color placeholderBoth'#ccc'
renderCustomTextFunctionImplement your own text renderingBoth(rowData) => {}
renderCustomDateFunctionImplement your own date renderingBoth(rowData, previousData) => {}
scrollAnimatedBooleando animation when scrollingBothtrue
sendButtonTextString'Send' button labelBoth'Send'
senderImageObjectImage of the senderBothnull
senderNameStringName of the sender of the messagesBoth'Sender'
stylesFunctionStyles of children components - See GiftedMessenger.js/componentWillMountBoth{}
submitOnReturnBooleanSend message when clicking on submitBothfalse
typingMessageStringDisplay a text at the bottom of the list. Eg: 'User is typing a message'Both''

Message object

var message = {
  uniqueId: 'XXXXX' // each messages should have an unique identifer - mandatory
  text: 'Message content',
  name: "Sender's name",
  image: {uri: 'https://facebook.github.io/react/img/logo_og.png'},
  position: 'left', // left for received messages, right for sent messages, center for server messages
  date: new Date(),
  view: null, // A custom Bubble view - the view will receive the message attributes as props
  imageView: null, // Returns custom Image view to display image (avatar) for the message
  status: 'Seen', // if status is 'ErrorButton', a re-send button will be displayed
  // ...any attributes you want
};

Android installation

  • Add windowSoftInputMode in your Android Manifest android/app/src/main/AndroidManifest.xml
<!-- ... -->
  android:label="@string/app_name"
  android:windowSoftInputMode="adjustResize"
  android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<!-- ... -->
  <GiftedMessenger
    // ...
    maxHeight={Dimensions.get('window').height - Navigator.NavigationBar.Styles.General.NavBarHeight - ExtraDimensions.get('STATUS_BAR_HEIGHT')}
    // ...
  />

Known issues

License

MIT

Feel free to ask me questions on Twitter @FaridSafi !

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.24

8 years ago

0.0.23

8 years ago

0.0.22

8 years ago

0.0.21

8 years ago

0.0.20

8 years ago

0.0.19

8 years ago

0.0.18

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago