react-native-srschat 0.1.13 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/lib/commonjs/components/email.js +243 -0
  2. package/lib/commonjs/components/email.js.map +1 -0
  3. package/lib/commonjs/components/feedback.js +115 -0
  4. package/lib/commonjs/components/feedback.js.map +1 -0
  5. package/lib/commonjs/components/header.js +35 -17
  6. package/lib/commonjs/components/header.js.map +1 -1
  7. package/lib/commonjs/components/input.js +106 -0
  8. package/lib/commonjs/components/input.js.map +1 -0
  9. package/lib/commonjs/components/productCard.js +234 -0
  10. package/lib/commonjs/components/productCard.js.map +1 -0
  11. package/lib/commonjs/components/testing.js +19 -6
  12. package/lib/commonjs/components/testing.js.map +1 -1
  13. package/lib/commonjs/{layout/chatIcon.js → components/welcomeButton.js} +40 -37
  14. package/lib/commonjs/components/welcomeButton.js.map +1 -0
  15. package/lib/commonjs/components/welcomeInput.js +87 -0
  16. package/lib/commonjs/components/welcomeInput.js.map +1 -0
  17. package/lib/commonjs/contexts/AppContext.js +272 -56
  18. package/lib/commonjs/contexts/AppContext.js.map +1 -1
  19. package/lib/commonjs/hooks/{Stream.js → stream.js} +107 -39
  20. package/lib/commonjs/hooks/stream.js.map +1 -0
  21. package/lib/commonjs/hooks/useAsyncStorage.js +36 -0
  22. package/lib/commonjs/hooks/useAsyncStorage.js.map +1 -0
  23. package/lib/commonjs/index.js +13 -6
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/layout/disclaimer.js +200 -0
  26. package/lib/commonjs/layout/disclaimer.js.map +1 -0
  27. package/lib/commonjs/layout/ex.js +272 -0
  28. package/lib/commonjs/layout/ex.js.map +1 -0
  29. package/lib/commonjs/layout/icon.js +114 -0
  30. package/lib/commonjs/layout/icon.js.map +1 -0
  31. package/lib/commonjs/layout/layout.js +148 -14
  32. package/lib/commonjs/layout/layout.js.map +1 -1
  33. package/lib/commonjs/layout/welcome.js +135 -0
  34. package/lib/commonjs/layout/welcome.js.map +1 -0
  35. package/lib/commonjs/layout/window.js +205 -0
  36. package/lib/commonjs/layout/window.js.map +1 -0
  37. package/lib/module/components/email.js +233 -0
  38. package/lib/module/components/email.js.map +1 -0
  39. package/lib/module/components/feedback.js +105 -0
  40. package/lib/module/components/feedback.js.map +1 -0
  41. package/lib/module/components/header.js +35 -17
  42. package/lib/module/components/header.js.map +1 -1
  43. package/lib/module/components/input.js +96 -0
  44. package/lib/module/components/input.js.map +1 -0
  45. package/lib/module/components/productCard.js +225 -0
  46. package/lib/module/components/productCard.js.map +1 -0
  47. package/lib/module/components/testing.js +20 -7
  48. package/lib/module/components/testing.js.map +1 -1
  49. package/lib/module/components/welcomeButton.js +48 -0
  50. package/lib/module/components/welcomeButton.js.map +1 -0
  51. package/lib/module/components/welcomeInput.js +77 -0
  52. package/lib/module/components/welcomeInput.js.map +1 -0
  53. package/lib/module/contexts/AppContext.js +272 -57
  54. package/lib/module/contexts/AppContext.js.map +1 -1
  55. package/lib/module/hooks/{Stream.js → stream.js} +107 -39
  56. package/lib/module/hooks/stream.js.map +1 -0
  57. package/lib/module/hooks/useAsyncStorage.js +29 -0
  58. package/lib/module/hooks/useAsyncStorage.js.map +1 -0
  59. package/lib/module/index.js +13 -6
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/layout/disclaimer.js +190 -0
  62. package/lib/module/layout/disclaimer.js.map +1 -0
  63. package/lib/module/layout/ex.js +262 -0
  64. package/lib/module/layout/ex.js.map +1 -0
  65. package/lib/module/layout/icon.js +104 -0
  66. package/lib/module/layout/icon.js.map +1 -0
  67. package/lib/module/layout/layout.js +150 -16
  68. package/lib/module/layout/layout.js.map +1 -1
  69. package/lib/module/layout/welcome.js +126 -0
  70. package/lib/module/layout/welcome.js.map +1 -0
  71. package/lib/module/layout/window.js +195 -0
  72. package/lib/module/layout/window.js.map +1 -0
  73. package/lib/typescript/components/email.d.ts +5 -0
  74. package/lib/typescript/components/email.d.ts.map +1 -0
  75. package/lib/typescript/components/feedback.d.ts +6 -0
  76. package/lib/typescript/components/feedback.d.ts.map +1 -0
  77. package/lib/typescript/components/header.d.ts.map +1 -1
  78. package/lib/typescript/components/input.d.ts +6 -0
  79. package/lib/typescript/components/input.d.ts.map +1 -0
  80. package/lib/typescript/components/productCard.d.ts +5 -0
  81. package/lib/typescript/components/productCard.d.ts.map +1 -0
  82. package/lib/typescript/components/testing.d.ts.map +1 -1
  83. package/lib/typescript/components/welcomeButton.d.ts +4 -0
  84. package/lib/typescript/components/welcomeButton.d.ts.map +1 -0
  85. package/lib/typescript/components/welcomeInput.d.ts +6 -0
  86. package/lib/typescript/components/welcomeInput.d.ts.map +1 -0
  87. package/lib/typescript/contexts/AppContext.d.ts +5 -1
  88. package/lib/typescript/contexts/AppContext.d.ts.map +1 -1
  89. package/lib/typescript/hooks/{Stream.d.ts → stream.d.ts} +1 -1
  90. package/lib/typescript/hooks/stream.d.ts.map +1 -0
  91. package/lib/typescript/hooks/useAsyncStorage.d.ts +2 -0
  92. package/lib/typescript/hooks/useAsyncStorage.d.ts.map +1 -0
  93. package/lib/typescript/index.d.ts +2 -1
  94. package/lib/typescript/index.d.ts.map +1 -1
  95. package/lib/typescript/layout/disclaimer.d.ts +5 -0
  96. package/lib/typescript/layout/disclaimer.d.ts.map +1 -0
  97. package/lib/typescript/layout/ex.d.ts +3 -0
  98. package/lib/typescript/layout/ex.d.ts.map +1 -0
  99. package/lib/typescript/layout/{chatIcon.d.ts → icon.d.ts} +1 -1
  100. package/lib/typescript/layout/icon.d.ts.map +1 -0
  101. package/lib/typescript/layout/layout.d.ts +1 -4
  102. package/lib/typescript/layout/layout.d.ts.map +1 -1
  103. package/lib/typescript/layout/welcome.d.ts +5 -0
  104. package/lib/typescript/layout/welcome.d.ts.map +1 -0
  105. package/lib/typescript/layout/window.d.ts +5 -0
  106. package/lib/typescript/layout/window.d.ts.map +1 -0
  107. package/package.json +7 -1
  108. package/src/components/email.js +210 -0
  109. package/src/components/feedback.js +114 -0
  110. package/src/components/header.js +32 -17
  111. package/src/components/input.js +95 -0
  112. package/src/components/productCard.js +240 -0
  113. package/src/components/testing.js +17 -4
  114. package/src/components/welcomeButton.js +51 -0
  115. package/src/components/welcomeInput.js +81 -0
  116. package/src/contexts/AppContext.js +237 -52
  117. package/src/hooks/{Stream.js → stream.js} +123 -41
  118. package/src/hooks/useAsyncStorage.js +33 -0
  119. package/src/index.js +7 -3
  120. package/src/layout/disclaimer.js +187 -0
  121. package/src/layout/ex.js +251 -0
  122. package/src/layout/icon.js +96 -0
  123. package/src/layout/layout.js +137 -10
  124. package/src/layout/welcome.js +124 -0
  125. package/src/layout/window.js +194 -0
  126. package/lib/commonjs/hooks/Stream.js.map +0 -1
  127. package/lib/commonjs/layout/chatIcon.js.map +0 -1
  128. package/lib/commonjs/layout/chatWindow.js +0 -214
  129. package/lib/commonjs/layout/chatWindow.js.map +0 -1
  130. package/lib/module/hooks/Stream.js.map +0 -1
  131. package/lib/module/layout/chatIcon.js +0 -44
  132. package/lib/module/layout/chatIcon.js.map +0 -1
  133. package/lib/module/layout/chatWindow.js +0 -204
  134. package/lib/module/layout/chatWindow.js.map +0 -1
  135. package/lib/typescript/hooks/Stream.d.ts.map +0 -1
  136. package/lib/typescript/layout/chatIcon.d.ts.map +0 -1
  137. package/lib/typescript/layout/chatWindow.d.ts +0 -6
  138. package/lib/typescript/layout/chatWindow.d.ts.map +0 -1
  139. package/src/layout/chatIcon.js +0 -38
  140. package/src/layout/chatWindow.js +0 -207
@@ -0,0 +1,210 @@
1
+ import React, { useState, useContext } from "react";
2
+ import { View, Text, TextInput, TouchableOpacity, ActivityIndicator, Alert, StyleSheet, ScrollView } from "react-native";
3
+ import Ionicons from "react-native-vector-icons/Ionicons";
4
+ import axios from "axios";
5
+ import { AppContext } from "../contexts/AppContext";
6
+ import { Header } from "./header";
7
+
8
+ export const EmailForm = ({ panHandlers }) => {
9
+ const { BASE_URL, setShowModal, messages, formatChatHistory, conversationStartTime } = useContext(AppContext);
10
+ const [subject, setSubject] = useState("");
11
+ const [message, setMessage] = useState("");
12
+ const [userEmail, setUserEmail] = useState("");
13
+ const [branchEmail, setBranchEmail] = useState("");
14
+ const [isLoading, setIsLoading] = useState(false);
15
+ const [error, setError] = useState("");
16
+ const [success, setSuccess] = useState(false);
17
+ const [isComposing, setIsComposing] = useState(false);
18
+
19
+ const handleComposeEmail = async () => {
20
+ setIsComposing(true);
21
+ setError("");
22
+
23
+ try {
24
+ const chatHistory = formatChatHistory();
25
+ const payload = {
26
+ chat_history: chatHistory,
27
+ conversation_start_time: conversationStartTime,
28
+ customer_name: '',
29
+ branch_email: "",
30
+ };
31
+
32
+ const response = await axios.post(`https://${BASE_URL}/compose-email`, payload);
33
+ setMessage(response.data.message);
34
+ setSubject(response.data.subject || "");
35
+ } catch (error) {
36
+ setError(error.response?.data?.message || "Failed to compose email");
37
+ } finally {
38
+ setIsComposing(false);
39
+ }
40
+ };
41
+
42
+ const handleSubmit = async () => {
43
+ if (!userEmail || !subject || !message) {
44
+ setError("Please fill in all fields");
45
+ return;
46
+ }
47
+
48
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(userEmail)) {
49
+ setError("Please enter a valid email address");
50
+ return;
51
+ }
52
+
53
+ setIsLoading(true);
54
+
55
+ try {
56
+ const chatHistory = formatChatHistory();
57
+ await axios.post(`https://${BASE_URL}/send-email`, {
58
+ user_email: 'cristin@instalily.ai',
59
+ subject,
60
+ message,
61
+ chat_history: chatHistory,
62
+ conversation_start_time: conversationStartTime,
63
+ customer_name: '',
64
+ branch_email: "",
65
+ });
66
+
67
+ setSuccess(true);
68
+ setTimeout(() => {
69
+ setSuccess(false);
70
+ setShowModal("ChatWindow");
71
+ }, 2000);
72
+ } catch (error) {
73
+ setError(error.response?.data?.message || "Failed to send email");
74
+ } finally {
75
+ setIsLoading(false);
76
+ }
77
+ };
78
+
79
+ return (
80
+ <View style={styles.container}>
81
+ <View {...panHandlers}>
82
+ <Header />
83
+ </View>
84
+ <View style={styles.topBar}>
85
+ <TouchableOpacity onPress={() => setShowModal("ChatWindow")} style={styles.backButton}>
86
+ <Ionicons name="arrow-back" size={20} color="#000" />
87
+ </TouchableOpacity>
88
+ <Text style={styles.topBarTitle}>Contact Us</Text>
89
+ </View>
90
+ <ScrollView
91
+ style={styles.content}
92
+ contentContainerStyle={{ paddingBottom: 100 }} // Add padding to bottom
93
+ keyboardShouldPersistTaps="handled"
94
+ showsVerticalScrollIndicator={true}
95
+ >
96
+
97
+ <Text style={styles.infoText}>
98
+ Our AI assistant can help draft a professional email based on your chat conversation. The email will capture your main points and maintain a conversational tone. You can review and modify before sending.
99
+ </Text>
100
+
101
+ <TouchableOpacity style={styles.composeButton} onPress={handleComposeEmail} disabled={isComposing}>
102
+ {isComposing ? (
103
+ <ActivityIndicator size="small" color="#FFFFFF" />
104
+ ) : (
105
+ <Text style={styles.buttonText}>Draft My Email</Text>
106
+ )}
107
+ </TouchableOpacity>
108
+
109
+ <TextInput style={styles.input} value={branchEmail} editable={false} placeholder="Branch Email" />
110
+ <TextInput style={styles.input} value={userEmail} onChangeText={setUserEmail} placeholder="Your Email" />
111
+ <TextInput style={styles.input} value={subject} onChangeText={setSubject} placeholder="Subject" />
112
+ <TextInput style={styles.textArea} value={message} onChangeText={setMessage} placeholder="Message" multiline />
113
+
114
+ {error ? <Text style={styles.errorText}>{error}</Text> : null}
115
+ {success ? <Text style={styles.successText}>Email sent successfully!</Text> : null}
116
+
117
+ <TouchableOpacity style={styles.sendButton} onPress={handleSubmit} disabled={isLoading}>
118
+ {isLoading ? <ActivityIndicator size="small" color="#FFFFFF" /> : <Text style={styles.buttonText}>Send Email</Text>}
119
+ </TouchableOpacity>
120
+ </ScrollView>
121
+ </View>
122
+ );
123
+ };
124
+
125
+ const styles = StyleSheet.create({
126
+ container: {
127
+ flex: 1,
128
+ },
129
+ content: {
130
+ padding: 20,
131
+ paddingTop: 5,
132
+ paddingBottom: 40,
133
+ marginBottom: 40
134
+ },
135
+ topBar: {
136
+ flexDirection: 'row',
137
+ alignItems: 'center',
138
+ paddingVertical: 10,
139
+ paddingHorizontal: 16,
140
+ marginTop: 10
141
+ },
142
+ backButton: {
143
+ padding: 8,
144
+ borderRadius: 20,
145
+ backgroundColor: '#FFF',
146
+ },
147
+ topBarTitle: {
148
+ fontSize: 18,
149
+ fontWeight: 'medium',
150
+ marginLeft: 12,
151
+ },
152
+ infoText: {
153
+ textAlign: "left",
154
+ color: "#666",
155
+ fontSize: 15,
156
+ lineHeight: 22,
157
+ marginBottom: 20,
158
+ },
159
+ input: {
160
+ backgroundColor: "#f5f5f5",
161
+ borderRadius: 8,
162
+ padding: 12,
163
+ fontSize: 16,
164
+ borderWidth: 1,
165
+ borderColor: "#e0e0e0",
166
+ marginBottom: 10,
167
+ },
168
+ textArea: {
169
+ backgroundColor: "#f5f5f5",
170
+ borderRadius: 8,
171
+ padding: 12,
172
+ fontSize: 16,
173
+ borderWidth: 1,
174
+ borderColor: "#e0e0e0",
175
+ marginBottom: 10,
176
+ height: 180,
177
+ textAlignVertical: "top",
178
+ },
179
+ composeButton: {
180
+ backgroundColor: "#367CB6",
181
+ borderRadius: 5,
182
+ padding: 12,
183
+ alignItems: "center",
184
+ marginBottom: 20,
185
+ },
186
+ sendButton: {
187
+ backgroundColor: "#367CB6",
188
+ borderRadius: 5,
189
+ padding: 12,
190
+ alignItems: "center",
191
+ marginTop: 20,
192
+ },
193
+ buttonText: {
194
+ color: "#FFF",
195
+ fontSize: 16,
196
+ fontWeight: "500",
197
+ },
198
+ errorText: {
199
+ color: "red",
200
+ fontSize: 14,
201
+ textAlign: "center",
202
+ marginTop: 10,
203
+ },
204
+ successText: {
205
+ color: "green",
206
+ fontSize: 14,
207
+ textAlign: "center",
208
+ marginTop: 10,
209
+ },
210
+ });
@@ -0,0 +1,114 @@
1
+ import React, { useContext } from "react";
2
+ import { View, Text, TouchableOpacity, TextInput, StyleSheet } from "react-native";
3
+ import Ionicons from "react-native-vector-icons/Ionicons";
4
+ import { AppContext } from "../contexts/AppContext";
5
+ import Feather from "react-native-vector-icons/Feather";
6
+
7
+ export const Feedback = ({ message, messageId }) => {
8
+ const { handleFeedback, feedback, handleWrittenFeedback, feedbackOpen, setFeedbackOpen, writeFeedback,
9
+ setWriteFeedback, switchFeedbackOpen } = useContext(AppContext);
10
+
11
+ return (
12
+ <View style={styles.container}>
13
+
14
+ {/* Feedback Icons */}
15
+ <View style={styles.iconContainer}>
16
+ {/* Thumbs Up Button */}
17
+ <TouchableOpacity onPress={() => handleFeedback(1, messageId)}>
18
+ <Feather
19
+ name="thumbs-up"
20
+ size={18}
21
+ color={feedback[messageId] === 1 ? "#367CB6" : "#808080"}
22
+ style={styles.icon}
23
+ />
24
+ </TouchableOpacity>
25
+
26
+ {/* Thumbs Down Button */}
27
+ <TouchableOpacity onPress={() => handleFeedback(-1, messageId)}>
28
+ <Feather
29
+ name="thumbs-down"
30
+ size={18}
31
+ color={feedback[messageId] === -1 ? "#367CB6" : "#808080"}
32
+ style={styles.icon}
33
+ />
34
+ </TouchableOpacity>
35
+ </View>
36
+
37
+ {/* Feedback Input */}
38
+ {feedbackOpen[messageId] == true && (
39
+ <View style={styles.feedbackSection}>
40
+ <TextInput
41
+ multiline
42
+ numberOfLines={3}
43
+ placeholder="Enter your feedback..."
44
+ style={styles.textInput}
45
+ value={writeFeedback}
46
+ onChangeText={setWriteFeedback}
47
+ />
48
+
49
+ {/* Buttons */}
50
+ <View style={styles.buttonContainer}>
51
+ <TouchableOpacity
52
+ style={styles.button}
53
+ onPress={() => switchFeedbackOpen(false, messageId, true)}
54
+ >
55
+ <Text style={styles.buttonText}>Close</Text>
56
+ </TouchableOpacity>
57
+
58
+ <TouchableOpacity
59
+ style={styles.button}
60
+ onPress={() => handleWrittenFeedback(messageId)}
61
+ >
62
+ <Text style={styles.buttonText}>Send</Text>
63
+ </TouchableOpacity>
64
+ </View>
65
+ </View>
66
+ )}
67
+ </View>
68
+ );
69
+ };
70
+
71
+ const styles = StyleSheet.create({
72
+ container: {
73
+ marginTop: 0,
74
+ marginBottom: 5
75
+ },
76
+ iconContainer: {
77
+ flexDirection: "row",
78
+ alignItems: "center",
79
+ justifyContent: 'flex-end'
80
+ },
81
+ icon: {
82
+ marginRight: 10,
83
+ },
84
+ feedbackSection: {
85
+ marginTop: 10,
86
+ },
87
+ textInput: {
88
+ width: "100%",
89
+ borderWidth: 1,
90
+ borderColor: "#808080",
91
+ borderRadius: 5,
92
+ padding: 10,
93
+ fontSize: 14,
94
+ color: "#161616",
95
+ backgroundColor: "#fff",
96
+ },
97
+ buttonContainer: {
98
+ flexDirection: "row",
99
+ justifyContent: "flex-end",
100
+ marginTop: 5,
101
+ },
102
+ button: {
103
+ backgroundColor: "#367CB6",
104
+ paddingVertical: 8,
105
+ paddingHorizontal: 15,
106
+ borderRadius: 5,
107
+ marginLeft: 10,
108
+ },
109
+ buttonText: {
110
+ color: "white",
111
+ fontSize: 14,
112
+ textTransform: "none",
113
+ },
114
+ });
@@ -4,7 +4,15 @@ import { AppContext } from '../contexts/AppContext';
4
4
  import Ionicons from 'react-native-vector-icons/Ionicons';
5
5
 
6
6
  export const Header = () => {
7
- const { setShowModal } = useContext(AppContext);
7
+ const { showModal, setShowModal, setMessages, defaultMessage, handleClearState, uiConfig } = useContext(AppContext);
8
+
9
+ const handleClick = () => {
10
+ if ((uiConfig.showIcon ?? true) !== true) {
11
+ setShowModal("Off");
12
+ } else {
13
+ setShowModal("Icon");
14
+ }
15
+ };
8
16
 
9
17
  return (
10
18
  <View style={styles.header}>
@@ -17,18 +25,25 @@ export const Header = () => {
17
25
  <View style={[styles.section, styles.titleContainer]}>
18
26
  <View style={styles.titleWrapper}>
19
27
  <Text style={styles.title}>
20
- Poseidon
28
+ Poseidon
21
29
  </Text>
22
- <Text style={styles.betaText}><Ionicons style={styles.icon} name="sparkles-outline" size={10} color="#007AFF" />beta</Text>
30
+ <Text style={styles.betaText}><Ionicons name="sparkles-outline" size={10} color="#007AFF" />beta</Text>
23
31
  </View>
24
32
  </View>
25
33
 
26
34
  {/* Close button on the right */}
27
35
  <View style={styles.iconsSection}>
28
- <TouchableOpacity onPress={() => setShowModal("Icon")}>
29
- <Ionicons name="trash" size={24} color="gray" />
30
- </TouchableOpacity>
31
- <TouchableOpacity onPress={() => setShowModal("Icon")}>
36
+ {showModal !== "Form" && showModal !== "Email" &&
37
+ <>
38
+ <TouchableOpacity onPress={() => setShowModal("Email")}>
39
+ <Ionicons name="mail" size={24} color="gray" />
40
+ </TouchableOpacity>
41
+ <TouchableOpacity onPress={() => handleClearState()}>
42
+ <Ionicons name="trash" size={24} color="gray" />
43
+ </TouchableOpacity>
44
+ </>
45
+ }
46
+ <TouchableOpacity onPress={() => handleClick()}>
32
47
  <Ionicons name="chevron-down" size={24} color="gray" />
33
48
  </TouchableOpacity>
34
49
  </View>
@@ -54,34 +69,34 @@ const styles = StyleSheet.create({
54
69
  display: 'flex',
55
70
  flexDirection: 'row',
56
71
  alignItems: 'center',
57
- justifyContent: 'flex-end'
72
+ justifyContent: 'flex-end',
73
+ marginRight: 10,
74
+ gap: 4,
58
75
  },
59
76
  logo: {
60
- width: 100,
77
+ width: 110,
61
78
  height: 40,
79
+ marginLeft: 10,
62
80
  resizeMode: 'contain',
63
81
  },
64
- icon: {
65
- paddingLeft: 2,
66
- paddingRight: 2
67
- },
68
82
  titleContainer: {
69
83
  flex: 2, // Slightly larger space for the title
84
+ marginTop: 13,
70
85
  },
71
86
  titleWrapper: {
72
87
  alignItems: 'center',
73
88
  justifyContent: 'center',
74
89
  },
75
90
  title: {
76
- fontSize: 20,
77
- fontWeight: 'medium',
78
- color: '#000',
91
+ fontSize: 22,
92
+ fontWeight: 300,
93
+ color: '#404040',
79
94
  textAlign: 'center',
80
95
  flexDirection: 'row',
81
96
  },
82
97
  betaText: {
83
98
  fontSize: 12,
84
- color: 'gray',
99
+ color: '#404040',
85
100
  position: 'absolute',
86
101
  top: -10,
87
102
  right: -35,
@@ -0,0 +1,95 @@
1
+ import React, { useState, useEffect, useContext, useRef } from 'react';
2
+ import {
3
+ Text,
4
+ StyleSheet,
5
+ View,
6
+ TextInput,
7
+ TouchableOpacity,
8
+ Platform,
9
+ KeyboardAvoidingView,
10
+ Keyboard
11
+ } from 'react-native';
12
+ import { Header } from '../components/header';
13
+ import { AppContext } from '../contexts/AppContext';
14
+ import Ionicons from 'react-native-vector-icons/Ionicons';
15
+
16
+ export const ChatInput = ({ onProductCardClick, onAddToCartClick }) => {
17
+ const { handleSend, input, setInput, showModal } = useContext(AppContext);
18
+
19
+ return (
20
+ <>
21
+ <Text style={styles.textBeta}>Beta version. Poseidon is learning!</Text>
22
+ <View style={styles.inputWrapper}>
23
+ <View style={styles.inputContainer}>
24
+ <TextInput
25
+ style={styles.input}
26
+ value={input}
27
+ onChangeText={setInput}
28
+ placeholder="Ask a question..."
29
+ placeholderTextColor="#999"
30
+ multiline
31
+ />
32
+ <TouchableOpacity style={styles.inputButton}>
33
+ <Ionicons name="mic-outline" size={24} color="#8E8E93" />
34
+ </TouchableOpacity>
35
+ <TouchableOpacity style={styles.sendButton} onPress={() => handleSend(input)} >
36
+ <Ionicons name="paper-plane-outline" size={24} color='#8E8E93' />
37
+ </TouchableOpacity>
38
+ </View>
39
+ </View>
40
+ </>
41
+ );
42
+ };
43
+
44
+ const styles = StyleSheet.create({
45
+ inputWrapper: {
46
+ backgroundColor: '#f6f6f6',
47
+ paddingHorizontal: 6,
48
+ paddingVertical: 6,
49
+ borderTopWidth: 1,
50
+ borderTopColor: 'rgba(0, 0, 0, 0.1)',
51
+ paddingBottom: 25,
52
+ },
53
+ inputContainer: {
54
+ flexDirection: 'row',
55
+ alignItems: 'center',
56
+ paddingHorizontal: 8,
57
+ paddingVertical: 8,
58
+ backgroundColor: '#FFFFFF',
59
+ borderRadius: 16,
60
+ margin: 8,
61
+ shadowColor: '#000',
62
+ shadowOffset: {
63
+ width: 0,
64
+ height: 2,
65
+ },
66
+ shadowOpacity: 0.1,
67
+ shadowRadius: 4,
68
+ elevation: 3,
69
+ },
70
+ input: {
71
+ flex: 1,
72
+ fontSize: 16,
73
+ paddingVertical: 8,
74
+ paddingHorizontal: 12,
75
+ color: '#000000',
76
+ },
77
+ inputButton: {
78
+ padding: 6,
79
+ },
80
+ sendButton: {
81
+ padding: 6,
82
+ marginLeft: 'auto',
83
+ },
84
+ disabledButton: {
85
+ opacity: 0.7,
86
+ },
87
+ textBeta: {
88
+ textAlign: 'center',
89
+ fontSize: 11,
90
+ color: '#808080',
91
+ fontWeight: '400',
92
+ marginTop: 5,
93
+ marginBottom: 2
94
+ },
95
+ });