Align own user messages to the right and other user messages to the left

This commit is contained in:
Keannu Bernasol 2023-10-13 14:06:04 +08:00
parent 0c9f53b84d
commit 8e5e0546df

View file

@ -34,9 +34,12 @@ import { useToast } from "react-native-toast-notifications";
import { useQueryClient } from "@tanstack/react-query"; import { useQueryClient } from "@tanstack/react-query";
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer"; import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
import AsyncStorage from "@react-native-async-storage/async-storage"; import AsyncStorage from "@react-native-async-storage/async-storage";
import { useSelector } from "react-redux";
import { RootState } from "../../features/redux/Store/Store";
export default function ConversationPage() { export default function ConversationPage() {
const toast = useToast(); const toast = useToast();
const user = useSelector((state: RootState) => state.user);
// Student Status // Student Status
const [student_status, setStudentStatus] = useState<StudentStatusType>(); const [student_status, setStudentStatus] = useState<StudentStatusType>();
const StudentStatusQuery = useQuery({ const StudentStatusQuery = useQuery({
@ -248,7 +251,10 @@ export default function ConversationPage() {
key={message.id} key={message.id}
style={{ style={{
...styles.message_contentContainer, ...styles.message_contentContainer,
alignItems: index % 2 == 0 ? "flex-end" : "flex-start", alignItems:
message.user === user.user.username
? "flex-end"
: "flex-start",
}} }}
> >
<View style={styles.flex_row}> <View style={styles.flex_row}>