Coder Social home page Coder Social logo

react-native-easy-chat-ui's Introduction

react-native-easy-chat-ui

中文文档

npm npm npm npm

ScreenShots

react-native-easy-chat-ui react-native-easy-chat-ui react-native-easy-chat-ui react-native-easy-chat-ui react-native-easy-chat-ui react-native-easy-chat-ui

Installation

  • yarn add @react-native-community/viewpager
  • react-native link @react-native-community/viewpager
  • npm: npm install react-native-easy-chat-ui --save
  • Yarn: yarn add react-native-easy-chat-ui

Dependency

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

Example

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View,
  StatusBar,
  PermissionsAndroid
} from 'react-native';
import { Header, NavigationActions } from 'react-navigation'
import {AudioRecorder, AudioUtils} from 'react-native-audio'
import RNFS from 'react-native-fs'
import Sound from 'react-native-sound'
import { ChatScreen } from 'react-native-easy-chat-ui'


class Example extends React.Component {
  state = {
     messages: [
            {
              id: `1`,
              type: 'text',
              content: 'hello world',
              targetId: '12345678',
              chatInfo: {
                avatar: require('../../source/defaultAvatar.png'),
                id: '12345678',
                nickName: 'Test'
              },
              renderTime: true,
              sendStatus: 0,
              time: '1542006036549'
            },
            {
              id: `2`,
              type: 'text',
              content: 'hi/{se}',
              targetId: '12345678',
              chatInfo: {
                avatar: require('../../source/defaultAvatar.png'),
                id: '12345678',
                nickName: 'Test'
              },
              renderTime: true,
              sendStatus: 0,
              time: '1542106036549'
            },
            {
              id: `3`,
              type: 'image',
              content: {
                uri: 'https://upload-images.jianshu.io/upload_images/11942126-044bd33212dcbfb8.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240',
                width: 100,
                height: 80,
              } ,
              targetId: '12345678',
              chatInfo: {
                avatar: require('../../source/defaultAvatar.png'),
                id: '12345678',
                nickName: 'Test'
              },
              renderTime: false,
              sendStatus: 0,
              time: '1542106037000'
            },
            {
              id: `4`,
              type: 'text',
              content: '你好/{weixiao}',
              targetId: '88886666',
              chatInfo: {
                avatar: require('../../source/avatar.png'),
                id: '12345678'
              },
              renderTime: true,
              sendStatus: -2,
              time: '1542177036549'
            },
            {
              id: `5`,
              type: 'voice',
              content: {
                uri: 'http://m10.music.126.net/20190810141311/78bf2f6e1080052bc0259afa91cf030d/ymusic/d60e/d53a/a031/1578f4093912b3c1f41a0bfd6c10115d.mp3',
                length: 10
              },
              targetId: '12345678',
              chatInfo: {
                avatar: require('../../source/defaultAvatar.png'),
                id: '12345678',
                nickName: 'Test'
              },
              renderTime: true,
              sendStatus: 1,
              time: '1542260667161'
            },
            {
              id: `6`,
              type: 'voice',
              content: {
                uri: 'http://m10.music.126.net/20190810141311/78bf2f6e1080052bc0259afa91cf030d/ymusic/d60e/d53a/a031/1578f4093912b3c1f41a0bfd6c10115d.mp3',
                length: 30
              },
              targetId: '88886666',
              chatInfo: {
                avatar: require('../../source/avatar.png'),
                id: '12345678'
              },
              renderTime: true,
              sendStatus: 0,
              time: '1542264667161'
            },
          ],
          // chatBg: require('../../source/bg.jpg'),
          inverted: false,  // require
          voiceHandle: true,
          currentTime: 0,
          recording: false,
          paused: false,
          stoppedRecording: false,
          finished: false,
          audioPath: '',
          voicePlaying: false,
          voiceLoading: false
  }


  sendMessage = (type, content, isInverted) => {
      console.log(type, content, isInverted, 'msg')
    }

  render() {
    return (
      <ChatScreen
        ref={(e) => this.chat = e}
        messageList={this.state.messages}
        sendMessage={this.sendMessage}
      />
    )
  }
}

Advanced example (How to record voice)

cd Demo
yarn
react-native run-ios or react-native run-android

About Message

{
    messages: [
      {
        id: `${new Date().getTime()}`,
        type: 'text',
        content: 'hello world',
        targetId: '12345678',
        chatInfo: {
          avatar: require('./app/source/image/avatar.png'),
          id: '12345678',
          nickName: 'Test'   // not require
        },
        renderTime: true,
        sendStatus: 0,
        time: new Date().getTime()
      }
    ]
}
  • id: message id
  • about message type: 'text', 'image', 'voice', 'video', 'location', 'share', 'videoCall', 'voiceCall', 'redEnvelope', 'file', 'system'
  • targetId: The id of the person who sent the message
  • content: see example
  • chatInfo: The profile of the person you're chatting with
  • renderTime: Whether to render time above message
  • sendStatus: 0 ---> sending, 1 ---> sendSuccess, -1 ---> You are deleted or on the blacklist, -2 ---> error
  • time: moment,messageList sorted by time

Props

  • message
props default Info
messageList [] Messages to display
inverted false When messageList exceeds the screen height, set it to true otherwise false (You can change this value when componentWillUnmount or delete message)
isIPhoneX false Is it full screen
chatBackgroundImage null Custom BackgroundImage
onScroll () => {} ListView Props
onEndReachedThreshold 0.1 ListView Props
chatWindowStyle undefined Container style
sendMessage (type, content, isInverted) => {} Callback when sending a message
reSendMessage (message) => {} Callback when you want send again
delMessage (indexs, isInverted) => {} Callback when delete message
renderAvatar (message) => {} Custom avatar view
avatarStyle undefined Style of avatar
chatId '123455678' The id of the person you're chatting with
chatType 'friend' Your relationship with the person you're chatting with
onMessagePress (type, index, content) => {} Callback when press a message
onMessageLongPress (type, index, content) => {} Callback when longPress a message and usePopView is false
pressAvatar (isSelf, targetId) => {} Callback when press avatar
headerHeight 66 navigation bar height + statusBar height
userProfile {id: '88888888', avatar: 'default.png'} Your own profile
showUserName false Whether show userName
loadHistory () => {} Callback when loading earlier messages
renderMessageTime (time) => {} Custom time inside above message
renderChatBg (bg) => {} Custom chat background image
renderErrorMessage (messageStatus) => {} Custom a message when the friend relationship is abnormal
panelSource [] Custom panel source
renderPanelRow () => {} Custom a tab icon
allPanelHeight 200 emojiPanel and plusPanel height
messageErrorIcon icon element Custom a icon when message failed to be sent
leftMessageBackground '#fffff' Custom background color on left
rightMessageBackground '#a0e75a' Custom background color on right
leftMessageTextStyle undefined Custom text message style on left
rightMessageTextStyle undefined Custom text message style on right
  • inputBarProps
props default Info
emojiIcon icon element Custom emoticons
placeholder '请输入...' Placeholder when text is empty
keyboardIcon icon Custom keyboard icon
plusIcon icon element Custom plus icon
sendIcon icon element Custom send icon
  • popViewProps
props default Info
usePopView true Display a popView when longPress a message
popoverStyle {backgroundColor: '#333'} popView style
renderDelPanel undefined Custom any what you want, (isSelect)=> {}
changeHeaderLeft () => {} Custom headerLeft
setPopItems (type, index, text) => {let items = [{title: '删除',onPress: () => {that.props.delMessage([index])}},{title: '多选',onPress: () => {that.multipleSelect(index)}}]if (type === 'text') {items = [{title: '复制',onPress: () => Clipboard.setString(text)},{title: '删除',onPress: () => {that.props.delMessage([index])}},{title: '多选', onPress: () => {that.multipleSelect(index)}}]}return items} Custom PopView
messageDelIcon icon element Custom delete icon
messageSelectIcon icon element Custom selected icon
renderMessageCheck undefined Custom selected icon, (isSelect)=> {}
  • voiceProps
props default Info
useVoice true send voice message
pressInText '按住 说话' Custom pressIn text
pressOutText '松开 发送' Custom pressOut text
voiceIcon icon element Custom voice icon
voiceLeftIcon undefined Custom icon of the message on the left
voiceRightIcon undefined Custom icon of the message on the right
voiceErrorIcon icon element Custom icon when record error
voiceErrorText '说话时间太短' Custom text when record error
voiceCancelIcon icon element Custom icon when cancel record
voiceCancelText '松开手指取消发送' Custom text when cancel record
voiceNoteText '手指上划,取消发送' Custom text when pressIn record button
voiceSpeakIcon [] Custom icon when pressIn record button
audioPath '' File path to store voice
audioOnProgress () => {} Callback when recording
audioOnFinish () => {} Callback when finish record
audioInitPath () => {} Callback when init file path
audioRecord () => {} Callback when start record
audioStopRecord () => {} Callback when stop record
audioPauseRecord () => {} Callback when pause record
audioResumeRecord () => {} Callback when resume record
audioCurrentTime 0 audio length
audioHandle true Whether to get a recording handle
setAudioHandle (status) => {} Callback when get handle or not
audioHasPermission false Whether has permission
requestAndroidPermission () => {} Callback when check permission on android
checkPermission () => {} Callback whether has permission
voiceLoading false Loading voice or not
voicePlaying false Playing voice or not
voiceLeftLoadingColor '#cccccc' Custom background color on left when load voice
voiceVolume 0 Volume (0~10)
voiceRightLoadingColor '#628b42' Custom background color on right when load voice
  • bubbleProps
props default Info
renderTextMessage undefined Custom message text, (data) => {}
renderImageMessage undefined Custom message image, (data) => {}
renderVoiceMessage undefined Custom message voice, (data) => {}
renderVoiceView undefined Custom voice container, (data) => {}
renderVideoMessage undefined Custom message video, (data) => {}
renderLocationMessage undefined Custom message location, (data) => {}
renderShareMessage undefined Custom message share, (data) => {}
renderVideoCallMessage undefined Custom message video call, (data) => {}
renderVoiceCallMessage undefined Custom message voice call, (data) => {}
renderRedEnvelopeMessage undefined Custom message red-envelope, (data) => {}
renderFileMessage undefined Custom message file, (data) => {}
renderPatMessage undefined Custom message pat, (data) => {}
renderCustomMessage undefined Custom message custom, (data) => {}
renderSystemMessage undefined Custom message system, (data) => {}

All Props

  propTypes = {
      /* defaultProps */
      messageList: PropTypes.array.isRequired,
      inverted: PropTypes.bool,
      isIPhoneX: PropTypes.bool.isRequired,
      lastReadAt: PropTypes.object,
      chatBackgroundImage: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
      onScroll: PropTypes.func,
      onEndReachedThreshold: PropTypes.number,
      chatWindowStyle: ViewPropTypes.style,
      sendMessage: PropTypes.func,
      renderAvatar: PropTypes.func,
      avatarStyle: ViewPropTypes.style,
      allPanelAnimateDuration: PropTypes.number,
      chatType: PropTypes.oneOf(['friend', 'group']),
      onMessagePress: PropTypes.func,
      onMessageLongPress: PropTypes.func,
      renderMessageTime: PropTypes.func,
      pressAvatar: PropTypes.func,
      renderErrorMessage: PropTypes.func,
      renderChatBg: PropTypes.func,
      reSendMessage: PropTypes.func,
      headerHeight: PropTypes.number.isRequired,
      iphoneXBottomPadding: PropTypes.number,
      showUserName: PropTypes.bool,
      showIsRead: PropTypes.bool,
      showInput: PropTypes.bool,
      isReadStyle: PropTypes.object,
      userProfile: PropTypes.shape({
        id: PropTypes.string.isRequired,
        avatar: PropTypes.isRequired,
        nickName: PropTypes.string
      }),
      panelSource: PropTypes.array,
      renderPanelRow: PropTypes.func,
      panelContainerStyle: ViewPropTypes.style,
      itemContainerStyle: ViewPropTypes.style,
      allPanelHeight: PropTypes.number,
      messageErrorIcon: PropTypes.element,
      loadHistory: PropTypes.func,
      leftMessageBackground: PropTypes.string,
      rightMessageBackground: PropTypes.string,
      leftMessageTextStyle: PropTypes.object,
      rightMessageTextStyle: PropTypes.object,
      renderLoadEarlier: PropTypes.func,
      extraData: PropTypes.any,
      containerBackgroundColor: PropTypes.string,
      showsVerticalScrollIndicator: PropTypes.bool,
      userNameStyle: PropTypes.object,
      panelContainerBackgroundColor: PropTypes.string,
      /* popProps */
      usePopView: PropTypes.bool,
      popoverStyle: ViewPropTypes.style,
      renderDelPanel: PropTypes.func,
      changeHeaderLeft: PropTypes.func,
      setPopItems: PropTypes.func,
      messageDelIcon: PropTypes.element,
      messageSelectIcon: PropTypes.element,
      delMessage: PropTypes.func,
      renderMessageCheck: PropTypes.func,
    
      /* inputBarProps */
      emojiIcon: PropTypes.element,
      placeholder: PropTypes.string,
      keyboardIcon: PropTypes.element,
      plusIcon: PropTypes.element,
      sendIcon: PropTypes.element,
      sendUnableIcon: PropTypes.element,
      inputStyle: ViewPropTypes.style,
      inputOutContainerStyle: ViewPropTypes.style,
      inputContainerStyle: ViewPropTypes.style,
      inputHeightFix: PropTypes.number,
      useEmoji: PropTypes.bool,
      usePlus: PropTypes.bool,
      /* voiceProps */
      useVoice: PropTypes.bool,
      pressInText: PropTypes.string,
      pressOutText: PropTypes.string,
      voiceIcon: PropTypes.element,
      voiceLeftIcon: PropTypes.element,
      voiceRightIcon: PropTypes.element,
      voiceErrorIcon: PropTypes.element,
      voiceCancelIcon: PropTypes.element,
      voiceSpeakIcon: PropTypes.array,
      audioPath: PropTypes.string,
      audioOnProgress: PropTypes.func,
      audioOnFinish: PropTypes.func,
      audioInitPath: PropTypes.func,
      audioRecord: PropTypes.func,
      audioStopRecord: PropTypes.func,
      audioPauseRecord: PropTypes.func,
      audioResumeRecord: PropTypes.func,
      audioCurrentTime: PropTypes.number,
      audioHandle: PropTypes.bool,
      setAudioHandle: PropTypes.func,
      audioHasPermission: PropTypes.bool,
      checkPermission: PropTypes.func,
      requestAndroidPermission: PropTypes.func,
      voiceErrorText: PropTypes.string,
      voiceCancelText: PropTypes.string,
      voiceNoteText: PropTypes.string,
      voiceLoading: PropTypes.bool,
      voicePlaying: PropTypes.bool,
      voiceLeftLoadingColor: PropTypes.string,
      voiceVolume: PropTypes.number,
      voiceRightLoadingColor: PropTypes.string,
      /* bubbleProps */
      renderTextMessage: PropTypes.func,
      renderImageMessage: PropTypes.func,
      renderVoiceMessage: PropTypes.func,
      renderVoiceView: PropTypes.func,
      renderVideoMessage: PropTypes.func,
      renderLocationMessage: PropTypes.func,
      renderShareMessage: PropTypes.func,
      renderVideoCallMessage: PropTypes.func,
      renderVoiceCallMessage: PropTypes.func,
      renderRedEnvelopeMessage: PropTypes.func,
      renderFileMessage: PropTypes.func,
      renderSystemMessage: PropTypes.func,
      renderCustomMessage: PropTypes.func,
      renderPatMessage: PropTypes.func,
      /* delPanelProps */
      delPanelStyle: ViewPropTypes.style,
      delPanelButtonStyle: ViewPropTypes.style,
      flatListProps: PropTypes.object
  }

Notes for Android

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

Donation

☕️☕️

react-native-easy-chat-ui react-native-easy-chat-ui

License

react-native-easy-chat-ui's People

Contributors

daiyz avatar youngjuning avatar youngxiaoran 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

react-native-easy-chat-ui's Issues

运行例子的时候报错

null is not an object(evaluating 'AudioRecorderManager.checkAuthorizationStatus')。我猜想是调用react-native-audio的授权时候有问题。但是不知道该怎么解决呀

关于消息列表的内存优化建议

首先我设置inverted={true},该值为false时载入界面会自动播放N长时间的往下滚动动画(不知是不是bug)
初始载入1000条消息的情况(注意views数量):

WechatIMG8

往上滑动一段距离后,views数量增长了极多,而且不会降下来:

WechatIMG9

另外,长按多选时,消息多了明显卡顿。

--------------分割线---------------------

之后我在源码中flatlist的渲染处加上了removeClippedSubviews={true},初始化载入情况:

101569329614_ pic_hd

往上滑动一段距离后,views数量基本不变:

111569329653_ pic_hd

是否可加上一些flatlist优化参数的配置入口

多选后,点击左上角取消可以关闭多选,但是再执行一次多选有问题

多选后,会有一个选中,并且左侧图标是勾选状态,点击左上角取消可以关闭多选,但是再执行一次多选后,也会有一个选中,但是左侧图标不是勾选状态,我看了一下源码
componentWillReceiveProps (nextProps) {
if (!nextProps.isOpen) {
this.setState({ isSelect: false })
} else {
if (nextProps.currentIndex === parseInt(nextProps.rowId) && this.props.currentIndex !== parseInt(nextProps.rowId)) {
this.setState({ isSelect: true })
}
}
}

再次执行多选时this.props.currentIndex !== parseInt(nextProps.rowId) 是false,导致无法执行this.setState({ isSelect: true }),所以没勾选上,这个希望您能够给点建议,或者修改一下,谢谢啦

说个坑吧,安卓闪退问题

原因未知的一个bug及解决办法

满足下面条件
1.安卓开启侧滑关闭(gestureEnabled: true)
2.聊天详情页面在路由栈非第一页,也就是聊天详情页面前面还有页面
3.点击聊天详情页面底部左侧按钮(也就是那个键盘/语音的按钮)
点击切换到语音输入界面,然后再点击切换到文本输入框(此时键盘自动打开了),然后再点击切换到语音,Duang,app闪退了(原生报错)

原因未知,解决办法就是将聊天详情的侧滑关闭功能禁用

下拉加载历史记录问题

实现了loadHistory方法,但是下拉并任何反应?也没有触发loadHistory?

<ChatScreen
ref={(e) => this.chat = e}
messageList={this.state.messages}
sendMessage={this.sendMessage}
reSendMessage={this.reSendMessage}
userProfile={this.state.userProfile}
chatId={this.state.chatInfo.id}
loadHistory={this.loadHistory}
/>

发送语音或者图片,前面的loading不消失

当发送语音时先将sendStatus设置为0此时有loading,当消息真正发出去后,动态改变该消息的sendStatus为1时,还是有loading,我用setState来改变的,render也执行了,loading一直在,同样的代码,我发送纯文本时先有loading,发送成功后loading消失,这个有遇到过吗,还是我的思路不对,请求指点一下哈哈

This package is not working in recent React Native version....

"react": "16.9.0",
"react-native": "0.61.5"

error message is as following...
WARN Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

  • Move data fetching code or side effects to componentDidUpdate.
  • If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
  • Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: ChatItem, EmojiPanel, PlusPanel, VoiceMessage

Please help me quickly....

发送文本消息时显示错误

您好,我在发送消息时出现点问题,例如:
我发送的消息为[xxxxxx]这个时候会出现以下情况
image
image
希望您可以解决一下

gesture-handler编译报错

跑demo的时候在到react-native-gesture-handler编译的时候出错,报错如下:
> Task :react-native-gesture-handler:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.

具体如下:
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEnabledRootView.java:10: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\lib\src\main\java\com\swmansion\gesturehandler\GestureHandlerOrchestrator.java:14: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:3: 错误: 程序包androidx.core.util不存在
import androidx.core.util.Pools;
^
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:11: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:19: 错误: 程序包Pools不存在
private static final Pools.SynchronizedPool EVENTS_POOL =
^
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerModule.java:36: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRegistry.java:11: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerPackage.java:16: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootInterface.java:3: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootView.java:10: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootViewManager.java:10: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:3: 错误: 程序包androidx.core.util不存在
import androidx.core.util.Pools;
^
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:11: 错误: 找不到符号
import androidx.annotation.Nullable;
^
符号: 类 Nullable
位置: 程序包 androidx.annotation
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:19: 错误: 程序包Pools不存在
private static final Pools.SynchronizedPool EVENTS_POOL =
^
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEnabledRootView.java:14: 错误: 找不到符号
private @nullable ReactInstanceManager mReactInstanceManager;
^
符号: 类 Nullable
位置: 类 RNGestureHandlerEnabledRootView
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEnabledRootView.java:15: 错误: 找不到符号
private @nullable RNGestureHandlerRootHelper mGestureRootHelper;
^
符号: 类 Nullable
位置: 类 RNGestureHandlerEnabledRootView
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEnabledRootView.java:63: 错误: 找不到符号
@nullable Bundle initialProperties) {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerEnabledRootView
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\lib\src\main\java\com\swmansion\gesturehandler\GestureHandlerOrchestrator.java:321: 错误: 找不到符号
private boolean isViewAttachedUnderWrapper(@nullable View view) {
^
符号: 类 Nullable
位置: 类 GestureHandlerOrchestrator
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:24: 错误: 找不到符号
@nullable RNGestureHandlerEventDataExtractor dataExtractor) {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerEvent
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:40: 错误: 找不到符号
@nullable RNGestureHandlerEventDataExtractor dataExtractor) {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerEvent
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerModule.java:529: 错误: 找不到符号
public @nullable Map getConstants() {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerModule
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerModule.java:632: 错误: 找不到符号
private @nullable RNGestureHandlerRootHelper findRootHelperForViewAncestor(int viewTag) {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerModule
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerModule.java:649: 错误: 找不到符号
private @nullable HandlerFactory findFactoryForHandler(GestureHandler handler) {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerModule
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRegistry.java:23: 错误: 找不到符号
public synchronized @nullable GestureHandler getHandler(int handlerTag) {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerRegistry
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootInterface.java:6: 错误: 找不到符号
@nullable RNGestureHandlerRootHelper getRootHelper();
^
符号: 类 Nullable
位置: 接口 RNGestureHandlerRootInterface
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootView.java:14: 错误: 找不到符号
private @nullable RNGestureHandlerRootHelper mRootHelper;
^
符号: 类 Nullable
位置: 类 RNGestureHandlerRootView
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerRootViewManager.java:42: 错误: 找不到符号
public @nullable Map getExportedCustomDirectEventTypeConstants() {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerRootViewManager
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:26: 错误: 找不到符号
@nullable RNGestureHandlerEventDataExtractor dataExtractor) {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerStateChangeEvent
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:44: 错误: 找不到符号
@nullable RNGestureHandlerEventDataExtractor dataExtractor) {
^
符号: 类 Nullable
位置: 类 RNGestureHandlerStateChangeEvent
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\lib\src\main\java\com\swmansion\gesturehandler\GestureHandlerOrchestrator.java:328: 错误: 找不到符号
@nullable ViewParent parent = view.getParent();
^
符号: 类 Nullable
位置: 类 GestureHandlerOrchestrator
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerEvent.java:20: 错误: 程序包Pools不存在
new Pools.SynchronizedPool<>(TOUCH_EVENTS_POOL_SIZE);
^
C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerStateChangeEvent.java:20: 错误: 程序包Pools不存在
new Pools.SynchronizedPool<>(TOUCH_EVENTS_POOL_SIZE);
^
注: C:\Users\34662\Desktop\react-native-easy-chat-ui-master\Demo\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerButtonViewManager.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
32 个错误

消息发送失败时,也会显示已读

您好,消息已读会不会存在一个问题,我先发送一条消息,假如失败了,那么此时肯定还是未读,那么我又发送一条消息,假如本次成功了,会显示已读,咱们这个显示已读是根据最后读取时间来判断的,那就回导致我上一个失败的也会显示已读,然后还有发送语音时,正常是对方听过后显示已读,假如我发送一个语音,紧接着又发送一个文本消息,文本一进页面就会显示已读,最后读取时间定位到文本,那语音此时也会显示已读,如果能将消息已读,未读,定位到每一个消息就好了,比如消息对象中本身就存在一个状态。

如何获取消息是否超过一屏

您好,我该如何获取消息是否超过一屏,我看源码
onLayout={(e) => {
this._scrollToBottom()
this.listHeight = e.nativeEvent.layout.height
}}
onContentSizeChange={(contentWidth, contentHeight) => { this._scrollToBottom({ contentWidth, contentHeight }) }}
只有这两个地方操作了高度
_scrollToBottom (listHeightAndWidth) {
const { inverted } = this.props
if (listHeightAndWidth !== undefined) {
const { contentHeight } = listHeightAndWidth
this.isInverted = contentHeight > this.listHeight
}
if (!inverted) {
setTimeout(() => {
this.chatList && this.chatList.scrollToEnd({
animated: this._userHasBeenInputed
})
}, this._userHasBeenInputed ? 0 : 130)
}
}

contentHeight 是内容高度是吧,那我外部得怎么获取呢
this.state = {
. . .
contentHeight: 0,
. . .
}
我是利用
<ChatScreen
ref={(e) => this.chat = e}
this.chat外部获取这个高度,但是始终是0,因为没有任何地方改变这个state,是不是我的想法有问题,希望给点建议,谢谢了

除了发送,删除操作能获取是否超过一屏,还有别的方式吗

1、那例如:
A用户给B用户发送消息,A通过发送方法可以判断是否倒置,但是B用户他只是接收消息啊,这个怎么判断是否倒置

2、删除的时候的isInverted这个参数有很大误差啊

3、如果我自定义了setPopItems,那么this.props.delMessage({ index, message }, this.isInverted)中的this.isInverted我只能通过this.chat.isInverted去拿对吧
show = (view, type, index, text, message) => {
if (!this.props.usePopView) {
this.props.onMessageLongPress(type, index, text, message)
} else {
view.measure((x, y, width, height, pageX, pageY) => {
let items = null
if (this.props.setPopItems) {
items = this.props.setPopItems(type, index, text, message)
} else {
items = [
{
title: '删除',
onPress: () => {
this.props.delMessage({ index, message }, this.isInverted)

RNC View Pager version conflict

In my project, i am having View Pager version 3.3.0 while in your library, the view pager version is 2.0.1. Hence causing error Tried to register two views with the same name RNCViewPager. Any idea how to resolve this issue?

用于群聊

pressAvatar没有返回对应用户的基本信息id等等

当长按多选删除时,删除消息后删除按钮没有消失

您好,请问一下,当长按多选删除时,删除消息后删除按钮没有消失,这个我得调用哪个事件来处理,然后还有左侧的选中状态按钮,刚开始多选时默认选中一个,那么我将其不选中,就是一个选中的都没有,此时删除按钮还是可以点击,这个我得需要怎么处理一下呢,谢谢了,我这是个新手。

安卓无法运行

你好

我尝试运用这chat UI 但是在安卓上完全无法运行

群聊消息昵称

RT
用于群聊场景,希望能给每条消息加上发送者的昵称,自己可以不加
setPopItems的items为空数组时是否可以不显示pop

ChatItem 有严重的效率问题

在聊天页面任何操作都会导致 ChatItem 重新渲染 比如切换文字和键盘
在聊天记录多的时候会导致卡顿严重


import { observer } from 'mobx-react/native';
@observer
    export default class ChatItem extends Component 

加入mobx 可以解决这个问题

因为项目已经被我改的面目全非 所以暂时没有办法PR

About Props of ChatScreen

There are many props in your module...
<ChatScreen
ref={e => (this.chat = e)}
CustomImageComponent={FastImage}
messageList={this.state.messages}
sendMessage={this.sendMessage}
// chatBackgroundImage={this.state.chatBg}
inverted={this.state.inverted}
panelSource={this.state.panelSource}
renderPanelRow={this.renderPanelRow}
onMessagePress={this.onPress}
voiceLoading={this.state.voiceLoading}
voicePlaying={this.state.voicePlaying}
audioPath={this.state.audioPath}
audioHasPermission={this.state.hasPermission}
requestAndroidPermission={this._requestAndroidPermission}
audioOnProgress={this.audioProgress}
audioOnFinish={this.audioFinish}
audioInitPath={this.initPath}
audioRecord={this._record}
audioStopRecord={this._stop}
audioCurrentTime={15}
audioHandle={this.state.audioHandle}
setAudioHandle={this.setAudioHandle}
voiceVolume={this.state.voiceVolume}
/>
I built my project with your package, then I can observe as followings...

executed order audioOnProgress -> audioOnFinish -> audioRecord -> audioStopRecord...
I think 'audioOnFinish ' have to execute at the end...
Please tell me about your opinion....

image

上滑取消发送,不太灵敏

您好,请问一下,在发送语音时,上滑取消,不太灵敏,总是在取消和发送之间跳,有时候还取消不了,能给出点建议吗

滑动聊天记录有时失效

在chatview的 render中 会导致有时滑动失效 至少在安卓上是这样的
改成View 会修复

其实我想表达的不是上面写的 我想表达的是 这个项目真的很牛逼

helo DaiYz !

My application was developed using EXPO,

but the render icon and my renderPanelRow when using ios it is on the top, is there any way to do it ... I don't want to develop with ios or androi. I use expo .. thank you hope to receive your soonest reply!

ViewPagerAndroid has been removed from React Native

react native 6.1版本, 报了这个错误.
Invariant Violation: ViewPagerAndroid has been removed from React Native. It can now be installed and imported from 'react-native-viewpager' instead of 'react-native'. See https://github.com/react-native-community/react-native-viewpager

This error is located at:
in EmojiPanel (at ChatView.js:1124)
in RCTView (at createAnimatedComponent.js:151)
in AnimatedComponent (at ChatView.js:956)
in RCTView (at ChatView.js:954)

no such file or directory, '/Users/user/folder/source' Failed building JavaScript bundle.

When using expo, i am unable to start my app because it throws

ENOENT: no such file or directory, scandir '/Users/abisola/Downloads/bereno-app/source'
Failed building JavaScript bundle.

After searching my app source i discovered it is because react-native-easy-chat-ui uses relative paths in it's code base e.g ../../source.

If i remove this package, all works well. I use expo to start my react app.
Please help, here is my package.json

package.txt

消息气泡

消息气泡不能修改文字颜色,望修改!

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.