mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
added conversation/groupchat page
This commit is contained in:
parent
22707b8372
commit
f0c46f2fbe
5 changed files with 201 additions and 3 deletions
2
App.tsx
2
App.tsx
|
@ -21,6 +21,7 @@ import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
|
||||||
import { StatusBar } from "expo-status-bar";
|
import { StatusBar } from "expo-status-bar";
|
||||||
import UserInfoPage from "./src/routes/UserInfoPage/UserInfoPage";
|
import UserInfoPage from "./src/routes/UserInfoPage/UserInfoPage";
|
||||||
import SubjectsPage from "./src/routes/SubjectsPage/SubjectsPage";
|
import SubjectsPage from "./src/routes/SubjectsPage/SubjectsPage";
|
||||||
|
import ConversationPage from "./src/routes/ConversationPage/ConversationPage";
|
||||||
|
|
||||||
const Drawer = createDrawerNavigator();
|
const Drawer = createDrawerNavigator();
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ export default function App() {
|
||||||
<Drawer.Screen name="Activation" component={Activation} />
|
<Drawer.Screen name="Activation" component={Activation} />
|
||||||
<Drawer.Screen name="User Info" component={UserInfoPage} />
|
<Drawer.Screen name="User Info" component={UserInfoPage} />
|
||||||
<Drawer.Screen name="Subjects" component={SubjectsPage} />
|
<Drawer.Screen name="Subjects" component={SubjectsPage} />
|
||||||
|
<Drawer.Screen name="Conversation" component={ConversationPage} />
|
||||||
</Drawer.Navigator>
|
</Drawer.Navigator>
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
</Provider>
|
</Provider>
|
||||||
|
|
|
@ -124,7 +124,14 @@ export default function CustomDrawerContent(props: {}) {
|
||||||
<SignupIcon size={32} />
|
<SignupIcon size={32} />
|
||||||
<Text style={styles.text_white_medium}>Register</Text>
|
<Text style={styles.text_white_medium}>Register</Text>
|
||||||
</DrawerButton>
|
</DrawerButton>
|
||||||
|
<DrawerButton
|
||||||
|
onPress={() => {
|
||||||
|
navigation.navigate("Conversation");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SubjectIcon size={32} />
|
||||||
|
<Text style={styles.text_white_medium}>Conversation</Text>
|
||||||
|
</DrawerButton>
|
||||||
{/*
|
{/*
|
||||||
Debug buttons for accessing revalidation and activation page
|
Debug buttons for accessing revalidation and activation page
|
||||||
<DrawerButton
|
<DrawerButton
|
||||||
|
|
179
src/routes/ConversationPage/ConversationPage.tsx
Normal file
179
src/routes/ConversationPage/ConversationPage.tsx
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
import * as React from "react";
|
||||||
|
import styles from "../../styles";
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
type ConversationType = {
|
||||||
|
username: string;
|
||||||
|
message: string;
|
||||||
|
userId: number;
|
||||||
|
type: string;
|
||||||
|
color: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default function ConversationPage() {
|
||||||
|
const [conversation, setConversation] = useState<ConversationType[]>([{
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ScrollView style={convStyles.scrollViewContainer}>
|
||||||
|
<View style={{
|
||||||
|
display: "flex", backgroundColor: colors.secondary_2,
|
||||||
|
borderRadius: 20,
|
||||||
|
}}>
|
||||||
|
<View style={{ padding: 15 }}>
|
||||||
|
<View style={{flexDirection: "row"}}>
|
||||||
|
<Text style={{ ...styles.text_white_medium }}>Group#57605</Text>
|
||||||
|
</View>
|
||||||
|
<Text>3 students
|
||||||
|
<View style={{ ...convStyles.badge, backgroundColor: 'blue' }}></View>
|
||||||
|
<View style={{ ...convStyles.badge, backgroundColor: `green` }}></View>
|
||||||
|
<View style={{ ...convStyles.badge, backgroundColor: `red` }}></View>
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View>
|
||||||
|
{
|
||||||
|
conversation.map((item: ConversationType) => (
|
||||||
|
<View key={item.userId} style={{
|
||||||
|
...convStyles.messageContainer,
|
||||||
|
alignItems: item.type == 'o' ? "flex-end" : 'flex-start'
|
||||||
|
}}>
|
||||||
|
|
||||||
|
<Text style={styles.text_white_small}>
|
||||||
|
{
|
||||||
|
item.type == 'i' ? <View style={{
|
||||||
|
...convStyles.badge,
|
||||||
|
backgroundColor: `#${item.color}`,
|
||||||
|
marginRight: 2
|
||||||
|
}}></View> : null
|
||||||
|
}
|
||||||
|
{item.username}
|
||||||
|
{
|
||||||
|
item.type == 'o' ? <View style={{
|
||||||
|
...convStyles.badge,
|
||||||
|
backgroundColor: `#${item.color}`,
|
||||||
|
marginLeft: 2
|
||||||
|
}}></View> : null
|
||||||
|
}
|
||||||
|
</Text>
|
||||||
|
<Text style={styles.text_white_small}>
|
||||||
|
{item.message}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<TextInput
|
||||||
|
style={styles.chatbox}
|
||||||
|
placeholder="type here...."
|
||||||
|
placeholderTextColor="white"
|
||||||
|
autoCapitalize="none"
|
||||||
|
/>
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
|
}
|
|
@ -200,5 +200,15 @@ const styles = StyleSheet.create({
|
||||||
padding: 0,
|
padding: 0,
|
||||||
border: 0,
|
border: 0,
|
||||||
},
|
},
|
||||||
|
chatbox: {
|
||||||
|
paddingHorizontal: 8,
|
||||||
|
height: 50,
|
||||||
|
marginVertical: 10,
|
||||||
|
borderWidth: 1,
|
||||||
|
color: colors.text_default,
|
||||||
|
backgroundColor: colors.primary_2,
|
||||||
|
borderRadius: 20,
|
||||||
|
borderColor: colors.primary_3,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
Loading…
Reference in a new issue