react-native-srschat 0.1.7 → 0.1.9
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.
- package/README.md +70 -0
- package/lib/commonjs/assets/heritage.png +0 -0
- package/lib/commonjs/components/header.js +105 -0
- package/lib/commonjs/components/header.js.map +1 -0
- package/lib/commonjs/components/testing.js +61 -0
- package/lib/commonjs/components/testing.js.map +1 -0
- package/lib/commonjs/contexts/AppContext.js +99 -0
- package/lib/commonjs/contexts/AppContext.js.map +1 -0
- package/lib/commonjs/hooks/Stream.js +202 -0
- package/lib/commonjs/hooks/Stream.js.map +1 -0
- package/lib/commonjs/index.js +13 -262
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layout/chatIcon.js +53 -0
- package/lib/commonjs/layout/chatIcon.js.map +1 -0
- package/lib/commonjs/layout/chatWindow.js +208 -0
- package/lib/commonjs/layout/chatWindow.js.map +1 -0
- package/lib/commonjs/layout/layout.js +35 -0
- package/lib/commonjs/layout/layout.js.map +1 -0
- package/lib/module/assets/heritage.png +0 -0
- package/lib/module/components/header.js +96 -0
- package/lib/module/components/header.js.map +1 -0
- package/lib/module/components/testing.js +53 -0
- package/lib/module/components/testing.js.map +1 -0
- package/lib/module/contexts/AppContext.js +90 -0
- package/lib/module/contexts/AppContext.js.map +1 -0
- package/lib/module/hooks/Stream.js +194 -0
- package/lib/module/hooks/Stream.js.map +1 -0
- package/lib/module/index.js +11 -261
- package/lib/module/index.js.map +1 -1
- package/lib/module/layout/chatIcon.js +44 -0
- package/lib/module/layout/chatIcon.js.map +1 -0
- package/lib/module/layout/chatWindow.js +199 -0
- package/lib/module/layout/chatWindow.js.map +1 -0
- package/lib/module/layout/layout.js +26 -0
- package/lib/module/layout/layout.js.map +1 -0
- package/lib/typescript/components/header.d.ts +3 -0
- package/lib/typescript/components/header.d.ts.map +1 -0
- package/lib/typescript/components/testing.d.ts +6 -0
- package/lib/typescript/components/testing.d.ts.map +1 -0
- package/lib/typescript/contexts/AppContext.d.ts +6 -0
- package/lib/typescript/contexts/AppContext.d.ts.map +1 -0
- package/lib/typescript/hooks/Stream.d.ts +2 -0
- package/lib/typescript/hooks/Stream.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -12
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/layout/chatIcon.d.ts +3 -0
- package/lib/typescript/layout/chatIcon.d.ts.map +1 -0
- package/lib/typescript/layout/chatWindow.d.ts +6 -0
- package/lib/typescript/layout/chatWindow.d.ts.map +1 -0
- package/lib/typescript/layout/layout.d.ts +6 -0
- package/lib/typescript/layout/layout.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/assets/heritage.png +0 -0
- package/src/components/header.js +89 -0
- package/src/components/testing.js +47 -0
- package/src/contexts/AppContext.js +83 -0
- package/src/hooks/Stream.js +198 -0
- package/src/index.js +18 -0
- package/src/layout/chatIcon.js +38 -0
- package/src/layout/chatWindow.js +200 -0
- package/src/layout/layout.js +23 -0
- package/src/index.tsx +0 -323
package/lib/module/index.js
CHANGED
|
@@ -1,267 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
2
|
import { SafeAreaView, Text, StyleSheet, View, TextInput, ScrollView, KeyboardAvoidingView, Platform, TouchableOpacity, RefreshControl } from 'react-native';
|
|
3
3
|
import { Ionicons as Icon } from '@expo/vector-icons';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
backgroundColor: '#FFFFFF',
|
|
7
|
-
textColor: '#000000',
|
|
8
|
-
inputBackgroundColor: '#FFFFFF'
|
|
9
|
-
};
|
|
4
|
+
import { AppProvider } from './contexts/AppContext';
|
|
5
|
+
import { Layout } from './layout/layout';
|
|
10
6
|
export const Chat = ({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
data,
|
|
8
|
+
onProductCardClick,
|
|
9
|
+
onAddToCartClick
|
|
14
10
|
}) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
setRefreshing(true);
|
|
20
|
-
try {
|
|
21
|
-
const response = await onSendMessage("Hi, I'm refreshing the chat!");
|
|
22
|
-
const currentTime = new Date().toLocaleTimeString([], {
|
|
23
|
-
hour: 'numeric',
|
|
24
|
-
minute: '2-digit',
|
|
25
|
-
hour12: true
|
|
26
|
-
});
|
|
27
|
-
setMessages(prev => [...prev, {
|
|
28
|
-
text: response,
|
|
29
|
-
isUser: false,
|
|
30
|
-
timestamp: currentTime
|
|
31
|
-
}]);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error('Error refreshing chat:', error);
|
|
34
|
-
} finally {
|
|
35
|
-
setRefreshing(false);
|
|
36
|
-
}
|
|
37
|
-
}, [onSendMessage]);
|
|
38
|
-
const handleSend = async () => {
|
|
39
|
-
if (!message.trim()) return;
|
|
40
|
-
const userMessage = message;
|
|
41
|
-
setMessage('');
|
|
42
|
-
const currentTime = new Date().toLocaleTimeString([], {
|
|
43
|
-
hour: 'numeric',
|
|
44
|
-
minute: '2-digit',
|
|
45
|
-
hour12: true
|
|
46
|
-
});
|
|
47
|
-
setMessages(prev => [...prev, {
|
|
48
|
-
text: userMessage,
|
|
49
|
-
isUser: true,
|
|
50
|
-
timestamp: currentTime
|
|
51
|
-
}]);
|
|
52
|
-
try {
|
|
53
|
-
// Create bot message placeholder before streaming
|
|
54
|
-
setMessages(prev => [...prev, {
|
|
55
|
-
text: '',
|
|
56
|
-
isUser: false,
|
|
57
|
-
timestamp: currentTime
|
|
58
|
-
}]);
|
|
59
|
-
const response = await onSendMessage(userMessage, chunk => {
|
|
60
|
-
setMessages(prev => {
|
|
61
|
-
const newMessages = [...prev];
|
|
62
|
-
const lastMessage = newMessages[newMessages.length - 1];
|
|
63
|
-
if (lastMessage && !lastMessage.isUser) {
|
|
64
|
-
lastMessage.text += chunk;
|
|
65
|
-
}
|
|
66
|
-
return newMessages;
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Only update if final response is different from streamed content
|
|
71
|
-
setMessages(prev => {
|
|
72
|
-
const newMessages = [...prev];
|
|
73
|
-
const lastMessage = newMessages[newMessages.length - 1];
|
|
74
|
-
if (lastMessage && !lastMessage.isUser && lastMessage.text !== response) {
|
|
75
|
-
lastMessage.text = response;
|
|
76
|
-
}
|
|
77
|
-
return newMessages;
|
|
78
|
-
});
|
|
79
|
-
} catch (error) {
|
|
80
|
-
console.error('Error sending message:', error);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const getMessageStyle = fromUser => [styles.messageBubble, fromUser ? styles.userMessage : styles.botMessage, {
|
|
84
|
-
backgroundColor: fromUser ? theme.primaryColor : '#E8E8E8'
|
|
85
|
-
}];
|
|
86
|
-
const getTextStyle = fromUser => [styles.messageText, {
|
|
87
|
-
color: fromUser ? '#fff' : theme.textColor
|
|
88
|
-
}];
|
|
89
|
-
return /*#__PURE__*/React.createElement(SafeAreaView, {
|
|
90
|
-
style: [styles.container, {
|
|
91
|
-
backgroundColor: theme.backgroundColor
|
|
92
|
-
}]
|
|
93
|
-
}, /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
|
|
94
|
-
behavior: Platform.OS === 'ios' ? 'padding' : 'height',
|
|
95
|
-
style: styles.content,
|
|
96
|
-
keyboardVerticalOffset: Platform.OS === 'ios' ? 60 : 0
|
|
97
|
-
}, /*#__PURE__*/React.createElement(ScrollView, {
|
|
98
|
-
style: styles.messagesContainer,
|
|
99
|
-
contentContainerStyle: styles.messagesContent,
|
|
100
|
-
refreshControl: /*#__PURE__*/React.createElement(RefreshControl, {
|
|
101
|
-
refreshing: refreshing,
|
|
102
|
-
onRefresh: onRefresh,
|
|
103
|
-
tintColor: theme.primaryColor || defaultTheme.primaryColor,
|
|
104
|
-
colors: [theme.primaryColor || defaultTheme.primaryColor],
|
|
105
|
-
progressBackgroundColor: "#ffffff"
|
|
106
|
-
})
|
|
107
|
-
}, messages.map((msg, i) => /*#__PURE__*/React.createElement(View, {
|
|
108
|
-
key: i,
|
|
109
|
-
style: styles.messageWrapper
|
|
110
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
111
|
-
style: [getMessageStyle(msg.isUser), styles.messageShadow]
|
|
112
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
113
|
-
style: getTextStyle(msg.isUser)
|
|
114
|
-
}, msg.text)), /*#__PURE__*/React.createElement(Text, {
|
|
115
|
-
style: [styles.timestamp, msg.isUser ? styles.timestampRight : styles.timestampLeft]
|
|
116
|
-
}, msg.timestamp)))), /*#__PURE__*/React.createElement(View, {
|
|
117
|
-
style: styles.inputWrapper
|
|
118
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
119
|
-
style: styles.inputContainer
|
|
120
|
-
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
121
|
-
style: styles.input,
|
|
122
|
-
value: message,
|
|
123
|
-
onChangeText: setMessage,
|
|
124
|
-
placeholder: placeholder,
|
|
125
|
-
placeholderTextColor: "#999",
|
|
126
|
-
multiline: true
|
|
127
|
-
})), /*#__PURE__*/React.createElement(View, {
|
|
128
|
-
style: styles.inputButtonsContainer
|
|
129
|
-
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
130
|
-
style: styles.inputButton
|
|
131
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
132
|
-
name: "add",
|
|
133
|
-
size: 28,
|
|
134
|
-
color: "#8E8E93"
|
|
135
|
-
})), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
136
|
-
style: styles.inputButton
|
|
137
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
138
|
-
name: "refresh-outline",
|
|
139
|
-
size: 28,
|
|
140
|
-
color: "#8E8E93"
|
|
141
|
-
})), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
142
|
-
style: styles.inputButton
|
|
143
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
144
|
-
name: "mic-outline",
|
|
145
|
-
size: 28,
|
|
146
|
-
color: "#8E8E93"
|
|
147
|
-
})), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
148
|
-
style: [styles.sendButton, !message.trim() && styles.disabledButton],
|
|
149
|
-
onPress: handleSend,
|
|
150
|
-
disabled: !message.trim()
|
|
151
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
152
|
-
name: "paper-plane-outline",
|
|
153
|
-
size: 28,
|
|
154
|
-
color: message.trim() ? theme.primaryColor : '#8E8E93'
|
|
155
|
-
}))))));
|
|
11
|
+
return /*#__PURE__*/React.createElement(AppProvider, null, /*#__PURE__*/React.createElement(Layout, {
|
|
12
|
+
onProductCardClick: onProductCardClick,
|
|
13
|
+
onAddToCartClick: onAddToCartClick
|
|
14
|
+
}));
|
|
156
15
|
};
|
|
157
|
-
const styles = StyleSheet.create({
|
|
158
|
-
container: {
|
|
159
|
-
flex: 1,
|
|
160
|
-
backgroundColor: '#FFFFFF'
|
|
161
|
-
},
|
|
162
|
-
content: {
|
|
163
|
-
flex: 1
|
|
164
|
-
},
|
|
165
|
-
messagesContainer: {
|
|
166
|
-
flex: 1
|
|
167
|
-
},
|
|
168
|
-
messagesContent: {
|
|
169
|
-
padding: 16,
|
|
170
|
-
paddingBottom: 32
|
|
171
|
-
},
|
|
172
|
-
messageWrapper: {
|
|
173
|
-
marginBottom: 16
|
|
174
|
-
},
|
|
175
|
-
timestamp: {
|
|
176
|
-
fontSize: 12,
|
|
177
|
-
color: '#8E8E93',
|
|
178
|
-
marginTop: 4,
|
|
179
|
-
paddingHorizontal: 4
|
|
180
|
-
},
|
|
181
|
-
timestampRight: {
|
|
182
|
-
textAlign: 'right'
|
|
183
|
-
},
|
|
184
|
-
timestampLeft: {
|
|
185
|
-
textAlign: 'left'
|
|
186
|
-
},
|
|
187
|
-
messageBubble: {
|
|
188
|
-
maxWidth: '70%',
|
|
189
|
-
padding: 12,
|
|
190
|
-
paddingHorizontal: 16,
|
|
191
|
-
borderRadius: 20,
|
|
192
|
-
backgroundColor: '#FFFFFF'
|
|
193
|
-
},
|
|
194
|
-
messageShadow: {
|
|
195
|
-
shadowColor: '#000',
|
|
196
|
-
shadowOffset: {
|
|
197
|
-
width: 0,
|
|
198
|
-
height: 1
|
|
199
|
-
},
|
|
200
|
-
shadowOpacity: 0.08,
|
|
201
|
-
shadowRadius: 2,
|
|
202
|
-
elevation: 2
|
|
203
|
-
},
|
|
204
|
-
userMessage: {
|
|
205
|
-
alignSelf: 'flex-end',
|
|
206
|
-
backgroundColor: '#007AFF'
|
|
207
|
-
},
|
|
208
|
-
botMessage: {
|
|
209
|
-
alignSelf: 'flex-start',
|
|
210
|
-
backgroundColor: '#F2F2F7'
|
|
211
|
-
},
|
|
212
|
-
messageText: {
|
|
213
|
-
fontSize: 16,
|
|
214
|
-
lineHeight: 22
|
|
215
|
-
},
|
|
216
|
-
inputWrapper: {
|
|
217
|
-
backgroundColor: '#FFFFFF',
|
|
218
|
-
paddingHorizontal: 8,
|
|
219
|
-
paddingVertical: 8,
|
|
220
|
-
borderTopWidth: 1,
|
|
221
|
-
borderTopColor: 'rgba(0, 0, 0, 0.1)'
|
|
222
|
-
},
|
|
223
|
-
inputContainer: {
|
|
224
|
-
flexDirection: 'row',
|
|
225
|
-
alignItems: 'center',
|
|
226
|
-
paddingHorizontal: 8,
|
|
227
|
-
paddingVertical: 8,
|
|
228
|
-
backgroundColor: '#FFFFFF',
|
|
229
|
-
borderRadius: 16,
|
|
230
|
-
margin: 8,
|
|
231
|
-
shadowColor: '#000',
|
|
232
|
-
shadowOffset: {
|
|
233
|
-
width: 0,
|
|
234
|
-
height: 2
|
|
235
|
-
},
|
|
236
|
-
shadowOpacity: 0.1,
|
|
237
|
-
shadowRadius: 4,
|
|
238
|
-
elevation: 3
|
|
239
|
-
},
|
|
240
|
-
input: {
|
|
241
|
-
flex: 1,
|
|
242
|
-
fontSize: 16,
|
|
243
|
-
paddingVertical: 8,
|
|
244
|
-
paddingHorizontal: 12,
|
|
245
|
-
maxHeight: 100,
|
|
246
|
-
color: '#000000'
|
|
247
|
-
},
|
|
248
|
-
inputButtonsContainer: {
|
|
249
|
-
flexDirection: 'row',
|
|
250
|
-
alignItems: 'center',
|
|
251
|
-
justifyContent: 'space-between',
|
|
252
|
-
paddingHorizontal: 8,
|
|
253
|
-
marginTop: 4
|
|
254
|
-
},
|
|
255
|
-
inputButton: {
|
|
256
|
-
padding: 6,
|
|
257
|
-
marginHorizontal: 4
|
|
258
|
-
},
|
|
259
|
-
sendButton: {
|
|
260
|
-
padding: 6,
|
|
261
|
-
marginLeft: 'auto'
|
|
262
|
-
},
|
|
263
|
-
disabledButton: {
|
|
264
|
-
opacity: 0.7
|
|
265
|
-
}
|
|
266
|
-
});
|
|
16
|
+
const styles = StyleSheet.create({});
|
|
267
17
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","SafeAreaView","Text","StyleSheet","View","TextInput","ScrollView","KeyboardAvoidingView","Platform","TouchableOpacity","RefreshControl","Ionicons","Icon","
|
|
1
|
+
{"version":3,"names":["React","useState","useCallback","SafeAreaView","Text","StyleSheet","View","TextInput","ScrollView","KeyboardAvoidingView","Platform","TouchableOpacity","RefreshControl","Ionicons","Icon","AppProvider","Layout","Chat","data","onProductCardClick","onAddToCartClick","createElement","styles","create"],"sourceRoot":"../../src","sources":["index.js"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,WAAW,QAAQ,OAAO;AACpD,SAASC,YAAY,EAAEC,IAAI,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAEC,oBAAoB,EACxFC,QAAQ,EAAEC,gBAAgB,EAAEC,cAAc,QAAS,cAAc;AACnE,SAASC,QAAQ,IAAIC,IAAI,QAAQ,oBAAoB;AACrD,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,MAAM,QAAQ,iBAAiB;AAExC,OAAO,MAAMC,IAAI,GAAGA,CAAC;EAACC,IAAI;EAAEC,kBAAkB;EAAEC;AAAiB,CAAC,KAAK;EAErE,oBACEpB,KAAA,CAAAqB,aAAA,CAACN,WAAW,qBACVf,KAAA,CAAAqB,aAAA,CAACL,MAAM;IAACG,kBAAkB,EAAEA,kBAAmB;IAACC,gBAAgB,EAAEA;EAAiB,CAAC,CACzE,CAAC;AAElB,CAAC;AAED,MAAME,MAAM,GAAGjB,UAAU,CAACkB,MAAM,CAAC,CACjC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { TouchableOpacity, View, StyleSheet } from 'react-native';
|
|
3
|
+
import { Ionicons as Icon } from '@expo/vector-icons';
|
|
4
|
+
import { AppContext } from '../contexts/AppContext';
|
|
5
|
+
export const ChatIcon = () => {
|
|
6
|
+
const {
|
|
7
|
+
setShowModal
|
|
8
|
+
} = useContext(AppContext);
|
|
9
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
10
|
+
style: styles.iconContainer,
|
|
11
|
+
onPress: () => setShowModal("ChatWindow")
|
|
12
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
13
|
+
style: styles.icon
|
|
14
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
15
|
+
name: "chatbubble-ellipses",
|
|
16
|
+
size: 28,
|
|
17
|
+
color: "white"
|
|
18
|
+
})));
|
|
19
|
+
};
|
|
20
|
+
const styles = StyleSheet.create({
|
|
21
|
+
iconContainer: {
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
bottom: 80,
|
|
24
|
+
right: 20,
|
|
25
|
+
zIndex: 10
|
|
26
|
+
},
|
|
27
|
+
icon: {
|
|
28
|
+
backgroundColor: '#FFA500',
|
|
29
|
+
width: 60,
|
|
30
|
+
height: 60,
|
|
31
|
+
borderRadius: 30,
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
shadowColor: '#000',
|
|
35
|
+
shadowOffset: {
|
|
36
|
+
width: 0,
|
|
37
|
+
height: 2
|
|
38
|
+
},
|
|
39
|
+
shadowOpacity: 0.2,
|
|
40
|
+
shadowRadius: 3,
|
|
41
|
+
elevation: 5
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=chatIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useContext","TouchableOpacity","View","StyleSheet","Ionicons","Icon","AppContext","ChatIcon","setShowModal","createElement","style","styles","iconContainer","onPress","icon","name","size","color","create","position","bottom","right","zIndex","backgroundColor","width","height","borderRadius","alignItems","justifyContent","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation"],"sourceRoot":"../../../src","sources":["layout/chatIcon.js"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,gBAAgB,EAAEC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AACjE,SAASC,QAAQ,IAAIC,IAAI,QAAQ,oBAAoB;AACrD,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAM;EAC5B,MAAM;IAAEC;EAAa,CAAC,GAAGR,UAAU,CAACM,UAAU,CAAC;EAE/C,oBACEP,KAAA,CAAAU,aAAA,CAACR,gBAAgB;IAACS,KAAK,EAAEC,MAAM,CAACC,aAAc;IAACC,OAAO,EAAEA,CAAA,KAAML,YAAY,CAAC,YAAY;EAAE,gBACvFT,KAAA,CAAAU,aAAA,CAACP,IAAI;IAACQ,KAAK,EAAEC,MAAM,CAACG;EAAK,gBACvBf,KAAA,CAAAU,aAAA,CAACJ,IAAI;IAACU,IAAI,EAAC,qBAAqB;IAACC,IAAI,EAAE,EAAG;IAACC,KAAK,EAAC;EAAO,CAAE,CACtD,CACU,CAAC;AAEvB,CAAC;AAED,MAAMN,MAAM,GAAGR,UAAU,CAACe,MAAM,CAAC;EAC/BN,aAAa,EAAE;IACbO,QAAQ,EAAE,UAAU;IACpBC,MAAM,EAAE,EAAE;IACVC,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE;EACV,CAAC;EACDR,IAAI,EAAE;IACJS,eAAe,EAAE,SAAS;IAC1BC,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACVC,YAAY,EAAE,EAAE;IAChBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,WAAW,EAAE,MAAM;IACnBC,YAAY,EAAE;MAAEN,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC;IACrCM,aAAa,EAAE,GAAG;IAClBC,YAAY,EAAE,CAAC;IACfC,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import React, { useState, useCallback, useContext } from 'react';
|
|
2
|
+
import { SafeAreaView, Text, StyleSheet, View, TextInput, ScrollView, KeyboardAvoidingView, Platform, TouchableOpacity, RefreshControl } from 'react-native';
|
|
3
|
+
import { Ionicons as Icon } from '@expo/vector-icons';
|
|
4
|
+
import { Header } from '../components/header';
|
|
5
|
+
import { AppContext } from '../contexts/AppContext';
|
|
6
|
+
import { Testing } from '../components/testing';
|
|
7
|
+
const theme = {
|
|
8
|
+
primaryColor: '#003764',
|
|
9
|
+
backgroundColor: '#f6f6f6',
|
|
10
|
+
textColor: '#000000',
|
|
11
|
+
inputBackgroundColor: '#f6f6f6'
|
|
12
|
+
};
|
|
13
|
+
export const ChatWindow = ({
|
|
14
|
+
onProductCardClick,
|
|
15
|
+
onAddToCartClick
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
handleSend,
|
|
19
|
+
messages,
|
|
20
|
+
setMessages,
|
|
21
|
+
onSendMessage,
|
|
22
|
+
input,
|
|
23
|
+
setInput
|
|
24
|
+
} = useContext(AppContext);
|
|
25
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
26
|
+
const onRefresh = useCallback(async () => {
|
|
27
|
+
setRefreshing(true);
|
|
28
|
+
try {
|
|
29
|
+
const response = await onSendMessage("Hi, I'm refreshing the chat!");
|
|
30
|
+
setMessages(prev => [...prev, {
|
|
31
|
+
text: response,
|
|
32
|
+
isUser: false
|
|
33
|
+
}]);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Error refreshing chat:', error);
|
|
36
|
+
} finally {
|
|
37
|
+
setRefreshing(false);
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
const getMessageStyle = type => [styles.messageBubble, type === "user" ? styles.userMessage : styles.aiMessage, {
|
|
41
|
+
backgroundColor: type === "user" ? theme.primaryColor : '#E8E8E8'
|
|
42
|
+
}];
|
|
43
|
+
const getTextStyle = type => [styles.messageText, {
|
|
44
|
+
color: type === "user" ? '#fff' : theme.textColor
|
|
45
|
+
}];
|
|
46
|
+
return /*#__PURE__*/React.createElement(SafeAreaView, {
|
|
47
|
+
style: [styles.container, {
|
|
48
|
+
backgroundColor: theme.backgroundColor
|
|
49
|
+
}]
|
|
50
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
51
|
+
style: styles.chatWindow
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Header, null), /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
|
|
53
|
+
behavior: Platform.OS === 'ios' ? 'padding' : 'height',
|
|
54
|
+
style: styles.content,
|
|
55
|
+
keyboardVerticalOffset: Platform.OS === 'ios' ? 60 : 0
|
|
56
|
+
}, /*#__PURE__*/React.createElement(ScrollView, {
|
|
57
|
+
style: styles.messagesContainer,
|
|
58
|
+
contentContainerStyle: styles.messagesContent,
|
|
59
|
+
refreshControl: /*#__PURE__*/React.createElement(RefreshControl, {
|
|
60
|
+
refreshing: refreshing,
|
|
61
|
+
onRefresh: onRefresh,
|
|
62
|
+
tintColor: theme.primaryColor,
|
|
63
|
+
colors: [theme.primaryColor],
|
|
64
|
+
progressBackgroundColor: "#ffffff"
|
|
65
|
+
})
|
|
66
|
+
}, messages.map((msg, i) => /*#__PURE__*/React.createElement(View, {
|
|
67
|
+
key: i,
|
|
68
|
+
style: styles.messageWrapper
|
|
69
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
70
|
+
style: [getMessageStyle(msg.type), styles.messageShadow]
|
|
71
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
72
|
+
style: getTextStyle(msg.type)
|
|
73
|
+
}, msg.text))))), /*#__PURE__*/React.createElement(Testing, {
|
|
74
|
+
onProductCardClick: onProductCardClick,
|
|
75
|
+
onAddToCartClick: onAddToCartClick
|
|
76
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
77
|
+
style: styles.inputWrapper
|
|
78
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
79
|
+
style: styles.inputContainer
|
|
80
|
+
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
81
|
+
style: styles.input,
|
|
82
|
+
value: input,
|
|
83
|
+
onChangeText: setInput,
|
|
84
|
+
placeholder: "Ask a question...",
|
|
85
|
+
placeholderTextColor: "#999",
|
|
86
|
+
multiline: true
|
|
87
|
+
}), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
88
|
+
style: styles.inputButton
|
|
89
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
90
|
+
name: "mic-outline",
|
|
91
|
+
size: 24,
|
|
92
|
+
color: "#8E8E93"
|
|
93
|
+
})), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
94
|
+
style: [styles.sendButton, !input.trim() && styles.disabledButton],
|
|
95
|
+
onPress: handleSend,
|
|
96
|
+
disabled: !input.trim()
|
|
97
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
98
|
+
name: "paper-plane-outline",
|
|
99
|
+
size: 24,
|
|
100
|
+
color: input.trim() ? theme.primaryColor : '#8E8E93'
|
|
101
|
+
})))))));
|
|
102
|
+
};
|
|
103
|
+
const styles = StyleSheet.create({
|
|
104
|
+
container: {
|
|
105
|
+
flex: 1,
|
|
106
|
+
backgroundColor: '#FFFFFF'
|
|
107
|
+
},
|
|
108
|
+
chatWindow: {
|
|
109
|
+
zIndex: 1,
|
|
110
|
+
flex: 1,
|
|
111
|
+
marginTop: 40,
|
|
112
|
+
borderTopWidth: 1,
|
|
113
|
+
borderTopColor: '#DDD',
|
|
114
|
+
borderTopLeftRadius: 16,
|
|
115
|
+
borderTopRightRadius: 16,
|
|
116
|
+
overflow: 'hidden',
|
|
117
|
+
backgroundColor: theme.backgroundColor
|
|
118
|
+
},
|
|
119
|
+
content: {
|
|
120
|
+
flex: 1
|
|
121
|
+
},
|
|
122
|
+
messagesContainer: {
|
|
123
|
+
flex: 1
|
|
124
|
+
},
|
|
125
|
+
messagesContent: {
|
|
126
|
+
padding: 16,
|
|
127
|
+
paddingBottom: 32
|
|
128
|
+
},
|
|
129
|
+
messageWrapper: {
|
|
130
|
+
marginBottom: 16
|
|
131
|
+
},
|
|
132
|
+
messageBubble: {
|
|
133
|
+
maxWidth: '90%',
|
|
134
|
+
padding: 12,
|
|
135
|
+
paddingHorizontal: 16,
|
|
136
|
+
borderRadius: 20
|
|
137
|
+
},
|
|
138
|
+
messageShadow: {
|
|
139
|
+
shadowColor: '#000',
|
|
140
|
+
shadowOffset: {
|
|
141
|
+
width: 0,
|
|
142
|
+
height: 1
|
|
143
|
+
},
|
|
144
|
+
shadowOpacity: 0.08,
|
|
145
|
+
shadowRadius: 2,
|
|
146
|
+
elevation: 2
|
|
147
|
+
},
|
|
148
|
+
userMessage: {
|
|
149
|
+
alignSelf: 'flex-end',
|
|
150
|
+
backgroundColor: theme.primaryColor
|
|
151
|
+
},
|
|
152
|
+
aiMessage: {
|
|
153
|
+
alignSelf: 'flex-start',
|
|
154
|
+
backgroundColor: '#F2F2F7'
|
|
155
|
+
},
|
|
156
|
+
messageText: {
|
|
157
|
+
fontSize: 16,
|
|
158
|
+
lineHeight: 22
|
|
159
|
+
},
|
|
160
|
+
inputWrapper: {
|
|
161
|
+
backgroundColor: '#f6f6f6',
|
|
162
|
+
paddingHorizontal: 8,
|
|
163
|
+
paddingVertical: 8,
|
|
164
|
+
borderTopWidth: 1,
|
|
165
|
+
borderTopColor: 'rgba(0, 0, 0, 0.1)'
|
|
166
|
+
},
|
|
167
|
+
inputContainer: {
|
|
168
|
+
flexDirection: 'row',
|
|
169
|
+
alignItems: 'center',
|
|
170
|
+
paddingHorizontal: 8,
|
|
171
|
+
paddingVertical: 8,
|
|
172
|
+
backgroundColor: '#FFFFFF',
|
|
173
|
+
borderRadius: 16,
|
|
174
|
+
margin: 8,
|
|
175
|
+
shadowColor: '#000',
|
|
176
|
+
shadowOffset: {
|
|
177
|
+
width: 0,
|
|
178
|
+
height: 2
|
|
179
|
+
},
|
|
180
|
+
shadowOpacity: 0.1,
|
|
181
|
+
shadowRadius: 4,
|
|
182
|
+
elevation: 3
|
|
183
|
+
},
|
|
184
|
+
input: {
|
|
185
|
+
flex: 1,
|
|
186
|
+
fontSize: 16,
|
|
187
|
+
paddingVertical: 8,
|
|
188
|
+
paddingHorizontal: 12,
|
|
189
|
+
color: '#000000'
|
|
190
|
+
},
|
|
191
|
+
sendButton: {
|
|
192
|
+
padding: 6,
|
|
193
|
+
marginLeft: 'auto'
|
|
194
|
+
},
|
|
195
|
+
disabledButton: {
|
|
196
|
+
opacity: 0.7
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
//# sourceMappingURL=chatWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useState","useCallback","useContext","SafeAreaView","Text","StyleSheet","View","TextInput","ScrollView","KeyboardAvoidingView","Platform","TouchableOpacity","RefreshControl","Ionicons","Icon","Header","AppContext","Testing","theme","primaryColor","backgroundColor","textColor","inputBackgroundColor","ChatWindow","onProductCardClick","onAddToCartClick","handleSend","messages","setMessages","onSendMessage","input","setInput","refreshing","setRefreshing","onRefresh","response","prev","text","isUser","error","console","getMessageStyle","type","styles","messageBubble","userMessage","aiMessage","getTextStyle","messageText","color","createElement","style","container","chatWindow","behavior","OS","content","keyboardVerticalOffset","messagesContainer","contentContainerStyle","messagesContent","refreshControl","tintColor","colors","progressBackgroundColor","map","msg","i","key","messageWrapper","messageShadow","inputWrapper","inputContainer","value","onChangeText","placeholder","placeholderTextColor","multiline","inputButton","name","size","sendButton","trim","disabledButton","onPress","disabled","create","flex","zIndex","marginTop","borderTopWidth","borderTopColor","borderTopLeftRadius","borderTopRightRadius","overflow","padding","paddingBottom","marginBottom","maxWidth","paddingHorizontal","borderRadius","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","alignSelf","fontSize","lineHeight","paddingVertical","flexDirection","alignItems","margin","marginLeft","opacity"],"sourceRoot":"../../../src","sources":["layout/chatWindow.js"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,WAAW,EAAEC,UAAU,QAAQ,OAAO;AAChE,SAASC,YAAY,EAAEC,IAAI,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAEC,oBAAoB,EACtFC,QAAQ,EAAEC,gBAAgB,EAAEC,cAAc,QAAS,cAAc;AACrE,SAASC,QAAQ,IAAIC,IAAI,QAAQ,oBAAoB;AACrD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,OAAO,QAAQ,uBAAuB;AAE/C,MAAMC,KAAK,GAAG;EACZC,YAAY,EAAE,SAAS;EACvBC,eAAe,EAAE,SAAS;EAC1BC,SAAS,EAAE,SAAS;EACpBC,oBAAoB,EAAE;AACxB,CAAC;AAED,OAAO,MAAMC,UAAU,GAAGA,CAAC;EAAEC,kBAAkB;EAAEC;AAAiB,CAAC,KAAK;EACtE,MAAM;IAAEC,UAAU;IAAEC,QAAQ;IAAEC,WAAW;IAAEC,aAAa;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAG7B,UAAU,CAACc,UAAU,CAAC;EAEpG,MAAM,CAACgB,UAAU,EAAEC,aAAa,CAAC,GAAGjC,QA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d,iBAAiB,EAAE,CAAC;IACpBY,eAAe,EAAE,CAAC;IAClB3F,eAAe,EAAE,SAAS;IAC1BgF,YAAY,EAAE,EAAE;IAChBc,MAAM,EAAE,CAAC;IACTb,WAAW,EAAE,MAAM;IACnBC,YAAY,EAAE;MACZC,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE;IACV,CAAC;IACDC,aAAa,EAAE,GAAG;IAClBC,YAAY,EAAE,CAAC;IACfC,SAAS,EAAE;EACb,CAAC;EACD7E,KAAK,EAAE;IACLyD,IAAI,EAAE,CAAC;IACPsB,QAAQ,EAAE,EAAE;IACZE,eAAe,EAAE,CAAC;IAClBZ,iBAAiB,EAAE,EAAE;IACrBlD,KAAK,EAAE;EACT,CAAC;EACDgC,UAAU,EAAE;IACVc,OAAO,EAAE,CAAC;IACVoB,UAAU,EAAE;EACd,CAAC;EACDhC,cAAc,EAAE;IACdiC,OAAO,EAAE;EACX;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { useState, useCallback, useContext } from 'react';
|
|
2
|
+
import { SafeAreaView, Text, StyleSheet, View, TextInput, ScrollView, KeyboardAvoidingView, Platform, TouchableOpacity, RefreshControl } from 'react-native';
|
|
3
|
+
import { Ionicons as Icon } from '@expo/vector-icons';
|
|
4
|
+
import { ChatWindow } from './chatWindow';
|
|
5
|
+
import { AppContext } from '../contexts/AppContext';
|
|
6
|
+
import { ChatIcon } from './chatIcon';
|
|
7
|
+
export const Layout = ({
|
|
8
|
+
onProductCardClick,
|
|
9
|
+
onAddToCartClick
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
showModal
|
|
13
|
+
} = useContext(AppContext);
|
|
14
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
15
|
+
style: styles.container
|
|
16
|
+
}, showModal === "Icon" ? /*#__PURE__*/React.createElement(ChatIcon, null) : /*#__PURE__*/React.createElement(ChatWindow, {
|
|
17
|
+
onProductCardClick: onProductCardClick,
|
|
18
|
+
onAddToCartClick: onAddToCartClick
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
container: {
|
|
23
|
+
flex: 1
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useState","useCallback","useContext","SafeAreaView","Text","StyleSheet","View","TextInput","ScrollView","KeyboardAvoidingView","Platform","TouchableOpacity","RefreshControl","Ionicons","Icon","ChatWindow","AppContext","ChatIcon","Layout","onProductCardClick","onAddToCartClick","showModal","createElement","style","styles","container","create","flex"],"sourceRoot":"../../../src","sources":["layout/layout.js"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,WAAW,EAAEC,UAAU,QAAQ,OAAO;AAChE,SAASC,YAAY,EAAEC,IAAI,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAEC,oBAAoB,EACxFC,QAAQ,EAAEC,gBAAgB,EAAEC,cAAc,QAAS,cAAc;AACnE,SAASC,QAAQ,IAAIC,IAAI,QAAQ,oBAAoB;AACrD,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,QAAQ,QAAQ,YAAY;AAErC,OAAO,MAAMC,MAAM,GAAGA,CAAC;EAAEC,kBAAkB;EAAEC;AAAiB,CAAC,KAAK;EAChE,MAAM;IAAEC;EAAU,CAAC,GAAGnB,UAAU,CAACc,UAAU,CAAC;EAE5C,oBACEjB,KAAA,CAAAuB,aAAA,CAAChB,IAAI;IAACiB,KAAK,EAAEC,MAAM,CAACC;EAAU,GAC3BJ,SAAS,KAAK,MAAM,gBAAGtB,KAAA,CAAAuB,aAAA,CAACL,QAAQ,MAAE,CAAC,gBAAGlB,KAAA,CAAAuB,aAAA,CAACP,UAAU;IAACI,kBAAkB,EAAEA,kBAAmB;IAACC,gBAAgB,EAAEA;EAAiB,CAAC,CAC3H,CAAC;AAEb,CAAC;AAED,MAAMI,MAAM,GAAGnB,UAAU,CAACqB,MAAM,CAAC;EAC7BD,SAAS,EAAE;IACTE,IAAI,EAAE;EACR;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/components/header.js"],"names":[],"mappings":"AAKO,4CA+BN;kBApCiC,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/components/testing.js"],"names":[],"mappings":"AAGO;;;sBAgCN;kBAnCiB,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppContext.d.ts","sourceRoot":"","sources":["../../../src/contexts/AppContext.js"],"names":[],"mappings":"AAEA,4CAA0C;AAEnC;;sBA8EN;kBAlFoE,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stream.d.ts","sourceRoot":"","sources":["../../../src/hooks/Stream.js"],"names":[],"mappings":"AAGA,4CAkMC"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
+
export function Chat({ data, onProductCardClick, onAddToCartClick }: {
|
|
2
|
+
data: any;
|
|
3
|
+
onProductCardClick: any;
|
|
4
|
+
onAddToCartClick: any;
|
|
5
|
+
}): React.JSX.Element;
|
|
1
6
|
import React from 'react';
|
|
2
|
-
interface ChatProps {
|
|
3
|
-
onSendMessage: (message: string, onStream?: (chunk: string) => void) => Promise<string>;
|
|
4
|
-
placeholder?: string;
|
|
5
|
-
theme?: {
|
|
6
|
-
primaryColor?: string;
|
|
7
|
-
backgroundColor?: string;
|
|
8
|
-
textColor?: string;
|
|
9
|
-
inputBackgroundColor?: string;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export declare const Chat: React.FC<ChatProps>;
|
|
13
|
-
export {};
|
|
14
7
|
//# sourceMappingURL=index.d.ts.map
|