@smart-link/rn-im 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -112,7 +112,7 @@ const ChatAvatar = ({ id, name, url: fileId, size = (0, rn_ui_1.dp)(40), disable
112
112
  });
113
113
  }
114
114
  };
115
- return (<react_native_1.TouchableOpacity disabled={disabled} onPress={onPress} onLongPress={onLongPress}>
115
+ return (<react_native_1.TouchableOpacity style={{ width: size, height: size }} disabled={disabled} onPress={onPress} onLongPress={onLongPress}>
116
116
  {ready ? <ChatAvatarId_1.default priority={priority} id={id} fileId={fileId} size={size} name={name} defaultAvatar={defaultAvatar}/> : <rn_ui_1.Avatar icon={<react_native_1.Image style={size ? { width: size, height: size } : {}} source={defaultAvatar}/>}/>}
117
117
  </react_native_1.TouchableOpacity>);
118
118
  };
@@ -48,6 +48,7 @@ const MessageItem = ({ isMultiple, multipleSelect, conversation, message, mine,
48
48
  const time = (0, useFormatMsgTime_1.default)(message.messageTime);
49
49
  const isNotify = (0, im_base_1.isNotifyMessage)(message.payloadType);
50
50
  const isB2C = (conversation === null || conversation === void 0 ? void 0 : conversation.type) === im_base_1.ConversationType.B2C;
51
+ const isC2C = (conversation === null || conversation === void 0 ? void 0 : conversation.type) === im_base_1.ConversationType.C2C;
51
52
  const isMultipleChecked = !!(multipleSelect === null || multipleSelect === void 0 ? void 0 : multipleSelect[message.messageSeq]);
52
53
  const notArrow = [im_base_1.PayloadType.PICTURE, im_base_1.PayloadType.VIDEO].includes(message.payloadType);
53
54
  const isUndo = message.messageStatus === im_base_1.MessageStatus.UNDO;
@@ -102,7 +103,7 @@ const MessageItem = ({ isMultiple, multipleSelect, conversation, message, mine,
102
103
  e.preventDefault();
103
104
  onLongPressPopover(message, e.nativeEvent);
104
105
  }}/>
105
- {mine && <MessageReceiptStatus_1.default {...message}/>}
106
+ {isC2C && mine && <MessageReceiptStatus_1.default {...message}/>}
106
107
  </react_native_1.View>
107
108
  </react_native_1.View>
108
109
  {message.messageStatus === im_base_1.MessageStatus.EMIT_ERROR && (<react_native_1.Text style={{ alignSelf: 'center' }}>
@@ -39,10 +39,8 @@ const im_base_1 = require("@smart-link/im-base");
39
39
  const clipboard_1 = __importDefault(require("@react-native-clipboard/clipboard"));
40
40
  const PayloadText = ({ payload, onLongPress, showArrow = true, direction, style }) => {
41
41
  const { t } = (0, useTranslation_1.default)();
42
- const navigation = (0, rn_ui_1.useNavigation)();
43
42
  const { text, quote } = payload;
44
43
  const onLongPressPhone = (phone) => {
45
- // TODO
46
44
  rn_ui_1.ActionSheet.open({
47
45
  title: phone + " " + t('mayPhone'),
48
46
  onClose: () => {
@@ -67,7 +65,8 @@ const PayloadText = ({ payload, onLongPress, showArrow = true, direction, style
67
65
  {
68
66
  text: t('addToContacts'),
69
67
  onPress: () => {
70
- // addPhoneContracts(phoneNum)
68
+ (0, phone_1.addContacts)(phone);
69
+ rn_ui_1.ActionSheet.destroy();
71
70
  }
72
71
  }
73
72
  ],
@@ -71,7 +71,7 @@ const styles = react_native_1.StyleSheet.create({
71
71
  backgroundColor: '#fff',
72
72
  borderRadius: (0, rn_ui_1.dp)(5),
73
73
  height: (0, rn_ui_1.dp)(120),
74
- paddingLeft: (0, rn_ui_1.dp)(50),
74
+ paddingLeft: (0, rn_ui_1.dp)(25),
75
75
  justifyContent: 'center'
76
76
  },
77
77
  text: {
@@ -69,11 +69,12 @@ const MessageBar = (0, react_1.forwardRef)(({ onKeyboardAt }, ref) => {
69
69
  const keyboardHeight = (0, react_1.useRef)(240);
70
70
  const handleChange = (0, react_1.useCallback)((text) => {
71
71
  tempText.current = text;
72
- if (text.length && !lazy.current) {
72
+ const trimTxt = text.trim();
73
+ if (trimTxt.length && !lazy.current) {
73
74
  setShowSend(true);
74
75
  lazy.current = true;
75
76
  }
76
- else if (!text.length) {
77
+ else if (!trimTxt.length) {
77
78
  setShowSend(false);
78
79
  lazy.current = false;
79
80
  }
@@ -1,2 +1,3 @@
1
1
  export declare const copyPhone: (phoneNum: string) => void;
2
2
  export declare const callPhone: (phoneNum: string) => void;
3
+ export declare const addContacts: (phoneNum: string) => Promise<void>;
@@ -1,11 +1,21 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.callPhone = exports.copyPhone = void 0;
15
+ exports.addContacts = exports.callPhone = exports.copyPhone = void 0;
7
16
  const clipboard_1 = __importDefault(require("@react-native-clipboard/clipboard"));
8
17
  const react_native_1 = require("react-native");
18
+ const react_native_contacts_1 = __importDefault(require("react-native-contacts"));
9
19
  const copyPhone = (phoneNum) => {
10
20
  clipboard_1.default.setString(phoneNum);
11
21
  };
@@ -22,3 +32,27 @@ const callPhone = (phoneNum) => {
22
32
  }).catch(error => console.log('tel error', error));
23
33
  };
24
34
  exports.callPhone = callPhone;
35
+ const addContacts = (phoneNum) => __awaiter(void 0, void 0, void 0, function* () {
36
+ const add = () => {
37
+ react_native_contacts_1.default.openContactForm({
38
+ phoneNumbers: [{
39
+ label: 'mobile',
40
+ number: phoneNum
41
+ }]
42
+ });
43
+ };
44
+ if (react_native_1.Platform.OS === 'android') {
45
+ const granted = yield react_native_1.PermissionsAndroid.request(react_native_1.PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS);
46
+ if (granted === react_native_1.PermissionsAndroid.RESULTS.GRANTED) {
47
+ console.log('You can use the contacts');
48
+ add();
49
+ }
50
+ else {
51
+ console.log('Contacts permission denied');
52
+ }
53
+ }
54
+ else {
55
+ add();
56
+ }
57
+ });
58
+ exports.addContacts = addContacts;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@smart-link/rn-im",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "dependencies": {
7
7
  "color": "^5.0.0",
8
8
  "lodash-es": "^4.17.21",
9
9
  "emoji-regex": "^10.4.0",
10
- "@smart-link/im-base": "^1.0.4"
10
+ "@smart-link/im-base": "^1.0.6"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@react-native/eslint-config": "0.73.2",
@@ -47,6 +47,7 @@
47
47
  "react-native-audio-recorder-player": "3.6.12",
48
48
  "react-native-image-crop-picker": "0.42.0",
49
49
  "react-native-compressor": "1.10.5",
50
+ "react-native-contacts": "^8.0.5",
50
51
  "react-native-fast-image": "8.6.3",
51
52
  "react-native-fs": "2.20.0",
52
53
  "react-native-file-viewer": "2.1.5",
@@ -62,8 +63,8 @@
62
63
  "react-redux": "^8.1.3",
63
64
  "redux": "^4.2.1",
64
65
  "redux-thunk": "^2.4.2",
65
- "@smart-link/rn-ui": "^1.0.6",
66
- "@smart-link/rn-base": "^1.0.7"
66
+ "@smart-link/rn-base": "^1.0.7",
67
+ "@smart-link/rn-ui": "^1.0.6"
67
68
  },
68
69
  "files": [
69
70
  "dist/**",