Skip to content

Commit

Permalink
Universal chat link and other ui and bugs resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
4RGUS committed Oct 4, 2021
1 parent ac68afc commit 66f4f38
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 79 deletions.
10 changes: 10 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,23 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="www.eto.li"
android:pathPrefix="/go"
/>
</intent-filter>
</activity>
</application>
</manifest>
12 changes: 9 additions & 3 deletions docs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ const APP_TOKEN = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7Il9pZCI6
// If ’true’, same as above logo will also be displayed in the top left of the navbar before the app title
const navbarLogoShow = false; //done

//universal link url
const unv_url = "https://www.eto.li/go?c=";
const unv_url1 = "https://www.eto.li/go/?c=";

// COLOUR THEME
const commonColors = {
"primaryColor" : "rgba(78, 138, 194, 1)",
"primaryDarkColor" : "rgba(55, 116, 173, 1)",
"primaryColor" : "#4E8AC2",
"primaryDarkColor" : "#3774AD",
"secondaryColor" : "#133452"
} //done

Expand Down Expand Up @@ -110,5 +114,7 @@ export{
appWalletName,
APP_TOKEN,
coinsMainName,
loginScreenBackgroundImage
loginScreenBackgroundImage,
unv_url,
unv_url1
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"android": "react-native run-android",
"clean-cache": "react-native start --reset-cache",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
Expand All @@ -14,6 +15,7 @@
"dependencies": {
"@invertase/react-native-apple-authentication": "^2.1.2",
"@react-native-async-storage/async-storage": "^1.15.5",
"@react-native-clipboard/clipboard": "^1.8.4",
"@react-native-community/audio-toolkit": "^2.0.3",
"@react-native-community/checkbox": "^0.5.8",
"@react-native-community/masked-view": "^0.1.11",
Expand Down Expand Up @@ -48,7 +50,7 @@
"react-native-gesture-handler": "^1.10.3",
"react-native-get-random-values": "^1.7.0",
"react-native-gifted-chat": "^0.16.3",
"react-native-image-picker": "^4.0.4",
"react-native-image-picker": "^3.7.0",
"react-native-linear-gradient": "^2.5.6",
"react-native-material-menu": "^1.2.0",
"react-native-modal": "^12.0.2",
Expand Down
28 changes: 25 additions & 3 deletions src/Screens/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
setRecentRealtimeChatAction,
tokenAmountUpdateAction,
updateMessageComposingState,
setCurrentChatDetails
} from '../actions/chatAction';
import {queryRoomAllMessages} from '../components/realmModels/messages';
import {
Expand Down Expand Up @@ -72,7 +73,8 @@ import {updateMessageObject} from '../components/realmModels/messages';
import {commonColors, textStyles} from '../../docs/config';
import {RNCamera} from 'react-native-camera';
import VideoRecorder from 'react-native-beautiful-video-recorder';

import parseChatLink from '../helpers/parseChatLink';
import openChatFromChatLink from '../helpers/openChatFromChatLink';
import Modal from 'react-native-modal';

import AudioRecorderPlayer, {
Expand Down Expand Up @@ -878,7 +880,7 @@ class Chat extends Component {
return (
<View
style={{
height: hp('5%'),
height: hp('5.5%'),
width: wp('100%'),
backgroundColor: 'transparent',
flexDirection: 'row',
Expand All @@ -898,7 +900,7 @@ class Chat extends Component {
<View style={styles.progressContainer}>
{this.state.progressVal ? (
<Text style={styles.progressNumberText}>
Uploading: {this.state.progressVal}
Uploading: {this.state.progressVal}%
</Text>
) : null}
</View>
Expand Down Expand Up @@ -1413,6 +1415,12 @@ class Chat extends Component {
}
}

handleChatLinks=(chatLink)=>{
const walletAddress = this.props.loginReducer.initialData.walletAddress;
const chatJID = parseChatLink(chatLink);
openChatFromChatLink(chatJID, walletAddress, this.props.setCurrentChatDetails, this.props.navigation);
}

render() {
return (
<View style={{flex: 1}}>
Expand Down Expand Up @@ -1467,6 +1475,19 @@ class Chat extends Component {
onLongPress={(e, m) => this.onLongPressMessage(e, m)}
onLongPressAvatar={e => this.onLongPressAvatar(e)}
renderMessageImage={this.renderMessageImage}
parsePatterns={(linkStyle) => [
{
pattern:/\bhttps:\/\/www\.eto\.li\/go\?c=0x[0-9a-f]+_0x[0-9a-f]+/gm,
style:linkStyle,
onPress: this.handleChatLinks
},
{
pattern:/\bhttps:\/\/www\.eto\.li\/go\?c=[0-9a-f]+/gm,
style:linkStyle,
onPress: this.handleChatLinks
},

]}
/>
<ModalList
type={this.state.modalType}
Expand Down Expand Up @@ -1560,4 +1581,5 @@ module.exports = connect(mapStateToProps, {
fetchTransaction,
setOtherUserDetails,
setIsPreviousUser,
setCurrentChatDetails
})(Chat);
40 changes: 32 additions & 8 deletions src/Screens/chatHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
TouchableOpacity,
Image,
ImageBackground,
RefreshControl,
Linking,
Alert,
PermissionsAndroid
} from 'react-native';
import {connect} from 'react-redux';
import Modal from 'react-native-modal';
Expand Down Expand Up @@ -49,12 +48,8 @@ import fetchFunction from '../config/api';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {commonColors, textStyles} from '../../docs/config';
import { underscoreManipulation } from '../helpers/underscoreLogic';
import * as xmppConstants from '../constants/xmppConstants'


import RNFetchBlob from 'rn-fetch-blob';

const hitAPI = new fetchFunction();
import * as xmppConstants from '../constants/xmppConstants';
import openChatFromChatLink from '../helpers/openChatFromChatLink';

const _ = require('lodash');
const subscriptionsStanzaID = 'subscriptions';
Expand All @@ -77,6 +72,7 @@ const RenderDragItem = ({
roomRoles,
movingActive,
}) => {
console.log(roomRoles, item, 'activeee');
return (
<TouchableOpacity
onPress={() => openChat(item.jid, item.name)}
Expand Down Expand Up @@ -218,10 +214,12 @@ const RenderDragItem = ({
</Text>
<Text
numberOfLines={1}

style={{
fontFamily: thinFont,
fontSize: hp('1.8%'),
color: '#4C5264',
width: wp('30%')
}}>
{item.lastUserText}
</Text>
Expand Down Expand Up @@ -405,6 +403,32 @@ class ChatHome extends Component {
const {token} = this.props.loginReducer;
this.props.getEmailList(token);

Linking.getInitialURL().then(url => {
if(url){
const chatJID = parseChatLink(url);
setTimeout(()=>{
openChatFromChatLink(
chatJID,
this.props.loginReducer.initialData.walletAddress,
this.props.setCurrentChatDetails,
this.props.navigation
);
}, 2000)
}
});

Linking.addEventListener('url', data=> {
if(data.url){
const chatJID = parseChatLink(data.url);
openChatFromChatLink(
chatJID,
this.props.loginReducer.initialData.walletAddress,
this.props.setCurrentChatDetails,
this.props.navigation
);
}
});

fetchRosterList().then((rosterListFromRealm) => {
let loading = false;
let pushChatName = '';
Expand Down
37 changes: 7 additions & 30 deletions src/Screens/createNewChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { View, Text, TextInput, TouchableOpacity, ScrollView, Image, Alert } fro
import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons';
import styles from './style/createNewChatStyle';
import {widthPercentageToDP as wp, heightPercentageToDP as hp} from 'react-native-responsive-screen';
import ImagePicker from 'react-native-image-picker';
import {launchImageLibrary} from 'react-native-image-picker';
import CustomHeader from '../components/shared/customHeader';
import {roomCreated} from '../actions/chatAction';
import { connect } from 'react-redux';
Expand All @@ -12,6 +12,7 @@ import * as xmppConstants from '../constants/xmppConstants';
import { sha256 } from 'react-native-sha256';
import {roomConfigurationForm, fetchRosterlist} from '../helpers/xmppStanzaRequestMessages';
import {underscoreManipulation} from '../helpers/underscoreLogic';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {commonColors} from '../../docs/config';

const {primaryColor} = commonColors;
Expand All @@ -20,31 +21,6 @@ const { xml } = require("@xmpp/client");

const subscriptionsStanzaID = 'subscriptions';

const checkDefaultRoom = [
// {exist:false, name:"3981a2b9c1ef7fce8dbf5e3d44fefc58746dee11b3de35655e166c25142612ba"}, //Communication
// {exist:false, name:"680c3097aabc902bb129eaa23a974408856fbdccb7630cfd074ddf0639fc8ec0"}, //Workplace Readiness
{
exist: false,
name:
'9c8f9e5ee96519c5251b79f9da4f0ad210cd7450ce7e04c8fbbcfbf748436ee0',
}, //GK Leadership
// {exist:false, name:"91bfaa5cbfaab8a5661c0c5e15e54196d4ed4f76bb86b6cef07d337ff5c7fd41"}, //Career Development
{
exist: false,
name:
'a258b30f88c30650e73073d5bdde5cfcc6987100ae62d37789e5c46a0d85b7c6',
}, //Global
{
exist: false,
name:
'aa2f4a79e1413b444fd531a394a01befa3b5e8b559dfbc67b54ce9a1b91cedf2',
}, //Southern Africa
// {exist:false, name:"c67531e3ec3d5090acc25d6768140ad37789000fb4c5e254af6be5538c49ee56"}, //Life Skills
// {exist:false, name:"cf5f45da57a2ca0e4a581d40099751bcb4919fbb984b547e1d9d12c8ca710412"}, //Personal Finance
// {exist:false, name:"d677190e0a9990e7d5fa9e4c1bbde44271fb8959c4acb6d43e02ed991128b4bf"}, //Service
// {exist:false, name:"ec75f79040af17557c450e94a4214a484350634a433592d2eb31784c5a46e865"}, //Leadership
];

const options = {
title: 'Select Avatar',
storageOptions: {
Expand Down Expand Up @@ -82,6 +58,7 @@ class CreateNewGroup extends Component {
}

createAndSubscribeRoom(manipulatedWalletAddress, roomHash, chatName, roomCreated, navigation){

let message = xml('presence',
{
id:"CreateRoom",
Expand Down Expand Up @@ -139,7 +116,7 @@ class CreateNewGroup extends Component {
if(chatName===""){
alert('Please fill Chat Name');
}else{
this.createAndSubscribeRoom(manipulatedWalletAddress, roomHash, chatName, roomCreated, navigation)
this.createAndSubscribeRoom(manipulatedWalletAddress, roomHash, chatName, roomCreated, navigation)
}
});

Expand All @@ -148,7 +125,7 @@ class CreateNewGroup extends Component {

//function to set avatar for chat
setChatAvatar=()=>{
ImagePicker.showImagePicker(options, (response) => {
launchImageLibrary(options, (response) => {
console.log('Response = ', response);

if (response.didCancel) {
Expand All @@ -162,7 +139,7 @@ class CreateNewGroup extends Component {

// You can also display the image using data:
// const source = { uri: 'data:image/jpeg;base64,' + response.data };

this.setState({
avatarSource: source,
});
Expand All @@ -181,7 +158,7 @@ class CreateNewGroup extends Component {
<View style={styles.section1}>
<TouchableOpacity onPress={this.setChatAvatar} style={{alignItems:'flex-start', flex:0.2}}>
<View style={styles.camOuter}>
{this.state.avatarSource!==null?
{this.state.avatarSource?
<Image source={this.state.avatarSource} style={{width:wp('15%'),height:wp('15%'),borderRadius:wp('15%')/2,}}/>:
<SimpleLineIcons name='camera' size={hp('3.5%')} color={primaryColor} />
}
Expand Down
6 changes: 3 additions & 3 deletions src/Screens/profileScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ class ProfileScreen extends Component {
backgroundColor: primaryColor,
borderRadius: hp('10.46%') / 2,
}}>
{/* {this.state.userAvatar ? (
{this.state.userAvatar ? (
<Image
source={{uri: this.state.userAvatar}}
style={{
Expand All @@ -1091,7 +1091,7 @@ class ProfileScreen extends Component {
borderRadius: hp('10.46%') / 2,
}}
/>
) : ( */}
) : (
<Text
style={{
fontSize: 40,
Expand All @@ -1100,7 +1100,7 @@ class ProfileScreen extends Component {
}}>
{firstName[0] + lastName[0]}
</Text>
{/* )} */}
)}
</View>
</View>
{/* Profile Picture */}
Expand Down
Loading

0 comments on commit 66f4f38

Please sign in to comment.