Skip to content

Commit 7afe9f1

Browse files
v1.0.0
1 parent fd9212d commit 7afe9f1

File tree

50 files changed

+1310
-749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1310
-749
lines changed

CometChatWorkspace/cometchat-app/App.js

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,42 @@ import {Provider} from 'react-redux';
55
import {store, persistor} from './store/store';
66
import StackNavigator from './StackNavigator';
77
import {COMETCHAT_CONSTANTS} from './CONSTS';
8-
import {LogBox} from 'react-native';
8+
import {
9+
LogBox,
10+
PermissionsAndroid,
11+
StyleSheet,
12+
Text,
13+
Platform,
14+
} from 'react-native';
915
import {PersistGate} from 'redux-persist/integration/react';
16+
import theme from './react-native-chat-ui-kit/src/resources/theme';
17+
18+
const styles = StyleSheet.create({
19+
defaultFontFamily: {
20+
fontFamily: theme.fontFamily,
21+
},
22+
});
23+
24+
const customProps = {style: styles.defaultFontFamily};
25+
26+
// To set default font family, avoiding issues with specific android fonts like OnePlus Slate
27+
function setDefaultFontFamily() {
28+
const TextRender = Text.render;
29+
const initialDefaultProps = Text.defaultProps;
30+
Text.defaultProps = {
31+
...initialDefaultProps,
32+
...customProps,
33+
};
34+
Text.render = function render(props) {
35+
let oldProps = props;
36+
props = {...props, style: [customProps.style, props.style]};
37+
try {
38+
return TextRender.apply(this, arguments);
39+
} finally {
40+
props = oldProps;
41+
}
42+
};
43+
}
1044

1145
const App = () => {
1246
LogBox.ignoreAllLogs();
@@ -15,9 +49,36 @@ const App = () => {
1549
.setRegion(COMETCHAT_CONSTANTS.REGION)
1650
.build();
1751

18-
CometChat.init(COMETCHAT_CONSTANTS.APP_ID, appSetting).catch(() => {
19-
return null;
20-
});
52+
useEffect(() => {
53+
console.log("init***")
54+
CometChat.init(COMETCHAT_CONSTANTS.APP_ID, appSetting).catch(() => {
55+
return null;
56+
});
57+
58+
if (Platform.OS === 'android') {
59+
setDefaultFontFamily();
60+
}
61+
62+
const getPermissions = async () => {
63+
if (Platform.OS === 'android') {
64+
let granted = await PermissionsAndroid.requestMultiple([
65+
PermissionsAndroid.PERMISSIONS.CAMERA,
66+
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
67+
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
68+
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
69+
]);
70+
if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
71+
granted = await PermissionsAndroid.requestMultiple([
72+
PermissionsAndroid.PERMISSIONS.CAMERA,
73+
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
74+
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
75+
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
76+
]);
77+
}
78+
}
79+
};
80+
getPermissions();
81+
}, []);
2182

2283
return (
2384
<Provider store={store}>

CometChatWorkspace/cometchat-app/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CometChatWorkspace/cometchat-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"lint": "eslint ."
1111
},
1212
"dependencies": {
13-
"@cometchat-pro/react-native-calls": "1.0.3",
14-
"@cometchat-pro/react-native-chat": "^2.1.6",
13+
"@cometchat-pro/react-native-calls": "1.0.7",
14+
"@cometchat-pro/react-native-chat": "2.1.7",
1515
"@react-native-community/async-storage": "^1.12.1",
1616
"@react-native-community/masked-view": "^0.1.10",
1717
"@react-native-picker/picker": "^1.9.4",

CometChatWorkspace/cometchat-app/react-native-chat-ui-kit/src/components/Calls/CometChatIncomingCall/index.js

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import React, { useState, useEffect } from 'react';
2-
import { View, TouchableOpacity, Image, Modal, SafeAreaView, Text } from 'react-native';
2+
import {
3+
View,
4+
TouchableOpacity,
5+
Image,
6+
Modal,
7+
SafeAreaView,
8+
Text,
9+
} from 'react-native';
310
import { CometChat } from '@cometchat-pro/react-native-chat';
411
import Sound from 'react-native-sound';
512

@@ -28,11 +35,13 @@ export default (props) => {
2835
Object.prototype.hasOwnProperty.call(props, 'widgetsettings') &&
2936
props.widgetsettings &&
3037
Object.prototype.hasOwnProperty.call(props.widgetsettings, 'main') &&
31-
(Object.prototype.hasOwnProperty.call(props.widgetsettings.main, 'enable_sound_for_calls') ===
32-
false ||
38+
(Object.prototype.hasOwnProperty.call(
39+
props.widgetsettings.main,
40+
'enable_sound_for_calls',
41+
) === false ||
3342
(Object.prototype.hasOwnProperty.call(
3443
props.widgetsettings.main,
35-
'enable_sound_for_calls'
44+
'enable_sound_for_calls',
3645
) &&
3746
props.widgetsettings.main.enable_sound_for_calls === false))
3847
) {
@@ -49,11 +58,13 @@ export default (props) => {
4958
Object.prototype.hasOwnProperty.call(props, 'widgetsettings') &&
5059
props.widgetsettings &&
5160
Object.prototype.hasOwnProperty.call(props.widgetsettings, 'main') &&
52-
(Object.prototype.hasOwnProperty.call(props.widgetsettings.main, 'enable_sound_for_calls') ===
53-
false ||
61+
(Object.prototype.hasOwnProperty.call(
62+
props.widgetsettings.main,
63+
'enable_sound_for_calls',
64+
) === false ||
5465
(Object.prototype.hasOwnProperty.call(
5566
props.widgetsettings.main,
56-
'enable_sound_for_calls'
67+
'enable_sound_for_calls',
5768
) &&
5869
props.widgetsettings.main.enable_sound_for_calls === false))
5970
) {
@@ -65,15 +76,19 @@ export default (props) => {
6576

6677
const markMessageAsRead = (message) => {
6778
const { receiverType } = message;
68-
const receiverId = receiverType === 'user' ? message.sender.uid : message.receiverId;
79+
const receiverId =
80+
receiverType === 'user' ? message.sender.uid : message.receiverId;
6981

7082
if (Object.prototype.hasOwnProperty.call(message, 'readAt') === false) {
7183
CometChat.markAsRead(message.id, receiverId, receiverType);
7284
}
7385
};
7486

7587
const incomingCallReceived = (call) => {
76-
if (props.loggedInUser && call.callInitiator.uid === props.loggedInUser.uid) {
88+
if (
89+
props.loggedInUser &&
90+
call.callInitiator.uid === props.loggedInUser.uid
91+
) {
7792
return;
7893
}
7994

@@ -116,9 +131,16 @@ export default (props) => {
116131
const rejectCall = () => {
117132
pauseIncomingAlert();
118133

119-
CometChatManager.rejectCall(incomingCall.sessionId, CometChat.CALL_STATUS.REJECTED)
134+
CometChatManager.rejectCall(
135+
incomingCall.sessionId,
136+
CometChat.CALL_STATUS.REJECTED,
137+
)
120138
.then((rejectedCall) => {
121-
props.actionGenerated('rejectedIncomingCall', incomingCall, rejectedCall);
139+
props.actionGenerated(
140+
'rejectedIncomingCall',
141+
incomingCall,
142+
rejectedCall,
143+
);
122144
setIncomingCall(null);
123145
})
124146
.catch((error) => {
@@ -130,8 +152,8 @@ export default (props) => {
130152
const acceptCall = () => {
131153
pauseIncomingAlert();
132154

133-
setIncomingCall(null);
134155
props.actionGenerated('acceptIncomingCall', incomingCall);
156+
setIncomingCall(null);
135157
};
136158

137159
useEffect(() => {
@@ -150,7 +172,8 @@ export default (props) => {
150172
return (
151173
<Modal transparent animated animationType="fade">
152174
<SafeAreaView>
153-
<View style={[style.callContainerStyle, { backgroundColor: '#444444' }]}>
175+
<View
176+
style={[style.callContainerStyle, { backgroundColor: '#444444' }]}>
154177
<View style={style.senderDetailsContainer}>
155178
<View>
156179
<Text numberOfLines={1} style={style.nameStyle}>
@@ -177,19 +200,35 @@ export default (props) => {
177200
)}
178201
</View>
179202
<View style={style.avatarStyle}>
180-
<CometChatAvatar cornerRadius={1000} image={{ uri: incomingCall.sender.avatar }} />
203+
<CometChatAvatar
204+
cornerRadius={1000}
205+
borderWidth={0}
206+
textColor="white"
207+
image={{ uri: incomingCall.sender.avatar }}
208+
name={incomingCall.sender.name}
209+
/>
181210
</View>
182211
</View>
183212
<View style={style.headerButtonStyle}>
184213
<TouchableOpacity
185-
style={[style.buttonStyle, { backgroundColor: ViewTheme.backgroundColor.red }]}
214+
style={[
215+
style.buttonStyle,
216+
{ backgroundColor: ViewTheme.backgroundColor.red },
217+
]}
186218
onPress={rejectCall}>
187-
<Text style={{ color: 'white', textAlign: 'center' }}>Decline</Text>
219+
<Text style={{ color: 'white', textAlign: 'center' }}>
220+
Decline
221+
</Text>
188222
</TouchableOpacity>
189223
<TouchableOpacity
190-
style={[style.buttonStyle, { backgroundColor: ViewTheme.backgroundColor.blue }]}
224+
style={[
225+
style.buttonStyle,
226+
{ backgroundColor: ViewTheme.backgroundColor.blue },
227+
]}
191228
onPress={acceptCall}>
192-
<Text style={{ color: 'white', textAlign: 'center' }}>Accept</Text>
229+
<Text style={{ color: 'white', textAlign: 'center' }}>
230+
Accept
231+
</Text>
193232
</TouchableOpacity>
194233
</View>
195234
</View>

CometChatWorkspace/cometchat-app/react-native-chat-ui-kit/src/components/Calls/CometChatIncomingCall/styles.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export default StyleSheet.create({
2424
flexWrap: 'wrap',
2525
width: 34,
2626
height: 34,
27+
borderRadius: 22,
28+
backgroundColor: 'rgba(51,153,255,0.25)',
2729
},
2830
callTypeStyle: {
2931
flexDirection: 'row',

CometChatWorkspace/cometchat-app/react-native-chat-ui-kit/src/components/Chats/CometChatConversationList/controller.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export class ConversationListManager {
3535
},
3636
})
3737
);
38-
3938
CometChat.addGroupListener(
4039
this.groupListenerId,
4140
new CometChat.GroupListener({
@@ -58,10 +57,16 @@ export class ConversationListManager {
5857
callback(enums.GROUP_MEMBER_UNBANNED, unbannedFrom, message, { user: unbannedUser });
5958
},
6059
onMemberAddedToGroup: (message, userAdded, userAddedBy, userAddedIn) => {
61-
callback(enums.GROUP_MEMBER_ADDED, userAddedIn, message, {
62-
user: userAdded,
63-
hasJoined: true,
64-
});
60+
callback(
61+
enums.GROUP_MEMBER_ADDED,
62+
userAddedIn,
63+
message,
64+
{
65+
user: userAdded,
66+
hasJoined: true,
67+
},
68+
userAddedBy,
69+
);
6570
},
6671
onGroupMemberLeft: (message, leavingUser, group) => {
6772
callback(enums.GROUP_MEMBER_LEFT, group, message, { user: leavingUser });

0 commit comments

Comments
 (0)