Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Chat #46

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c513c31
created chat ui
doljko Apr 9, 2024
5b91cea
fixed chat ui
doljko Apr 9, 2024
2b59f20
improved chat ui
doljko Apr 10, 2024
f4926db
fixed messenger container
doljko Apr 10, 2024
1acd762
changed colour
doljko Apr 11, 2024
2678336
implemented fe db
doljko Apr 12, 2024
45d26b5
added swipe
doljko Apr 12, 2024
88a811f
list updated
doljko Apr 12, 2024
34ada7a
added users function
doljko Apr 15, 2024
fb54d5c
fix delete button ui
doljko Apr 16, 2024
dadf6c8
Showed user list
doljko Apr 16, 2024
8206954
added edit button
doljko Apr 16, 2024
1ef9e1e
fixed update, create func
doljko Apr 16, 2024
960606a
add load, file upload
doljko Apr 16, 2024
610eae8
fixed add participant
doljko Apr 18, 2024
a4408d1
Added delete function
doljko Apr 18, 2024
e5f8412
fixed remove function
doljko Apr 18, 2024
5be97f5
fixed name
doljko Apr 18, 2024
857da6c
user ui fix
doljko Apr 18, 2024
985081b
showed particient by modal
doljko Apr 18, 2024
86dcfda
checked if participant already added
doljko Apr 18, 2024
1e022c5
added indicator
doljko Apr 18, 2024
b058c44
fixed bug navigation, button
doljko Apr 18, 2024
638d4c2
fix border
doljko Apr 18, 2024
5d9c4a8
change file upload
doljko Apr 18, 2024
4d60a3f
added send func
doljko Apr 19, 2024
a9ac399
fixed send fnc
doljko Apr 19, 2024
860edae
added socket fnc
doljko Apr 19, 2024
ff562ff
fix some issues
doljko Apr 21, 2024
f43fae0
added chat history
doljko Apr 21, 2024
17a0bb8
fixed issues for add and remove participants
doljko Apr 21, 2024
6765373
remove duplicate adapter instances
doljko Apr 21, 2024
2598d84
remove unused state
doljko Apr 21, 2024
b84dba5
checked name length
doljko Apr 22, 2024
7ea77c6
removed unused file
doljko Apr 22, 2024
6f0527e
removed unused line
doljko Apr 23, 2024
1ac810c
fix chat id
doljko Apr 24, 2024
1c446b4
fixed socket data
doljko Apr 25, 2024
f292267
fix android ui
doljko Apr 26, 2024
c158394
added file upload
doljko Apr 29, 2024
742b0a9
fix uploadFile body.
doljko Apr 29, 2024
375ad83
added axiosClient
doljko Apr 29, 2024
28296a8
fixed auth token
doljko Apr 29, 2024
1ac6639
removed unused line
doljko Apr 30, 2024
9f452c1
If no image is selected, the condition is checked
doljko Apr 30, 2024
4ecf2c8
added attach pic
doljko Apr 30, 2024
5308d75
fix api
doljko May 1, 2024
d64efa9
added open, download action
doljko May 1, 2024
45d40f3
removed axioas
doljko May 3, 2024
682ed31
fixed image download
doljko May 3, 2024
526932b
changed chat position
doljko May 3, 2024
7afb0dd
fixed participent, attachment
doljko May 6, 2024
d5e011b
changed name
doljko May 7, 2024
96003f0
fixed base64, image viewer.
doljko May 7, 2024
bf59bd3
removed log
doljko May 7, 2024
e97bc50
fixed image download, viewer
doljko May 8, 2024
06afe4b
fixed chat text moving
doljko May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'@babel/plugin-transform-async-generator-functions',
'@babel/plugin-transform-async-to-generator',
'react-native-reanimated/plugin',
'preval',
[
Expand Down
6 changes: 0 additions & 6 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,6 @@ PODS:
- React-Core
- RNCMaskedView (0.1.11):
- React
- RNCPicker (2.6.1):
- React-Core
- RNCPushNotificationIOS (1.11.0):
- React-Core
- RNDateTimePicker (6.7.5):
Expand Down Expand Up @@ -739,7 +737,6 @@ DEPENDENCIES:
- RNBootSplash (from `../node_modules/react-native-bootsplash`)
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- "RNCPicker (from `../node_modules/@react-native-picker/picker`)"
- "RNCPushNotificationIOS (from `../node_modules/@react-native-community/push-notification-ios`)"
- "RNDateTimePicker (from `../node_modules/@react-native-community/datetimepicker`)"
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
Expand Down Expand Up @@ -903,8 +900,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/@react-native-async-storage/async-storage"
RNCMaskedView:
:path: "../node_modules/@react-native-community/masked-view"
RNCPicker:
:path: "../node_modules/@react-native-picker/picker"
RNCPushNotificationIOS:
:path: "../node_modules/@react-native-community/push-notification-ios"
RNDateTimePicker:
Expand Down Expand Up @@ -1014,7 +1009,6 @@ SPEC CHECKSUMS:
RNBootSplash: 85f6b879c080e958afdb4c62ee04497b05fd7552
RNCAsyncStorage: 687bb9e85dd3d45b966662440dcfc0cd962347e6
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
RNCPicker: b18aaf30df596e9b1738e7c1f9ee55402a229dca
RNCPushNotificationIOS: 64218f3c776c03d7408284a819b2abfda1834bc8
RNDateTimePicker: 65e1d202799460b286ff5e741d8baf54695e8abd
RNDeviceInfo: aad3c663b25752a52bf8fce93f2354001dd185aa
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"react-native-geolocation-service": "^5.3.0-beta.1",
"react-native-gesture-handler": "^1.10.3",
"react-native-get-random-values": "^1.9.0",
"react-native-gifted-chat": "^2.4.0",
"react-native-google-places-autocomplete": "^2.2.0",
"react-native-image-picker": "^4.4.0",
"react-native-image-resizer": "^1.4.5",
Expand All @@ -86,7 +87,7 @@
"react-native-maps": "^2.0.0-beta.14",
"react-native-maps-directions": "^1.8.0",
"react-native-mmkv-storage": "^0.9.0",
"react-native-modal": "^12.0.2",
"react-native-modal": "^13.0.1",
"react-native-navigation-apps": "^1.0.27",
"react-native-open-maps": "^0.4.0",
"react-native-permissions": "^3.0.5",
Expand All @@ -104,14 +105,15 @@
"react-native-webview": "^13.6.0",
"react-native-youtube": "^2.0.2",
"react-redux": "^7.2.5",
"socketcluster-client": "^16.0.4",
"socketcluster-client": "^17.1.1",
"tailwind-rn": "^3.0.1",
"tailwindcss": "^2.2.4",
"uuid": "^9.0.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-transform-async-generator-functions": "^7.22.15",
"@babel/plugin-transform-async-to-generator": "^7.24.1",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/eslint-config": "^0.72.2",
Expand Down
6 changes: 6 additions & 0 deletions src/features/Core/MainStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import ProofScreen from 'shared/ProofScreen';
import MainScreen from './screens/MainScreen';
import SearchScreen from './screens/SearchScreen';
import IssueScreen from './screens/IssueScreen';
import ChatScreen from './screens/ChatScreen';
import ChatsScreen from './screens/ChatsScreen';
import ChannelScreen from './screens/ChannelScreen';

const RootStack = createStackNavigator();

Expand All @@ -30,6 +33,9 @@ const MainStack = ({ route }) => {
<RootStack.Screen name="ProofScreen" component={ProofScreen} options={{ headerShown: false }} initialParams={route.params ?? {}} />
<RootStack.Screen name="SearchScreen" component={SearchScreen} options={{ headerShown: false }} initialParams={route.params ?? {}} />
<RootStack.Screen name="IssueScreen" component={IssueScreen} options={{ headerShown: false }} initialParams={route.params ?? {}} />
<RootStack.Screen name="ChatScreen" component={ChatScreen} options={{ headerShown: false }} initialParams={route.params ?? {}} />
<RootStack.Screen name="ChatsScreen" component={ChatsScreen} options={{ headerShown: false }} initialParams={route.params ?? {}} />
<RootStack.Screen name="ChannelScreen" component={ChannelScreen} options={{ headerShown: false }} initialParams={route.params ?? {}} />
</RootStack.Group>
</RootStack.Navigator>
</SafeAreaProvider>
Expand Down
95 changes: 95 additions & 0 deletions src/features/Core/screens/ChannelScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { faTimes } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { useNavigation } from '@react-navigation/native';
import { useFleetbase } from 'hooks';
import React, { useEffect, useState } from 'react';
import Toast from 'react-native-toast-message';
import { ActivityIndicator, Keyboard, KeyboardAvoidingView, Pressable, Text, TextInput, TouchableOpacity, View } from 'react-native';
import tailwind from 'tailwind';
import { getColorCode, logError, translate } from 'utils';

const ChannelScreen = ({ route }) => {
const navigation = useNavigation();
const fleetbase = useFleetbase();
const [name, setName] = useState();
const [isLoading, setIsLoading] = useState(false);
const [channelId, setChannelId] = useState();

useEffect(() => {
if (route?.params) {
const { data } = route.params;
setChannelId(data?.id);
setName(data?.name);
}
}, [route]);

const saveChannel = () => {
setIsLoading(true);
const adapter = fleetbase.getAdapter();
const data = { name };
if (channelId) {
return adapter
.put(`chat-channels/${channelId}`, data)
.then(res => {
navigation.navigate('ChatScreen', { channel: res });
})
.catch(logError)
.finally(() => setIsLoading(false));
} else {
return adapter
.post('chat-channels', { name })
.then(res => {
navigation.navigate('ChatScreen', { channel: res });
Toast.show({
type: 'success',
text1: `Channel created successfully`,
});
})
.catch(logError)
.finally(() => setIsLoading(false));
}
};

return (
<View style={[tailwind('w-full h-full bg-gray-800')]}>
<Pressable onPress={Keyboard.dismiss} style={tailwind('w-full h-full relative')}>
<View style={tailwind('flex flex-row items-center justify-between p-4')}>
<Text style={tailwind('text-xl text-gray-50 font-semibold')}>{channelId ? translate('Core.ChannelScreen.update-channel') : translate('Core.ChannelScreen.title')}</Text>
<TouchableOpacity onPress={() => navigation.pop(2)} style={tailwind('mr-4')}>
<View style={tailwind('rounded-full bg-gray-900 w-10 h-10 flex items-center justify-center')}>
<FontAwesomeIcon icon={faTimes} style={tailwind('text-red-400')} />
</View>
</TouchableOpacity>
</View>
<View style={tailwind('flex w-full h-full')}>
<KeyboardAvoidingView style={tailwind('p-4')}>
<View style={tailwind('mb-4')}>
<Text style={tailwind('font-semibold text-base text-gray-50 mb-2')}>
{channelId ? translate('Core.ChannelScreen.update') : translate('Core.ChannelScreen.name')}
</Text>
<TextInput
value={name}
onChangeText={setName}
keyboardType={'default'}
placeholder={translate('Core.ChannelScreen.name')}
placeholderTextColor={getColorCode('text-gray-600')}
style={tailwind('form-input text-white')}
/>
</View>

<TouchableOpacity onPress={saveChannel} disabled={isLoading}>
<View style={tailwind('btn bg-gray-900 border border-gray-700 mt-4')}>
{isLoading && <ActivityIndicator color={getColorCode('text-gray-50')} style={tailwind('mr-2')} />}
<Text style={tailwind('font-semibold text-lg text-gray-50 text-center')}>
{channelId ? translate('Core.ChannelScreen.update-channel') : translate('Core.ChannelScreen.title')}
</Text>
</View>
</TouchableOpacity>
</KeyboardAvoidingView>
</View>
</Pressable>
</View>
);
};

export default ChannelScreen;
Loading
Loading