Skip to content

Commit

Permalink
Merge pull request #11 from cometchat-pro/V3.0.0-beta1-2
Browse files Browse the repository at this point in the history
optimistic ui
  • Loading branch information
TirathBhuva authored Apr 20, 2021
2 parents 65fbb9b + 162a4a5 commit 58d8cf3
Show file tree
Hide file tree
Showing 113 changed files with 2,377 additions and 674 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ These packages help make the ui-kit smooth and functioning
[react-native-autolink](https://www.npmjs.com/package/react-native-autolink)</br>
[react-native-screens](https://www.npmjs.com/package/react-native-screens)</br>
[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>

<br/>

## 2. Configure CometChat inside your app
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "cometchat-pro-react-native-ui-kit",
"version": "3.0.0-beta1-1",

"version": "3.0.0-beta1-2",

"description": "Chat UI Kit for React Native App",
"main": "./src/index.js",
"scripts": {
Expand All @@ -9,9 +11,10 @@
},
"repository": {
"type": "git",
"url": "git@git.geekyants.com:cometchat/react-native.git"
"url": "git@github.com:cometchat-pro/react-native-chat-sdk.git"
},
"peerDependencies": {
"react-native-keep-awake": "^4.0.0",
"@react-native-community/async-storage": "^1.12.1",
"react-native-sound": "^0.11.0",
"react-native-vector-icons": "^7.1.0",
Expand Down
129 changes: 71 additions & 58 deletions src/components/Calls/CometChatIncomingCall/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import audioCallIcon from './resources/incomingaudiocall.png';
import videoCallIcon from './resources/incomingvideocall.png';
import { incomingCallAlert } from '../../../resources/audio';
import { logger } from '../../../utils/common';
import DropDownAlert from '../../Shared/DropDownAlert';

export default (props) => {
let callAlertManager = null;
const viewTheme = { ...theme, ...props.theme };
Expand Down Expand Up @@ -105,6 +107,8 @@ export default (props) => {
})
.catch((error) => {
props.actionGenerated(actions.CALL_ERROR, error);
const errorCode = error?.message || 'ERROR';
this.dropDownAlertRef?.showMessage('error', errorCode);
});
} else if (incomingCall === null) {
playIncomingAlert();
Expand Down Expand Up @@ -170,10 +174,14 @@ export default (props) => {
setIncomingCall(null);
})
.catch((error) => {
const errorCode = error?.message || 'ERROR';
this.dropDownAlertRef?.showMessage('error', errorCode);
props.actionGenerated(actions.CALL_ERROR, error);
setIncomingCall(null);
});
} catch (error) {
const errorCode = error?.message || 'ERROR';
this.dropDownAlertRef?.showMessage('error', errorCode);
logger(error);
}
};
Expand All @@ -189,6 +197,8 @@ export default (props) => {
props.actionGenerated(actions.ACCEPT_INCOMING_CALL, incomingCall);
setIncomingCall(null);
} catch (error) {
const errorCode = error?.message || 'ERROR';
this.dropDownAlertRef?.showMessage('error', errorCode);
logger(error);
}
};
Expand All @@ -209,69 +219,72 @@ export default (props) => {

if (incomingCall) {
return (
<Modal transparent animated animationType="fade">
<SafeAreaView>
<View style={[style.callContainerStyle]}>
<View style={style.senderDetailsContainer}>
<View>
<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>
<>
<Modal transparent animated animationType="fade">
<SafeAreaView>
<View style={[style.callContainerStyle]}>
<View style={style.senderDetailsContainer}>
<View>
<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>
) : (
<View style={style.callTypeStyle}>
<Image source={audioCallIcon} alt="Incoming video call" />
<View style={style.callMessageContainerStyle}>
<Text
numberOfLines={1}
style={style.callMessageTextStyle}>
Incoming audio call
</Text>
) : (
<View style={style.callTypeStyle}>
<Image source={audioCallIcon} alt="Incoming video call" />
<View style={style.callMessageContainerStyle}>
<Text
numberOfLines={1}
style={style.callMessageTextStyle}>
Incoming audio call
</Text>
</View>
</View>
</View>
)}
)}
</View>
<View style={style.avatarStyle}>
<CometChatAvatar
cornerRadius={1000}
borderWidth={0}
textColor="white"
image={{ uri: incomingCall.sender.avatar }}
name={incomingCall.sender.name}
/>
</View>
</View>
<View style={style.avatarStyle}>
<CometChatAvatar
cornerRadius={1000}
borderWidth={0}
textColor="white"
image={{ uri: incomingCall.sender.avatar }}
name={incomingCall.sender.name}
/>
<View style={style.headerButtonStyle}>
<TouchableOpacity
style={[
style.buttonStyle,
{ backgroundColor: viewTheme.backgroundColor.red },
]}
onPress={rejectCall}>
<Text style={style.btnTextStyle}>Decline</Text>
</TouchableOpacity>
<TouchableOpacity
style={[
style.buttonStyle,
{ backgroundColor: viewTheme.backgroundColor.blue },
]}
onPress={acceptCall}>
<Text style={style.btnTextStyle}>Accept</Text>
</TouchableOpacity>
</View>
</View>
<View style={style.headerButtonStyle}>
<TouchableOpacity
style={[
style.buttonStyle,
{ backgroundColor: viewTheme.backgroundColor.red },
]}
onPress={rejectCall}>
<Text style={style.btnTextStyle}>Decline</Text>
</TouchableOpacity>
<TouchableOpacity
style={[
style.buttonStyle,
{ backgroundColor: viewTheme.backgroundColor.blue },
]}
onPress={acceptCall}>
<Text style={style.btnTextStyle}>Accept</Text>
</TouchableOpacity>
</View>
</View>
</SafeAreaView>
</Modal>
</SafeAreaView>
</Modal>
<DropDownAlert ref={(ref) => (this.dropDownAlertRef = ref)} />
</>
);
}

Expand Down
24 changes: 24 additions & 0 deletions src/components/Calls/CometChatIncomingDirectCall/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { CometChat } from '@cometchat-pro/react-native-chat';

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

export class messageAlertManager {
msgListenerId = 'incoming_message_' + new Date().getTime();

attachListeners(callback) {
CometChat.addMessageListener(
this.msgListenerId,
new CometChat.MessageListener({
onCustomMessageReceived: (customMessage) => {
if (customMessage.type == enums.CUSTOM_TYPE_MEETING) {
callback(enums.CUSTOM_MESSAGE_RECEIVED, customMessage);
}
},
}),
);
}

removeListeners() {
CometChat.removeMessageListener(this.msgListenerId);
}
}
Loading

0 comments on commit 58d8cf3

Please sign in to comment.