0% acharam este documento útil (0 voto)
9 visualizações2 páginas

Opções de Digitação em Chat Mobile

Enviado por

Eduardo Teixeira
Direitos autorais
© All Rights Reserved
Levamos muito a sério os direitos de conteúdo. Se você suspeita que este conteúdo é seu, reivindique-o aqui.
Formatos disponíveis
Baixe no formato TXT, PDF, TXT ou leia on-line no Scribd
0% acharam este documento útil (0 voto)
9 visualizações2 páginas

Opções de Digitação em Chat Mobile

Enviado por

Eduardo Teixeira
Direitos autorais
© All Rights Reserved
Levamos muito a sério os direitos de conteúdo. Se você suspeita que este conteúdo é seu, reivindique-o aqui.
Formatos disponíveis
Baixe no formato TXT, PDF, TXT ou leia on-line no Scribd

import { FunctionComponent, useContext, useState } from "react";

import { View, Text, TouchableOpacity, TextInput } from 'react-native';


import { ThemeContext } from "../../../contexts/ThemeContext";
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";
import { faCirclePlus } from "@fortawesome/free-solid-svg-icons";
import * as ImagePicker from 'expo-image-picker';
import { useNavigation } from "@react-navigation/native";
import { StackTypes } from "../../../routes/[Link]";
import { Chat } from "../../../utils/types";

interface optionsProps {
content: string;
}

interface ChatContentTypingOptionsProps {
chat: Chat;
setAttachment: (attachment: any) => void;
}

const ChatContentTypingOptions: FunctionComponent<ChatContentTypingOptionsProps> =


(props) => {
const navigate = useNavigation<StackTypes>();
const { themeObject } = useContext(ThemeContext);

const [textValue, setTextValue] = useState('');


const [attachment, setAttachment] = useState<any>(null);

const options: optionsProps[] = [


{ content: 'Lead CRM' },
{ content: 'Pós-venda CRM' },
{ content: 'ADD Mídia' },
{ content: 'Add Atendente' },
];

function handleOptions(currentOption: string) {


switch (currentOption) {
case 'Lead CRM':
[Link]('CrmForm', { chat: [Link] });
break;
case 'ADD Mídia':
pickMedia(); // Chamando a função de seleção de mídia
break;
default:
break;
}
}

const pickMedia = async () => {


try {
const permissionResult = await
[Link]();
if (![Link]) {
alert("Permissão para acessar as fotos é necessária!");
return;
}

const result = await [Link]({


mediaTypes: [Link],
allowsEditing: true,
quality: 1,
});

// Verifica se o usuário selecionou uma imagem


if (![Link] && [Link] && [Link] > 0) {
const selectedImageUri = [Link][0].uri; // Obtém o URI da primeira
imagem selecionada
[Link]('Imagem selecionada:', selectedImageUri);
setAttachment(selectedImageUri);
[Link]('ImagePreview', { image: selectedImageUri, chat:
[Link] });
} else {
[Link]('Nenhuma imagem selecionada.');
}
} catch (err) {
[Link]('Erro ao selecionar imagem:', err);
}
};
/*
const sendMessage = () => {
if ([Link]() === '' && !attachment) {
alert('Por favor, adicione um texto ou uma imagem!');
return;
}

// Aqui você vai chamar a lógica para enviar a mensagem com o anexo, se houver
[Link]('Enviando mensagem:', textValue, 'com anexo:', attachment);
};
*/

return (
<View className="absolute bottom-14 p-2 gap-y-2">
{[Link]((currentOption: optionsProps, i) => (
<TouchableOpacity key={i} onPress={() =>
handleOptions([Link])} className="flex-row gap-x-2">
<FontAwesomeIcon size={30} color={[Link]}
icon={faCirclePlus} />
<Text
style={{ backgroundColor: [Link], color:
[Link] }}
className="p-2 rounded-md"
>
{[Link]}
</Text>
</TouchableOpacity>
))}

</View>
);
};

export default ChatContentTypingOptions;

Você também pode gostar