diff --git a/src/routes/ConversationPage/ConversationPage.tsx b/src/routes/ConversationPage/ConversationPage.tsx index c8340da..6c00b9b 100644 --- a/src/routes/ConversationPage/ConversationPage.tsx +++ b/src/routes/ConversationPage/ConversationPage.tsx @@ -1,179 +1,105 @@ import * as React from "react"; import styles from "../../styles"; -import { - View, - Text, - TextInput, - ScrollView, - StyleSheet -} from "react-native"; +import { View, Text, TextInput, ScrollView, StyleSheet } from "react-native"; import { colors } from "../../styles"; import { useState } from "react"; -const convStyles = StyleSheet.create({ - scrollViewContainer: { - backgroundColor: colors.secondary_1, - padding: 15, - }, - messageContainer: { - backgroundColor: '#00000038', - margin: 5, - padding: 10, - borderRadius: 20, - }, - badge: { - height: 10, - width: 10, - borderRadius: 10, - } -}) +const convStyles = StyleSheet.create({}); type ConversationType = { - username: string; - message: string; - userId: number; - type: string; + id: number; + user: string; + message_content: string; + study_group: string; color: string; -} - +}; export default function ConversationPage() { - const [conversation, setConversation] = useState([{ - username: "You", - message: "Hello World naa ko diri canteen gutom sh*t.", - userId: Math.floor(Math.random() * 1000), - type: "o", - color: Math.floor(Math.random() * 16777215).toString(16) - }, { - username: "User 2", - message: "Hahahah shor oy.", - userId: Math.floor(Math.random() * 1000), - type: "i", - color: Math.floor(Math.random() * 16777215).toString(16) - }, { - username: "User 3", - message: "AHAHAHHA BOBO!", - userId: Math.floor(Math.random() * 1000), - type: "i", - color: Math.floor(Math.random() * 16777215).toString(16) - }, - { - username: "Vale", - message: "tanga valir! bobo!", - userId: Math.floor(Math.random() * 1000), - type: "i", - color: Math.floor(Math.random() * 16777215).toString(16) - }, - { - username: "You", - message: "Hoyy bobo!!!", - userId: Math.floor(Math.random() * 1000), - type: "o", - color: Math.floor(Math.random() * 16777215).toString(16) - }, { - username: "Valir", - message: "Gago! 1v1 nalng?", - userId: Math.floor(Math.random() * 1000), - type: "o", - color: Math.floor(Math.random() * 16777215).toString(16) - }, { - username: "User 2", - message: "Hello World", - userId: Math.floor(Math.random() * 1000), - type: "i", - color: Math.floor(Math.random() * 16777215).toString(16) - }, { - username: "User 3", - message: "Hello World", - userId: Math.floor(Math.random() * 1000), - type: "i", - color: Math.floor(Math.random() * 16777215).toString(16) - }, - { - username: "User 1", - message: "Hello World", - userId: Math.floor(Math.random() * 1000), - type: "o", - color: Math.floor(Math.random() * 16777215).toString(16) - }, - { - username: "User 1", - message: "Hello World", - userId: Math.floor(Math.random() * 1000), - type: "o", - color: Math.floor(Math.random() * 16777215).toString(16) - }, - { - username: "User 1", - message: "Hello World", - userId: Math.floor(Math.random() * 1000), - type: "o", - color: Math.floor(Math.random() * 16777215).toString(16) - }, - { - username: "User 1", - message: "Hello World", - userId: Math.floor(Math.random() * 1000), - type: "o", - color: Math.floor(Math.random() * 16777215).toString(16) - } + const [conversation, setConversation] = useState([ + { + user: "You", + message_content: "Hello World naa ko diri canteen gutom sh*t.", + id: Math.floor(Math.random() * 1000), + color: Math.floor(Math.random() * 16777215).toString(16), + study_group: "Heh group", + }, + { + user: "User 2", + message_content: "Hahahah shor oy.", + id: Math.floor(Math.random() * 1000), + color: Math.floor(Math.random() * 16777215).toString(16), + study_group: "Heh group", + }, ]); return ( - - + + - + Group#57605 - 3 students - - - + + 3 students + + + - { - conversation.map((item: ConversationType) => ( - + {conversation.map((item: ConversationType, index: number) => { + const color = `rgba(${Math.floor( + Math.random() * 256 + )}, ${Math.floor(Math.random() * 256)}, ${Math.floor( + Math.random() * 256 + )}, 0.7)`; + return ( + + + {index % 2 == 0 ? ( + + ) : ( + + )} + {item.user} + - { - item.type == 'i' ? : null - } - {item.username} - { - item.type == 'o' ? : null - } - - - {item.message} + {item.message_content} - )) - } + ); + })} + style={styles.chatbox} + placeholder="type here...." + placeholderTextColor="white" + autoCapitalize="none" + /> ); } diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx index 3f0e256..3f72156 100644 --- a/src/routes/Home/Home.tsx +++ b/src/routes/Home/Home.tsx @@ -121,17 +121,13 @@ export default function Home() { return data; }, onSuccess: (data: StudentStatusReturnType) => { - if (data[1].active !== undefined) { - setStudying(data[1].active); - } - if (data[1].subject !== undefined) { - setSubject(data[1].subject); - } if (data[1].active == true) { setButtonLabel("Stop Studying"); } else if (data[1].active == false) { setButtonLabel("Start Studying"); } + setSubject(data[1].subject); + setStudying(data[1].active); setStudentStatus(data[1]); }, onError: (error: Error) => { @@ -264,6 +260,7 @@ export default function Home() { useState([]); // Student Status List Global const StudentStatusListGlobalQuery = useQuery({ + enabled: !studying, queryKey: ["user_status_list_global"], queryFn: async () => { const data = await GetStudentStatusList(); @@ -322,6 +319,7 @@ export default function Home() { >([]); // Study Group Global List const StudyGroupGlobalQuery = useQuery({ + enabled: !studying, queryKey: ["study_group_list_global"], queryFn: async () => { const data = await GetStudyGroupList(); diff --git a/src/styles.tsx b/src/styles.tsx index 0f9ab15..8e8f1cf 100644 --- a/src/styles.tsx +++ b/src/styles.tsx @@ -212,6 +212,24 @@ const styles = StyleSheet.create({ backgroundColor: colors.primary_2, borderRadius: 20, borderColor: colors.primary_3, - } + }, + messageScrollViewContainer: { + backgroundColor: colors.secondary_1, + padding: 15, + }, + message_contentContainer: { + backgroundColor: "#00000038", + margin: 5, + padding: 10, + borderRadius: 20, + }, + badge: { + height: 16, + width: 16, + justifyContent: "center", + borderRadius: 10, + marginLeft: 4, + marginRight: 4, + }, }); export default styles;