Skip to content

Commit

Permalink
Merge pull request #16 from cometchat-pro/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
TirathBhuva authored Jun 11, 2021
2 parents f940366 + 0b678bb commit 8d69fcd
Show file tree
Hide file tree
Showing 70 changed files with 3,110 additions and 764 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ To install React-Native UI Kit, you need to first register on CometChat Dashboar
### ii. Add the CometChat Dependency

```javascript
npm install @cometchat-pro/react-native-chat@2.3.3 --save
npm install @cometchat-pro/react-native-chat@2.3.4 --save
```

### iii. Other required DEPENDENCIES
Expand Down Expand Up @@ -90,7 +90,7 @@ These packages help make the ui-kit smooth and functioning
[emoji-mart-native](https://www.npmjs.com/package/emoji-mart-native)</br>
[react-native-keep-awake](https://www.npmjs.com/package/react-native-keep-awake)</br>
[react-native-webview](https://www.npmjs.com/package/react-native-webview)</br>

[react-native-swipe-list-view](https://www.npmjs.com/package/react-native-swipe-list-view)</br>

<br/>

Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"name": "cometchat-pro-react-native-ui-kit",

"version": "2.3.3-1",

"version": "2.3.4-1",
"description": "Chat UI Kit for React Native App",
"main": "./src/index.js",
"scripts": {
Expand Down Expand Up @@ -31,7 +29,8 @@
"@react-navigation/bottom-tabs": "^5.11.2",
"@react-navigation/native": "^5.8.10",
"@react-navigation/stack": "^5.12.8",
"react-native-video-controls": "^2.7.1"
"react-native-video-controls": "^2.7.1",
"react-native-swipe-list-view": "^3.2.8"
},
"author": "Inscripts",
"license": "ISC",
Expand All @@ -52,7 +51,7 @@
},
"dependencies": {
"@cometchat-pro/react-native-calls": "2.0.3-beta1",
"@cometchat-pro/react-native-chat": "2.3.3",
"@cometchat-pro/react-native-chat": "2.3.4",
"@react-native-async-storage/async-storage": "^1.13.4",
"lodash": "^4.17.20",
"react-native-autolink": "^3.0.0",
Expand Down
Binary file removed src/components/.DS_Store
Binary file not shown.
18 changes: 15 additions & 3 deletions src/components/Calls/CometChatIncomingCall/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useContext } from 'react';
import {
View,
TouchableOpacity,
Expand All @@ -14,7 +14,7 @@ import { CometChatManager } from '../../../utils/controller';
import * as enums from '../../../utils/enums';
import * as actions from '../../../utils/actions';
import theme from '../../../resources/theme';
import { CometChatAvatar } from '../../Shared';
import CometChatAvatar from '../../Shared/CometChatAvatar';

import { CallAlertManager } from './controller';

Expand All @@ -25,19 +25,31 @@ import videoCallIcon from './resources/incomingvideocall.png';
import { incomingCallAlert } from '../../../resources/audio';
import { logger } from '../../../utils/common';
import DropDownAlert from '../../Shared/DropDownAlert';
import { CometChatContext } from '../../../utils/CometChatContext';

export default (props) => {
let callAlertManager = null;
const viewTheme = { ...theme, ...props.theme };
const incomingAlert = new Sound(incomingCallAlert);

const [incomingCall, setIncomingCall] = useState(null);

const [isMessagesSoundEnabled, setIsMessagesSoundEnabled] = useState(null);
const context = useContext(CometChatContext);
useEffect(() => {
checkRestrictions();
}, []);
const checkRestrictions = async () => {
let isEnabled = await context.FeatureRestriction.isCallsSoundEnabled();
setIsMessagesSoundEnabled(isEnabled);
};
/**
* Play call alerts
* @param
*/
const playIncomingAlert = () => {
if (!isMessagesSoundEnabled) {
return false;
}
try {
incomingAlert.setCurrentTime(0);
incomingAlert.setNumberOfLoops(-1);
Expand Down
48 changes: 23 additions & 25 deletions src/components/Calls/CometChatIncomingDirectCall/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useContext } from 'react';
import {
View,
TouchableOpacity,
Expand All @@ -14,7 +14,7 @@ import { CometChatManager } from '../../../utils/controller';
import * as enums from '../../../utils/enums';
import * as actions from '../../../utils/actions';
import theme from '../../../resources/theme';
import { CometChatAvatar } from '../../Shared';
import CometChatAvatar from '../../Shared/CometChatAvatar';

import { messageAlertManager } from './controller';

Expand All @@ -24,18 +24,30 @@ import audioCallIcon from './resources/incomingaudiocall.png';
import videoCallIcon from './resources/incomingvideocall.png';
import { incomingCallAlert } from '../../../resources/audio';
import { logger } from '../../../utils/common';
import { CometChatContext } from '../../../utils/CometChatContext';
export default (props) => {
let callAlertManager = null;
const viewTheme = { ...theme, ...props.theme };
const incomingAlert = new Sound(incomingCallAlert);

const [isMessagesSoundEnabled, setIsMessagesSoundEnabled] = useState(null);
const [incomingCall, setIncomingCall] = useState(null);

const context = useContext(CometChatContext);
useEffect(() => {
checkRestrictions();
}, []);
const checkRestrictions = async () => {
let isEnabled = await context.FeatureRestriction.isCallsSoundEnabled();
setIsMessagesSoundEnabled(isEnabled);
};
/**
* Play call alerts
* @param
*/
const playIncomingAlert = () => {
if (!isMessagesSoundEnabled) {
return false;
}
try {
incomingAlert.setCurrentTime(0);
incomingAlert.setNumberOfLoops(-1);
Expand Down Expand Up @@ -217,29 +229,15 @@ export default (props) => {
<Text numberOfLines={1} style={style.nameStyle}>
{incomingCall.sender.name}
</Text>
{incomingCall.type === 'video' ? (
<View style={style.callTypeStyle}>
<Image source={videoCallIcon} alt="Incoming video call" />
<View style={style.callMessageContainerStyle}>
<Text
numberOfLines={1}
style={style.callMessageTextStyle}>
Incoming video call
</Text>
</View>
</View>
) : (
<View style={style.callTypeStyle}>
<Image source={audioCallIcon} alt="Incoming audio call" />
<View style={style.callMessageContainerStyle}>
<Text
numberOfLines={1}
style={style.callMessageTextStyle}>
Incoming audio call
</Text>
</View>

<View style={style.callTypeStyle}>
<Image source={videoCallIcon} alt="Incoming video call" />
<View style={style.callMessageContainerStyle}>
<Text numberOfLines={1} style={style.callMessageTextStyle}>
Incoming video call
</Text>
</View>
)}
</View>
</View>
<View style={style.avatarStyle}>
<CometChatAvatar
Expand Down
3 changes: 1 addition & 2 deletions src/components/Calls/CometChatOutgoingCall/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { outgoingCallAlert } from '../../../resources/audio';
import { CometChatManager } from '../../../utils/controller';
import { CallScreenManager } from './controller';

import { CometChatAvatar } from '../../Shared';
import CometChatAvatar from '../../Shared/CometChatAvatar';

import * as enums from '../../../utils/enums';
import * as actions from '../../../utils/actions';
Expand Down Expand Up @@ -257,7 +257,6 @@ class CometChatOutgoingCall extends React.PureComponent {
callInProgress: null,
callSettings: null,
});

this.markMessageAsRead(endedCall);
this.props.actionGenerated(actions.CALL_ENDED, endedCall);
},
Expand Down
9 changes: 2 additions & 7 deletions src/components/Calls/CometChatOutgoingDirectCall/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CometChatOutgoingDirectCall extends React.Component {

const newMessageObj = { ...customMessage, error: error };
this.props.actionGenerated(
enums.ACTIONS['ERROR_IN_SENDING_MESSAGE'],
actions['ERROR_IN_SENDING_MESSAGE'],
newMessageObj,
);
});
Expand All @@ -88,12 +88,7 @@ class CometChatOutgoingDirectCall extends React.Component {
let defaultLayout = true;
let callListener = new CometChat.OngoingCallListener({
onCallEnded: (call) => {
this.props.actionGenerated(actions.DIRECT_CALL_ENDED, call);
this.setState({
outgoingCallScreen: false,
callInProgress: null,
callSettings: null,
});
this.props.close();
},
onError: (error) => {
console.log('Call Error: ', error);
Expand Down
27 changes: 23 additions & 4 deletions src/components/Chats/CometChatConversationList/controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CometChat } from '@cometchat-pro/react-native-chat';

import * as enums from '../../../utils/enums';

import { UIKitSettings } from '../../../utils/UIKitSettings';
export class ConversationListManager {
conversationRequest = null;

Expand All @@ -14,9 +14,28 @@ export class ConversationListManager {
callListenerId = `chatlist_call_${new Date().getTime()}`;

constructor() {
this.conversationRequest = new CometChat.ConversationsRequestBuilder()
.setLimit(30)
.build();
let UIKitSettingsBuilder = new UIKitSettings();
const chatListMode = UIKitSettingsBuilder.chatListMode;
const chatListFilterOptions = UIKitSettings.chatListFilterOptions;
switch (chatListMode) {
case chatListFilterOptions['USERS']:
this.conversationRequest = new CometChat.ConversationsRequestBuilder()
.setConversationType(CometChat.ACTION_TYPE.TYPE_USER)
.setLimit(30)
.build();
break;
case chatListFilterOptions['GROUPS']:
this.conversationRequest = new CometChat.ConversationsRequestBuilder()
.setConversationType(CometChat.ACTION_TYPE.TYPE_GROUP)
.setLimit(30)
.build();
break;
default:
this.conversationRequest = new CometChat.ConversationsRequestBuilder()
.setLimit(30)
.build();
break;
}
}

fetchNextConversation() {
Expand Down
Loading

0 comments on commit 8d69fcd

Please sign in to comment.