Skip to content

Commit c1d7ce8

Browse files
authored
Merge pull request #20 from cometchat-pro/v2.3.0-2
optimistic UI
2 parents ee5b275 + 7330e18 commit c1d7ce8

File tree

92 files changed

+1081
-738
lines changed

Some content is hidden

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

92 files changed

+1081
-738
lines changed

CometChatWorkspace/cometchat-app/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
9292
* Upload all the APKs to the Play Store and people will download
9393
* the correct one based on the CPU architecture of their device.
9494
*/
95-
def enableSeparateBuildPerCPUArchitecture = false
95+
def enableSeparateBuildPerCPUArchitecture = true
9696

9797
/**
9898
* Run Proguard to shrink the Java bytecode in release builds.

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ These packages help make the ui-kit smooth and functioning
8888
[react-native-autolink](https://www.npmjs.com/package/react-native-autolink)</br>
8989
[react-native-screens](https://www.npmjs.com/package/react-native-screens)</br>
9090
[emoji-mart-native](https://www.npmjs.com/package/emoji-mart-native)</br>
91+
[react-native-keep-awake](https://www.npmjs.com/package/react-native-keep-awake)</br>
92+
9193
<br/>
9294

9395
## 2. Configure CometChat inside your app

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cometchat-pro-react-native-ui-kit",
3-
"version": "2.3.0-1",
3+
"version": "2.3.0-2",
44
"description": "Chat UI Kit for React Native App",
55
"main": "./src/index.js",
66
"scripts": {
@@ -12,6 +12,7 @@
1212
"url": "[email protected]:cometchat/react-native.git"
1313
},
1414
"peerDependencies": {
15+
"react-native-keep-awake": "^4.0.0",
1516
"@react-native-community/async-storage": "^1.12.1",
1617
"react-native-sound": "^0.11.0",
1718
"react-native-vector-icons": "^7.1.0",

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Calls/CometChatIncomingDirectCall/controller.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export class messageAlertManager {
1010
this.msgListenerId,
1111
new CometChat.MessageListener({
1212
onCustomMessageReceived: (customMessage) => {
13-
callback(enums.CUSTOM_MESSAGE_RECEIVED, customMessage);
13+
if (customMessage.type == enums.CUSTOM_TYPE_MEETING) {
14+
callback(enums.CUSTOM_MESSAGE_RECEIVED, customMessage);
15+
}
1416
},
1517
}),
1618
);

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Calls/CometChatOutgoingCall/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Text, View, Modal, TouchableOpacity } from 'react-native';
44
import { CometChat } from '@cometchat-pro/react-native-chat';
55
import Icon from 'react-native-vector-icons/MaterialIcons';
66
import Sound from 'react-native-sound';
7-
7+
import KeepAwake from 'react-native-keep-awake';
88
import { outgoingCallAlert } from '../../../resources/audio';
99
import { CometChatManager } from '../../../utils/controller';
1010
import { CallScreenManager } from './controller';
@@ -361,6 +361,7 @@ class CometChatOutgoingCall extends React.PureComponent {
361361
return (
362362
<Modal animated animationType="fade">
363363
<View style={{ height: '100%', width: '100%', position: 'relative' }}>
364+
<KeepAwake />
364365
<CometChat.CallingComponent
365366
callsettings={this.state.callSettings}
366367
/>

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Calls/CometChatOutgoingDirectCall/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { Text, View, Modal, TouchableOpacity } from 'react-native';
33
import { CometChat } from '@cometchat-pro/react-native-chat';
44
import * as actions from '../../../utils/actions';
5-
5+
import KeepAwake from 'react-native-keep-awake';
66
import * as enums from '../../../utils/enums';
77
import { theme } from '../../../resources/theme';
88

@@ -117,6 +117,7 @@ class CometChatOutgoingDirectCall extends React.Component {
117117
return (
118118
<Modal animated animationType="fade">
119119
<View style={{ height: '100%', width: '100%', position: 'relative' }}>
120+
<KeepAwake />
120121
{this.state.callSettings ? (
121122
<CometChat.CallingComponent
122123
callsettings={this.state.callSettings}

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Chats/CometChatConversationList/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ class CometChatConversationList extends React.Component {
858858
<View style={styles.headerContainer}></View>
859859
{this.listHeaderComponent()}
860860
<FlatList
861+
contentContainerStyle={styles.flexGrow1}
861862
data={this.state.conversationList}
862863
renderItem={({ item }) => {
863864
return (
@@ -872,7 +873,6 @@ class CometChatConversationList extends React.Component {
872873
);
873874
}}
874875
ListEmptyComponent={this.listEmptyContainer}
875-
ItemSeparatorComponent={this.itemSeparatorComponent}
876876
onScroll={this.handleScroll}
877877
onEndReached={this.endReached}
878878
onEndReachedThreshold={0.3}

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Chats/CometChatConversationList/styles.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default StyleSheet.create({
1212
alignItems: 'center',
1313
},
1414
conversationHeaderStyle: {
15-
paddingBottom: 12 * heightRatio,
15+
paddingBottom: 32,
1616
position: 'relative',
1717
paddingHorizontal: 22 * widthRatio,
1818
},
@@ -34,7 +34,7 @@ export default StyleSheet.create({
3434
},
3535
contactMsgStyle: {
3636
overflow: 'hidden',
37-
width: '100%',
37+
flex: 1,
3838
justifyContent: 'center',
3939
alignItems: 'center',
4040
},
@@ -52,8 +52,9 @@ export default StyleSheet.create({
5252
},
5353
headerContainer: {
5454
alignItems: 'center',
55-
height: 32 * heightRatio,
55+
height: 48,
5656
width: '100%',
5757
justifyContent: 'center',
5858
},
59+
flexGrow1: { flexGrow: 1 },
5960
});

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Chats/CometChatConversationListItem/index.js

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class CometChatConversationListItem extends React.Component {
157157
let time = timestamp.split(':'); // convert to array
158158

159159
var hours = Number(time[0]);
160-
var minutes = Number(time[1]);
160+
var minutes = Number(time[1]?.split(' ')[0]);
161161
var timeValue;
162162

163163
if (hours > 0 && hours <= 12) {
@@ -175,8 +175,10 @@ class CometChatConversationListItem extends React.Component {
175175
} else if (diffTimestamp < 48 * 60 * 60 * 1000) {
176176
timestamp = 'Yesterday';
177177
} else if (diffTimestamp < 7 * 24 * 60 * 60 * 1000) {
178-
timestamp = messageTimestamp.toLocaleString('en-US', {
179-
weekday: 'long',
178+
timestamp = messageTimestamp.toLocaleDateString('en-US', {
179+
year: '2-digit',
180+
month: '2-digit',
181+
day: '2-digit',
180182
});
181183
} else {
182184
timestamp = messageTimestamp.toLocaleDateString('en-US', {
@@ -311,19 +313,21 @@ class CometChatConversationListItem extends React.Component {
311313
}
312314

313315
let presence;
316+
314317
if (this.props.conversation.conversationType === 'user') {
315318
const { status } = this.props.conversation.conversationWith;
316319
presence = (
317320
<CometChatUserPresence
318321
status={status}
322+
style={{ top: 30 }}
319323
cornerRadius={18}
320-
borderColor={this.props.theme.color.darkSecondary}
321-
borderWidth={1}
324+
borderColor={this.props.theme.color.white}
325+
borderWidth={2}
322326
/>
323327
);
324328
}
325329
return (
326-
<View>
330+
<View key={this.props?.conversation?.conversationId}>
327331
<TouchableOpacity
328332
underlayColor={this.props.theme.backgroundColor.listUnderlayColor}
329333
style={styles.listItem}
@@ -348,18 +352,30 @@ class CometChatConversationListItem extends React.Component {
348352
styles.itemDetailsContainer,
349353
{ borderBottomColor: this.props.theme.borderColor.primary },
350354
]}>
351-
<View style={styles.itemMsgStyle}>
355+
<View
356+
style={{
357+
flexDirection: 'row',
358+
justifyContent: 'space-between',
359+
width: '100%',
360+
alignItems: 'center',
361+
}}>
352362
<Text numberOfLines={1} style={styles.itemNameStyle}>
353363
{this.props.conversation.conversationWith.name}
354364
</Text>
355-
<Text numberOfLines={1} style={styles.itemLastMsgTimeStyle}>
356-
{this.state.lastMessage}
357-
</Text>
358-
</View>
359-
<View style={styles.itemRowStyle}>
360365
<View style={styles.itemLastMsgStyle}>
361366
{lastMessageTimeStamp}
362367
</View>
368+
</View>
369+
<View
370+
style={{
371+
flexDirection: 'row',
372+
justifyContent: 'space-between',
373+
width: '100%',
374+
alignItems: 'center',
375+
}}>
376+
<Text numberOfLines={1} style={styles.itemLastMsgTimeStyle}>
377+
{this.state.lastMessage}
378+
</Text>
363379
<CometChatBadgeCount
364380
theme={this.props.theme}
365381
count={this.props.conversation.unreadMessageCount}

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Chats/CometChatConversationListItem/styles.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { StyleSheet } from 'react-native';
22
import { widthRatio } from '../../../utils/consts';
3+
import theme from '../../../resources/theme';
34

45
export default StyleSheet.create({
56
listItem: {
67
flexDirection: 'row',
78
alignItems: 'center',
89
width: '100%',
9-
maxHeight: 62,
10-
paddingHorizontal: 20,
10+
maxHeight: 64,
11+
paddingHorizontal: 16,
12+
justifyContent: 'center',
13+
marginBottom: 8,
1114
},
1215
avatarStyle: {
1316
flexWrap: 'wrap',
@@ -16,29 +19,34 @@ export default StyleSheet.create({
1619
height: 44,
1720
marginRight: 15 * widthRatio,
1821
justifyContent: 'center',
19-
borderWidth: 1,
22+
borderWidth: 0.5,
2023
},
2124
itemDetailsContainer: {
22-
height: '100%',
23-
borderBottomWidth: 0.5,
25+
borderBottomWidth: 1,
2426
flex: 1,
25-
paddingBottom: 15,
26-
paddingTop: 15,
27-
paddingHorizontal: 10,
28-
justifyContent: 'space-between',
27+
height: '100%',
28+
marginLeft: 10,
29+
justifyContent: 'center',
2930
alignItems: 'center',
30-
flexDirection: 'row',
31+
alignSelf: 'flex-end',
32+
paddingBottom: 10,
33+
color: theme.color.primary,
34+
// flexDirection: 'row',
3135
},
3236
itemLastMsgTimeStyle: {
33-
fontSize: 14,
37+
fontSize: 12,
3438
fontWeight: '200',
3539
maxWidth: '100%',
3640
marginLeft: 2,
41+
color: theme.color.helpText,
3742
},
3843
itemNameStyle: {
39-
fontSize: 18,
40-
fontWeight: '600',
41-
width: '100%',
44+
fontSize: 16,
45+
fontWeight: '500',
46+
width: '60%',
47+
color: theme.color.primary,
48+
marginBottom: 2,
49+
marginTop: 8,
4250
},
4351
itemMsgStyle: {
4452
width: '80%',
@@ -48,13 +56,14 @@ export default StyleSheet.create({
4856
alignItems: 'center',
4957
},
5058
itemLastMsgStyle: {
51-
marginBottom: 2,
59+
width: '40%',
60+
alignItems: 'flex-end',
5261
},
5362
itemThumbnailStyle: {
5463
flexWrap: 'wrap',
5564
flexDirection: 'row',
56-
width: 44,
57-
height: 44,
65+
width: 40,
66+
height: 40,
5867
backgroundColor: 'rgba(51,153,255,0.25)',
5968
borderRadius: 25,
6069
},

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/Chats/CometChatConversationListWithMessages/index.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ class CometChatConversationListWithMessages extends React.Component {
175175
case actions.MESSAGE_DELETED:
176176
this.updateLastMessage(item[0]);
177177
break;
178-
case actions.MESSAGE_COMPOSED:
179-
this.callInitiated(item);
180-
break;
181178
case actions.JOIN_DIRECT_CALL:
182179
this.setState({ joinDirectCall: true }, () => {
183180
this.videoCall(true);
@@ -230,20 +227,10 @@ class CometChatConversationListWithMessages extends React.Component {
230227
const usersList = [this.state.item.uid];
231228
CometChatManager.blockUsers(usersList)
232229
.then((response) => {
233-
if (response) {
234-
this.setState({ item: { ...this.state.item, blockedByMe: true } });
235-
this.dropDownAlertRef?.showMessage('success', 'Blocked user');
236-
} else {
237-
this.dropDownAlertRef?.showMessage(
238-
'error',
239-
'Failed to blocked user',
240-
);
241-
}
230+
this.setState({ item: { ...this.state.item, blockedByMe: true } });
242231
})
243232
.catch((error) => {
244233
logger('Blocking user fails with error', error);
245-
const errorCode = error?.message || 'ERROR';
246-
this.dropDownAlertRef?.showMessage('error', errorCode);
247234
});
248235
} catch (error) {
249236
logger(error);

CometChatWorkspace/cometchat-app/cometchat-pro-react-native-ui-kit/src/components/CometChatUI/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export default () => {
2323

2424
if (route.name === 'Chats') {
2525
return (
26-
<MCIIcons name="chat" size={24 * heightRatio} color={color} />
26+
<MCIIcons name="chat" size={25 * heightRatio} color={color} />
2727
);
2828
}
2929
if (route.name === 'More') {
3030
return (
3131
<MaterialIcons
3232
name="more-horiz"
33-
size={24 * heightRatio}
33+
size={25 * heightRatio}
3434
color={color}
3535
/>
3636
);
@@ -52,7 +52,7 @@ export default () => {
5252
inactiveTintColor: 'rgba(0,0,0,0.5)',
5353
activeBackgroundColor: theme.color.white,
5454
inactiveBackgroundColor: theme.color.white,
55-
labelStyle: { fontSize: 8 * heightRatio },
55+
labelStyle: { fontSize: 12 },
5656
}}>
5757
<Tab.Screen
5858
name="Chats"

0 commit comments

Comments
 (0)