Skip to content

Commit

Permalink
Merge pull request #14 from cometchat-pro/v3.0.0-beta4-1
Browse files Browse the repository at this point in the history
V3.0.0 beta4 1
  • Loading branch information
TirathBhuva authored Jun 1, 2021
2 parents 58d8cf3 + d28ee91 commit 842b804
Show file tree
Hide file tree
Showing 48 changed files with 1,097 additions and 245 deletions.
Binary file modified .DS_Store
Binary file not shown.
71 changes: 71 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
CometChatWorkspace/cometchat-app/android/app/build/
cometchat-app/android/app/build/
/android/app/build/
/app/build/
ios/Pods/*
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
package-lock.json # include if you are using npm - don't use both yarn and npm
npm-debug.log
yarn-error.log
yarn.lock # include if you are using yarn - don't use both npm and yarn

# BUCK
buck-out/
\.buckd/
*.keystore
!CometChatWorkspace/cometchat-app/android/app/debug.keystore

# Fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use Fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Pods
CometChatWorkspace/cometchat-app/ios/Pods/
cometchat-app/ios/Pods/
/ios/Pods/
ios/Pods/*

# Bundle artifact
*.jsbundle
src/components/.DS_Store
3 changes: 2 additions & 1 deletion 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@3.0.0-beta1 --save
npm install @cometchat-pro/react-native-chat@3.0.0-beta4 --save
```

### iii. Other required DEPENDENCIES
Expand Down Expand Up @@ -89,6 +89,7 @@ These packages help make the ui-kit smooth and functioning
[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>
[react-native-webview](https://www.npmjs.com/package/react-native-webview)</br>

<br/>

Expand Down
12 changes: 5 additions & 7 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": "3.0.0-beta1-2",

"version": "3.0.0-beta4-1",
"description": "Chat UI Kit for React Native App",
"main": "./src/index.js",
"scripts": {
Expand All @@ -11,7 +9,7 @@
},
"repository": {
"type": "git",
"url": "git@github.com:cometchat-pro/react-native-chat-sdk.git"
"url": "git@git.geekyants.com:cometchat/react-native.git"
},
"peerDependencies": {
"react-native-keep-awake": "^4.0.0",
Expand Down Expand Up @@ -51,9 +49,9 @@
"prettier": "^2.1.2"
},
"dependencies": {
"@cometchat-pro/react-native-calls": "2.0.1",
"@cometchat-pro/react-native-chat": "3.0.0-beta1",
"@react-native-community/async-storage": "^1.12.1",
"@cometchat-pro/react-native-calls": "2.0.3-beta1",
"@cometchat-pro/react-native-chat": "3.0.0-beta4",
"@react-native-async-storage/async-storage": "^1.13.4",
"lodash": "^4.17.20",
"react-native-autolink": "^3.0.0",
"redux": "^4.0.5",
Expand Down
Binary file removed src/.DS_Store
Binary file not shown.
Binary file removed src/components/.DS_Store
Binary file not shown.
12 changes: 9 additions & 3 deletions src/components/Chats/CometChatConversationListItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ class CometChatConversationListItem extends React.Component {
this.state = {
lastMessage: '',
lastMessageTimestamp: '',
isThreaded: false,
};
}

componentDidMount() {
const message = this.getLastMessage();
const timestamp = this.getLastMessageTimestamp();

this.setState({ lastMessage: message, lastMessageTimestamp: timestamp });
this.setState({
lastMessage: message || '',
lastMessageTimestamp: timestamp,
});
}

componentDidUpdate(prevProps) {
Expand All @@ -45,7 +49,7 @@ class CometChatConversationListItem extends React.Component {
const timestamp = this.getLastMessageTimestamp();

this.setState({
lastMessage: message,
lastMessage: message || '',
lastMessageTimestamp: timestamp,
});
}
Expand Down Expand Up @@ -228,6 +232,7 @@ class CometChatConversationListItem extends React.Component {
getMessage = (lastMessage) => {
try {
let message = null;
this.setState({ isThreaded: lastMessage.parentMessageId });
switch (lastMessage.type) {
case CometChat.MESSAGE_TYPE.TEXT:
message = lastMessage.text;
Expand Down Expand Up @@ -374,7 +379,8 @@ class CometChatConversationListItem extends React.Component {
alignItems: 'center',
}}>
<Text numberOfLines={1} style={styles.itemLastMsgTimeStyle}>
{this.state.lastMessage}
{`${this.state.isThreaded ? 'In a thread : ' : ''}` +
this.state.lastMessage}
</Text>
<CometChatBadgeCount
theme={this.props.theme}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,7 @@ class CometChatConversationListWithMessages extends React.Component {
});
break;
case actions.DIRECT_CALL_ENDED:
this.setState(
{ joinDirectCall: false, ongoingDirectCall: null },
() => {
this.props.navigation.navigate(
enums.NAVIGATION_CONSTANTS.COMET_CHAT_MESSAGES,
{
theme: this.theme,
item: { ...this.state.item },
tab: this.state.tab,
type: this.state.type,
composedThreadMessage: this.state.composedThreadMessage,
callMessage: this.state.callMessage,
loggedInUser: this.loggedInUser,
actionGenerated: this.actionHandler,
},
);
},
);
this.setState({ joinDirectCall: false, ongoingDirectCall: null });

break;
case actions.ACCEPT_DIRECT_CALL:
Expand Down
2 changes: 1 addition & 1 deletion src/components/Groups/CometChatAddGroupMemberList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class CometChatAddGroupMemberList extends React.Component {
this.props.actionGenerated('addGroupParticipants', membersToAdd);
}
})
.catch(() => {
.catch((error) => {
const errorCode = error?.message || 'ERROR';
this.dropDownAlertRef?.showMessage('error', errorCode);
logger('addMembersToGroup failed with exception:', error);
Expand Down
29 changes: 28 additions & 1 deletion src/components/Groups/CometChatGroupDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import { View, Text, TouchableOpacity, Dimensions, Modal } from 'react-native';
import theme from '../../../resources/theme';
import Icon from 'react-native-vector-icons/MaterialIcons';
import { CometChatSharedMedia } from '../../Shared';
import { CometChatSharedMedia, CometChatAvatar } from '../../Shared';
import style from './styles';
import BottomSheet from 'reanimated-bottom-sheet';
import { CometChat } from '@cometchat-pro/react-native-chat';
Expand All @@ -21,6 +21,7 @@ import {
import { deviceHeight } from '../../../utils/consts';
import { logger } from '../../../utils/common';
import DropDownAlert from '../../Shared/DropDownAlert';
import styles from '../../Shared/CometChatAvatar/styles';

const ADD_MEMBER = 'addMember';
const VIEW_MEMBER = 'viewMember';
Expand Down Expand Up @@ -739,6 +740,18 @@ export default class CometChatGroupDetails extends React.Component {
);
}

let avatar = (
<View style={style.avatarStyle}>
<CometChatAvatar
cornerRadius={32}
borderColor={theme.color.secondary}
borderWidth={1}
image={{ uri: this.props.item.avatar }}
name={this.props.item.name}
/>
</View>
);

return (
<Modal
transparent
Expand Down Expand Up @@ -785,6 +798,20 @@ export default class CometChatGroupDetails extends React.Component {
</TouchableOpacity>
<Text style={style.headerTitleStyle}>Details</Text>
</View>
<View style={styles.groupDetailContainer}>
{avatar}
<View style={styles.groupDetail}>
<View>
<Text style={style.userName}>
{this.props.item.name}
</Text>
</View>
<Text style={style.statusText} numberOfLines={1}>
{parseInt(this.props.item?.membersCount)} Members
</Text>
</View>
</View>

<View style={style.detailContainer}>
{members}
{options}
Expand Down
25 changes: 25 additions & 0 deletions src/components/Groups/CometChatGroupDetails/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,29 @@ export default StyleSheet.create({
overflow: 'hidden',
minHeight: Dimensions.get('window').height - 80,
},
userName: {
fontSize: 18 * heightRatio,
color: theme.color.primary,
fontWeight: 'bold',
},
statusText: {
fontSize: 14,
color: theme.color.blue,
},
avatarStyle: {
width: 48,
height: 48,
borderRadius: 24,
backgroundColor: 'rgba(51,153,255,0.25)',
},
groupDetailContainer: {
padding: 16,
flexDirection: 'row',
alignItems: 'center',
},
groupDetail: {
paddingLeft: 8,
justifyContent: 'center',
height: 48,
},
});
19 changes: 1 addition & 18 deletions src/components/Groups/CometChatGroupListWithMessages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,7 @@ class CometChatGroupListWithMessages extends React.Component {
});
break;
case actions.DIRECT_CALL_ENDED:
this.setState(
{ joinDirectCall: false, ongoingDirectCall: null },
() => {
this.props.navigation.navigate(
enums.NAVIGATION_CONSTANTS.COMET_CHAT_MESSAGES,
{
theme: this.theme,
item: { ...this.state.item },
tab: this.state.tab,
type: this.state.type,
composedThreadMessage: this.state.composedThreadMessage,
callMessage: this.state.callMessage,
loggedInUser: this.loggedInUser,
actionGenerated: this.actionHandler,
},
);
},
);
this.setState({ joinDirectCall: false, ongoingDirectCall: null });
break;
case actions.ACCEPT_DIRECT_CALL:
this.setState({ joinDirectCall: true }, () => {
Expand Down
42 changes: 33 additions & 9 deletions src/components/Messages/CometChatDeleteMessageBubble/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { View, Text } from 'react-native';
import { View, Text, Platform } from 'react-native';
import theme from '../../../resources/theme';
import style from './style';
import * as enums from '../../../utils/enums';
Expand All @@ -9,14 +9,38 @@ import { CometChatAvatar } from '../../Shared';
const CometChatDeleteMessageBubble = (props) => {
const message = { ...props.message, messageFrom: props.messageOf };
let messageContainer = null;
const timestamp = new Date(props.message.sentAt * 1000).toLocaleTimeString(
'en-US',
{
hour: 'numeric',
minute: 'numeric',
hour12: true,
},
);

let timestamp = new Date(
props.message.sentAt
? props.message.sentAt * 1000
: props.message._composedAt,
).toLocaleTimeString('en-US', {
hour: 'numeric',
minute: 'numeric',
hour12: true,
});
if (Platform.OS === 'android') {
let time = timestamp.split(':'); // convert to array

// fetch
var hours = Number(time[0]);
var minutes = Number(time[1]?.split(' ')[0]);

// calculate
var timeValue;

if (hours > 0 && hours <= 12) {
timeValue = '' + hours;
} else if (hours > 12) {
timeValue = '' + (hours - 12);
} else if (hours == 0) {
timeValue = '12';
}

timeValue += minutes < 10 ? ':0' + minutes : ':' + minutes; // get minutes
timeValue += hours >= 12 ? ' PM' : ' AM'; // get AM/PM
timestamp = timeValue;
}
const viewTheme = { ...theme, ...props.theme };

if (props.messageOf === enums.MESSAGE_OF_SENDER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
import { widthRatio } from '../../../utils/consts';

export default StyleSheet.create({
messageContainerStyle: { marginBottom: 16 },
messageContainerStyle: { marginBottom: 16, marginHorizontal: 8 },
messageSenderNameContainerStyle: { marginBottom: 5 },
messageContainerForReceiver: {
flexDirection: 'row',
Expand Down
Loading

0 comments on commit 842b804

Please sign in to comment.