From 55d69585def75ebb7a48c9c9122bb31a7548b635 Mon Sep 17 00:00:00 2001 From: aguilhot Date: Thu, 15 Dec 2022 09:45:30 +0100 Subject: [PATCH] ADD: New conversation preview Component --- .../ConversationPreviewComponent.tsx | 45 +++++++++++++++++++ .../ConverstationPreviewComponent.style.js | 23 ++++++++++ bob_party/src/screens/Chat.tsx | 4 +- 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 bob_party/src/components/ConversationPreviewComponent.tsx create mode 100644 bob_party/src/components/style/ConverstationPreviewComponent.style.js diff --git a/bob_party/src/components/ConversationPreviewComponent.tsx b/bob_party/src/components/ConversationPreviewComponent.tsx new file mode 100644 index 0000000..4edd8b0 --- /dev/null +++ b/bob_party/src/components/ConversationPreviewComponent.tsx @@ -0,0 +1,45 @@ +import { FC, ReactNode } from "react" +import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" +import React from "react" +import { Skin } from "../core/skin" +import { Conversation } from "../core/conversation" + +/* + Importing the correct stylesheet +*/ +import styles from "./style/ConverstationPreviewComponent.style" +import { SkinComponent } from "./Skin" +import { MANAGER_USER } from "../../appManagers" +import { User } from "../core/User/user" + +export const ConversationPreviewComponent : +/* Parameters : + * skin : Skin to be displayed +*/ +FC<{conv: Conversation, navigation: any}> = +({conv, navigation}) => +{ + const user1 = MANAGER_USER.getCurrentUser(); + let tmp; + + if (conv.getTabUser()[0] === user1) tmp = conv.getTabUser()[1]; + else tmp = conv.getTabUser()[0]; + + const user2 = tmp; + + + + return( + navigation.navigate(Conversation)}> + + + + + + {conv.getLastMessage().getMessageSender().getUsername()} + {conv.getLastMessage().getMessageContent()} + + + + ) +} \ No newline at end of file diff --git a/bob_party/src/components/style/ConverstationPreviewComponent.style.js b/bob_party/src/components/style/ConverstationPreviewComponent.style.js new file mode 100644 index 0000000..1a49e81 --- /dev/null +++ b/bob_party/src/components/style/ConverstationPreviewComponent.style.js @@ -0,0 +1,23 @@ +import { StyleSheet } from "react-native"; + +export default StyleSheet.create({ + textNom: { + fontSize: 20, + fontWeight: 'bold', + letterSpacing: 0.25, + color: 'white', + }, + textMess: { + fontSize: 15, + letterSpacing: 0.25, + color: '#D9D9D9', + }, + conv: { + flexDirection: 'row', + height: 70, + borderBottomWidth: 2, + borderBottomColor: '#2D2C33', + paddingLeft: '5%', + alignItems: "center", + } +}); \ No newline at end of file diff --git a/bob_party/src/screens/Chat.tsx b/bob_party/src/screens/Chat.tsx index 1e014da..a6ae5e1 100644 --- a/bob_party/src/screens/Chat.tsx +++ b/bob_party/src/screens/Chat.tsx @@ -5,7 +5,7 @@ import stylesScreen from './style/screens.style'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { FlatList } from 'react-native-gesture-handler'; -import { ConversationComponent } from '../components/ConversationComponent'; +import { ConversationPreviewComponent } from '../components/ConversationPreviewComponent'; import { useConversationStore } from '../context/conversationContext'; function Chat(props: { navigation: any; }) { @@ -20,7 +20,7 @@ function Chat(props: { navigation: any; }) { } + renderItem={({item}) => } />