import React, { useCallback, useReducer } from 'react'; import { ThemedText, ThemedView } from '@/components/theme/Theme'; import { Alert, Linking, Platform, StyleSheet } from 'react-native'; import { MaterialIcons } from '@expo/vector-icons'; import { GiftedChat, IMessage, Send, SendProps, SystemMessage, } from 'react-native-gifted-chat'; import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; import AccessoryBar from '@/components/chat/AccessoryBar'; import CustomActions from '@/components/chat/CustomActions'; import CustomView from '@/components/chat/CustomView'; import NavBar from '@/components/chat/NavBar'; import earlierMessages from '@/components/chat/data/earlierMessages'; import messages from '@/components/chat/data/messages'; import * as Clipboard from 'expo-clipboard'; import { GCUser, GCState, GCStateAction, ActionKind, GCMessage } from '@/constants/Types'; const tempUser: GCUser = { _id: 1, name: 'Developer', }; const reducer = (state: GCState, action: GCStateAction) => { switch (action.type) { case ActionKind.SEND_MESSAGE: { return { ...state, step: state.step + 1, messages: action.payload, }; } case ActionKind.LOAD_EARLIER_MESSAGES: { return { ...state, loadEarlier: true, isLoadingEarlier: false, messages: action.payload, }; } case ActionKind.LOAD_EARLIER_START: { return { ...state, isLoadingEarlier: true, } } case ActionKind.SET_IS_TYPING: { return { ...state, isTyping: action.payload, } } } }; const MessagesScreen = () => { const [state, dispatch] = useReducer(reducer, { messages: messages, step: 0, loadEarlier: true, isLoadingEarlier: false, isTyping: false, }) const onSend = useCallback((messages: GCMessage[]) => { const sentMessages = [{ ...messages[0], sent: true, received: true }] }; export default MessagesScreen;