Skip to content

Commit

Permalink
Merge pull request #32 from hecom-rn/dev_msg_quote
Browse files Browse the repository at this point in the history
Dev msg quote
  • Loading branch information
summer88123 authored Oct 15, 2021
2 parents 0bed822 + 896e6d2 commit 799c4cd
Show file tree
Hide file tree
Showing 85 changed files with 3,408 additions and 893 deletions.
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/docs
/example
/node_modules
.eslintignore
.eslintrc.js
.travis.yml
.travis.yml
yarn.lock
2 changes: 1 addition & 1 deletion docs/zh-cn/struct/Event.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 事件

采用[react-native-general-listener](https://github.com/gaoxiaosong/react-native-general-listener)作为事件监听的类,这个库是支持多级层次的事件结构,并支持对所有下级事件的监听。
采用[@hecom/listener](https://github.com/hecom-rn/listener)作为事件监听的类,这个库是支持多级层次的事件结构,并支持对所有下级事件的监听。

事件类型都放在`src/constant.js`中,其中`BaseEvent`代表基础事件类型,是每个事件的根类型。

Expand Down
213 changes: 138 additions & 75 deletions example/yarn.lock

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"IMPageChooseConversationTitle": "选择聊天",
"IMPageChooseConversationCreateNew": "创建新聊天",
"IMPageChooseUserSelectFromOrg": "按部门选同事",
"IMPageChooseUserAll": "所有人",
"IMSettingAddGroupMember": "添加群成员",
"IMSettingAllMembers": "全体成员({{length}})",
"IMSettingAllMembers": "查看全体群成员({{length}})",
"IMSettingAllowInvite": "允许添加成员",
"IMSettingAvoid": "消息免打扰",
"IMSettingChooseGroupMember": "选择群成员",
Expand All @@ -37,12 +38,15 @@
"IMSettingGroupNameChangeTips": "请输入群聊名称",
"IMSettingGroupNameNotEmpty": "群聊名称不能为空",
"IMSettingLeaveGroupDestroy": "解散群聊",
"IMSettingGroupAnnouncement": "群公告",
"IMSettingGroupAnnouncementChange": "更改群公告",
"IMSettingLeaveGroupQuit": "退出群聊",
"IMSettingRemoveGroupMember": "删除群成员",
"IMSettingTop": "置顶聊天",
"IMSettingTransferOwner": "转交群主",
"IMSettingTransferOwnerAction": "转交",
"IMToastError": "{{action}}失败",
"IMToastMessageNotSupport": "当前版本暂不支持该消息",
"IMToastSuccess": "{{action}}成功"
}
"IMToastSuccess": "{{action}}成功",
"IMSettingGroupDataInfo": "资料"
}
71 changes: 46 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,68 @@
},
"homepage": "https://github.com/gaoxiaosong/react-native-im#readme",
"dependencies": {
"@hecom/badge": "^1.0.2",
"@hecom/image-arrow": "^1.0.3",
"@hecom-rn/react-native-full-image-picker":"1.3.1",
"@hecom-rn/react-native-general-actionsheet":"1.0.5",
"@hecom-rn/react-native-general-actionsheet": "1.0.5",
"dateformat": "^3.0.3",
"i18n-js": "^3.2.1",
"react-native-fs": "^2.13.3",
"react-native-general-listener": "^1.0.3",
"react-native-general-searchbar": "^1.0.6",
"react-native-general-storage": "^1.0.4",
"react-native-gesture-handler": "^1.6.0",
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-localize": "^1.1.2",
"react-native-photo-browse": "^1.1.0",
"react-native-picklist": "^1.2.5",
"react-native-popover-view": "^1.0.17",
"react-native-popup-dialog": "^0.16.6",
"react-native-pure-navigation-bar": "^1.4.9",
"react-native-root-toast": "^3.1.1",
"md5": "^2.3.0",
"react-native-section-list-get-item-layout": "^2.2.3",
"react-native-sound": "^0.10.9",
"react-native-sound-recorder": "^1.3.2",
"react-native-swipe-list-view": "^1.5.0",
"react-navigation-header-buttons": "^2.1.1",
"specials": "^2.0.4"
"recyclerlistview": "^3.0.0"
},
"peerDependencies": {
"@hecom-rn/react-native-full-image-picker": "*",
"@hecom/badge": "*",
"@hecom/image-arrow": "*",
"@hecom/listener": "*",
"@hecom/react-native-image-capinsets": "*",
"@hecom/react-native-picklist": "*",
"@hecom/react-native-pure-navigation-bar": "*",
"@hecom/storage": ">=1.1",
"@react-navigation/native": "*",
"react": "*",
"react-native": "*",
"react-native-fs": ">=2",
"react-native-general-searchbar": ">=1",
"react-native-gesture-handler": ">=1",
"react-native-keyboard-aware-scroll-view": "*",
"react-native-localize": "*",
"react-native-modals": "*",
"react-native-photo-browse": "*",
"react-native-popover-view": ">=3.0.3",
"react-native-root-toast": "*",
"react-native-sound": "*",
"react-native-sound-recorder": "*",
"react-native-swipe-list-view": "*",
"react-native-video": "*",
"react-navigation": "*"
"react-navigation-header-buttons": ">=2.1.1",
"specials": "^2.0.4",
"react-native-permissions": "*"
},
"devDependencies": {
"@hecom/badge": "^1.0.3",
"@hecom/image-arrow": "^1.0.3",
"@hecom/listener": "^1.0.0",
"@hecom/storage": "1.1.0",
"@types/i18n-js": "^3.0.1",
"@types/promise.prototype.finally": "^2.0.3",
"@types/react": "^16.8.14",
"@types/react-native": "^0.57.46",
"@types/react-navigation": "^3.0.6",
"eslint-plugin-automatic": "latest",
"react-native-fs": "^2.13.3",
"react-native-general-searchbar": "^1.0.6",
"react-native-gesture-handler": "^1.6.0",
"react-native-im-easemob": "^1.0.24",
"tslib": "^1.9.3"
"react-native-keyboard-aware-scroll-view": "^0.9.1",
"react-native-localize": "^1.1.2",
"react-native-modals": "^0.19.9",
"react-native-photo-browse": "1.3.0",
"react-native-picklist": "^1.2.5",
"react-native-popover-view": "^3.0.3",
"react-native-root-toast": "^3.2.1",
"react-native-sound": "^0.10.9",
"react-native-sound-recorder": "^1.3.2",
"react-native-swipe-list-view": "^1.5.0",
"react-navigation-header-buttons": "^2.1.1",
"tslib": "^1.9.3",
"react-native-permissions": "^2.2.2"
}
}
6 changes: 6 additions & 0 deletions plugin/easemob/IMConversationDelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export default function () {
Delegate.im.conversation.deleteOne = (imId) => {
return ChatManager.deleteConversation(imId);
};
Delegate.im.conversation.deleteAllMessages = (imId, chatType) => {
return ChatManager.deleteAllMessages(imId, chatType);
};
Delegate.im.conversation.updateMessageExt = (messageId, ext) => {
return ChatManager.updateMessageExt(messageId, ext);
};
// TODO updateConfig
Delegate.im.conversation.markAllRead = (imId, chatType) => {
return ChatManager.markAllMessagesAsRead(imId, chatType);
Expand Down
2 changes: 2 additions & 0 deletions plugin/easemob/ParseAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function convertText(message: Typings.Message.Origin) {
text: message.body.text,
atMemberList: message.ext ? message.ext.atMemberList : [],
isSystem: message.ext ? message.ext.isSystemMessage : false,
quoteMsg: message.ext ? message.ext.quoteMsg : undefined,
}
);
}
Expand Down Expand Up @@ -79,6 +80,7 @@ function convertVideo(message: Typings.Message.Origin) {
localPath: message.body.localPath,
remotePath: message.body.remotePath,
duration: 0, // TODO duration
shouldRead: message.ext.shouldRead,
}
);
}
Expand Down
1 change: 1 addition & 0 deletions plugin/easemob/SendAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function sendText(params: Typings.Action.Send.Params<Typings.Message.TextBody>)
chatType,
message.data.text,
{
quoteMsg:message.data.quoteMsg,
atMemberList: message.data.atMemberList,
...ext,
},
Expand Down
28 changes: 19 additions & 9 deletions plugin/message/display/ImageBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,31 @@ export default class extends React.PureComponent<Props, State> {
resizeMode={'contain'}
source={this.state.source}
style={[styles.image, {width, height}]}
onError={this.onError}
/>
</View>
) : null;
}

onError = () => this.setState({source: require('./image/load_error.png')})

public onPress() {
const {message: {data: {remotePath}, messageId}, messages = []} = this.props;
const images = messages.filter(({type}) => type === IMConstant.MessageType.image).reverse();
const currentIndex = images.findIndex(image => image.messageId === messageId);
showPhotoBrowserPage({
currentIndex: currentIndex < 0 ? 0 : currentIndex,
images: images.length === 0 ? [remotePath] : images.map(({data: {remotePath}}) => remotePath),
canSave: true,
renderIndicator: () => null,
});
const {message: {data: {remotePath, localPath}, messageId}, messages = []} = this.props;

if (!remotePath && !localPath) {
return;
}
const images = messages.filter(({type, data: {remotePath: remoteP, localPath: localP}}) => {
return type === IMConstant.MessageType.image &&
((remoteP && remoteP.length > 0) || (localP && localP.length > 0))
}).reverse();
const currentIndex = images.findIndex(image => image.messageId === messageId);
showPhotoBrowserPage({
currentIndex: currentIndex < 0 ? 0 : currentIndex,
images: images.length === 0 ? [remotePath] : images.map(({data: {remotePath, localPath}}) => remotePath ? remotePath : localPath),
canSave: true,
renderIndicator: () => null,
});
}
}

Expand Down
74 changes: 74 additions & 0 deletions plugin/message/display/QuoteMsgBubble.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';
import { Platform, StyleSheet, Text, TextStyle, TouchableWithoutFeedback } from 'react-native';
import { Message } from 'react-native-im/standard/typings';
import { Model as MsgModel } from '../../../standard';

interface Props {
message: Message.General;
maxWidth: number,
paddingLeft: number,
paddingRight: number,
innerMaxWidth: number,
}

export default class QuoteMsgBubble extends React.PureComponent<Props> {

constructor(props: Props) {
super(props);
}


render() {

const { message: { data: { quoteMsg } }, maxWidth, paddingRight } = this.props;

return quoteMsg ? (
<TouchableWithoutFeedback
onPress={this._onPress.bind(this)}
>
<Text
style={[styles.quoteText, { maxWidth: maxWidth, paddingLeft: paddingRight, paddingRight: paddingRight }]}
numberOfLines={1}
ellipsizeMode={'tail'}
>
{(MsgModel.Quote.msgDescResolver.get(quoteMsg.type) as Function)(quoteMsg)}
</Text>
</TouchableWithoutFeedback>
) : null;
}

protected _onPress() {
const { message: { data: { quoteMsg: quoteMsg } } } = this.props;
(MsgModel.Quote.msgClickHandleResolver.get(quoteMsg.type) as Function)(quoteMsg);
}
}

const styles = StyleSheet.create({
container: {
flexDirection: 'column',
alignItems: 'flex-end',
},
quoteText: {
height: 20,
fontSize: 13,
marginTop: 3,
paddingTop: 2,
alignContent: "center",
paddingBottom: 2,
borderRadius: 3,
backgroundColor: '#cccccc',
...Platform.select({
android: { textAlignVertical: 'center' },
}),
overflow: 'hidden',
} as TextStyle,
view: {
backgroundColor: 'transparent',
paddingHorizontal: 13,
paddingVertical: 10,
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
flexWrap: 'wrap',
},
});
Loading

0 comments on commit 799c4cd

Please sign in to comment.