@developer_tribe/react-native-comnyx 0.3.5 → 0.3.7
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/lib/commonjs/assets/arrow-right.png +0 -0
- package/lib/commonjs/assets/down.png +0 -0
- package/lib/commonjs/assets/info-circle.png +0 -0
- package/lib/commonjs/components/ChatList.js +99 -37
- package/lib/commonjs/components/ChatList.js.map +1 -1
- package/lib/commonjs/components/CustomAlert.js +15 -5
- package/lib/commonjs/components/CustomAlert.js.map +1 -1
- package/lib/commonjs/components/CustomerForm.js +13 -10
- package/lib/commonjs/components/CustomerForm.js.map +1 -1
- package/lib/commonjs/components/InitFailed.js +2 -0
- package/lib/commonjs/components/InitFailed.js.map +1 -1
- package/lib/commonjs/components/MessageInput.js +14 -14
- package/lib/commonjs/components/MessageInput.js.map +1 -1
- package/lib/commonjs/components/MessageItem.js +6 -14
- package/lib/commonjs/components/MessageItem.js.map +1 -1
- package/lib/commonjs/constants/activeOpacity.js +8 -0
- package/lib/commonjs/constants/activeOpacity.js.map +1 -0
- package/lib/commonjs/constants/translations.js +202 -42
- package/lib/commonjs/constants/translations.js.map +1 -1
- package/lib/commonjs/data/fake/messages.js +2 -0
- package/lib/commonjs/data/fake/messages.js.map +1 -1
- package/lib/commonjs/hooks/useThemeColors.js +1 -7
- package/lib/commonjs/hooks/useThemeColors.js.map +1 -1
- package/lib/commonjs/types/Theme.js +4 -2
- package/lib/commonjs/types/Theme.js.map +1 -1
- package/lib/module/assets/arrow-right.png +0 -0
- package/lib/module/assets/down.png +0 -0
- package/lib/module/assets/info-circle.png +0 -0
- package/lib/module/components/ChatList.js +100 -38
- package/lib/module/components/ChatList.js.map +1 -1
- package/lib/module/components/CustomAlert.js +15 -5
- package/lib/module/components/CustomAlert.js.map +1 -1
- package/lib/module/components/CustomerForm.js +13 -10
- package/lib/module/components/CustomerForm.js.map +1 -1
- package/lib/module/components/InitFailed.js +2 -0
- package/lib/module/components/InitFailed.js.map +1 -1
- package/lib/module/components/MessageInput.js +14 -14
- package/lib/module/components/MessageInput.js.map +1 -1
- package/lib/module/components/MessageItem.js +6 -14
- package/lib/module/components/MessageItem.js.map +1 -1
- package/lib/module/constants/activeOpacity.js +4 -0
- package/lib/module/constants/activeOpacity.js.map +1 -0
- package/lib/module/constants/translations.js +202 -42
- package/lib/module/constants/translations.js.map +1 -1
- package/lib/module/data/fake/messages.js +2 -0
- package/lib/module/data/fake/messages.js.map +1 -1
- package/lib/module/hooks/useThemeColors.js +2 -8
- package/lib/module/hooks/useThemeColors.js.map +1 -1
- package/lib/module/types/Theme.js +4 -2
- package/lib/module/types/Theme.js.map +1 -1
- package/lib/typescript/commonjs/src/components/ChatList.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/CustomAlert.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/CustomerForm.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/InitFailed.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/MessageInput.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/constants/activeOpacity.d.ts +2 -0
- package/lib/typescript/commonjs/src/constants/activeOpacity.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/constants/translations.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/data/fake/messages.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useThemeColors.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/Conversation.d.ts +6 -1
- package/lib/typescript/commonjs/src/types/Conversation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/LocalizationKeys.d.ts +16 -0
- package/lib/typescript/commonjs/src/types/LocalizationKeys.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/MessageResponse.d.ts +2 -0
- package/lib/typescript/commonjs/src/types/MessageResponse.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/Theme.d.ts +1 -0
- package/lib/typescript/commonjs/src/types/Theme.d.ts.map +1 -1
- package/lib/typescript/module/src/components/ChatList.d.ts.map +1 -1
- package/lib/typescript/module/src/components/CustomAlert.d.ts.map +1 -1
- package/lib/typescript/module/src/components/CustomerForm.d.ts.map +1 -1
- package/lib/typescript/module/src/components/InitFailed.d.ts.map +1 -1
- package/lib/typescript/module/src/components/MessageInput.d.ts.map +1 -1
- package/lib/typescript/module/src/constants/activeOpacity.d.ts +2 -0
- package/lib/typescript/module/src/constants/activeOpacity.d.ts.map +1 -0
- package/lib/typescript/module/src/constants/translations.d.ts.map +1 -1
- package/lib/typescript/module/src/data/fake/messages.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useThemeColors.d.ts.map +1 -1
- package/lib/typescript/module/src/types/Conversation.d.ts +6 -1
- package/lib/typescript/module/src/types/Conversation.d.ts.map +1 -1
- package/lib/typescript/module/src/types/LocalizationKeys.d.ts +16 -0
- package/lib/typescript/module/src/types/LocalizationKeys.d.ts.map +1 -1
- package/lib/typescript/module/src/types/MessageResponse.d.ts +2 -0
- package/lib/typescript/module/src/types/MessageResponse.d.ts.map +1 -1
- package/lib/typescript/module/src/types/Theme.d.ts +1 -0
- package/lib/typescript/module/src/types/Theme.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/assets/arrow-right.png +0 -0
- package/src/assets/down.png +0 -0
- package/src/assets/info-circle.png +0 -0
- package/src/components/ChatList.tsx +116 -42
- package/src/components/CustomAlert.tsx +24 -6
- package/src/components/CustomerForm.tsx +13 -9
- package/src/components/InitFailed.tsx +2 -0
- package/src/components/MessageInput.tsx +15 -16
- package/src/components/MessageItem.tsx +4 -12
- package/src/constants/activeOpacity.ts +1 -0
- package/src/constants/translations.ts +281 -68
- package/src/data/fake/messages.ts +2 -0
- package/src/hooks/useThemeColors.ts +2 -7
- package/src/types/Conversation.ts +3 -1
- package/src/types/LocalizationKeys.ts +16 -0
- package/src/types/MessageResponse.ts +2 -0
- package/src/types/Theme.ts +3 -0
|
@@ -16,6 +16,8 @@ import { useThemeColors } from '../hooks/useThemeColors';
|
|
|
16
16
|
import CustomPopup from './CustomAlert';
|
|
17
17
|
import { useState } from 'react';
|
|
18
18
|
import { ScaledSheet } from './ScaledSheet';
|
|
19
|
+
import type { LocalizationKeys } from '../types/LocalizationKeys';
|
|
20
|
+
import { activeOpacity } from '../constants/activeOpacity';
|
|
19
21
|
|
|
20
22
|
interface CustomerFormData {
|
|
21
23
|
name: string;
|
|
@@ -109,6 +111,7 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
|
|
|
109
111
|
]}
|
|
110
112
|
>
|
|
111
113
|
<TouchableOpacity
|
|
114
|
+
activeOpacity={activeOpacity}
|
|
112
115
|
style={[
|
|
113
116
|
styles.iconContainer,
|
|
114
117
|
{ backgroundColor: themeColors.dark_background },
|
|
@@ -144,7 +147,7 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
|
|
|
144
147
|
},
|
|
145
148
|
]}
|
|
146
149
|
>
|
|
147
|
-
{localize('customer.form.
|
|
150
|
+
{localize('customer.form.name')}
|
|
148
151
|
</AppText>
|
|
149
152
|
<Controller
|
|
150
153
|
control={control}
|
|
@@ -158,7 +161,7 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
|
|
|
158
161
|
<View
|
|
159
162
|
style={[
|
|
160
163
|
styles.inputContainer,
|
|
161
|
-
{ borderBottomColor: themeColors.
|
|
164
|
+
{ borderBottomColor: themeColors.ghost },
|
|
162
165
|
]}
|
|
163
166
|
>
|
|
164
167
|
<TextInput
|
|
@@ -200,7 +203,7 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
|
|
|
200
203
|
<View
|
|
201
204
|
style={[
|
|
202
205
|
styles.inputContainer,
|
|
203
|
-
{ borderBottomColor: themeColors.
|
|
206
|
+
{ borderBottomColor: themeColors.ghost },
|
|
204
207
|
]}
|
|
205
208
|
>
|
|
206
209
|
<TextInput
|
|
@@ -246,7 +249,7 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
|
|
|
246
249
|
<View
|
|
247
250
|
style={[
|
|
248
251
|
styles.inputContainer,
|
|
249
|
-
{ borderBottomColor: themeColors.
|
|
252
|
+
{ borderBottomColor: themeColors.ghost },
|
|
250
253
|
]}
|
|
251
254
|
>
|
|
252
255
|
<TextInput
|
|
@@ -269,6 +272,7 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
|
|
|
269
272
|
/>
|
|
270
273
|
</View>
|
|
271
274
|
<TouchableOpacity
|
|
275
|
+
activeOpacity={activeOpacity}
|
|
272
276
|
style={[
|
|
273
277
|
styles.button,
|
|
274
278
|
{ backgroundColor: themeColors.dark_background },
|
|
@@ -291,9 +295,7 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
|
|
|
291
295
|
setPopupVisible(false);
|
|
292
296
|
setPopupContent({ title: '', description: '' });
|
|
293
297
|
}}
|
|
294
|
-
|
|
295
|
-
setPopupVisible(false);
|
|
296
|
-
}}
|
|
298
|
+
buttonText={'customer.form.cancel' as keyof LocalizationKeys}
|
|
297
299
|
/>
|
|
298
300
|
</Pressable>
|
|
299
301
|
);
|
|
@@ -301,7 +303,8 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
|
|
|
301
303
|
|
|
302
304
|
const styles = ScaledSheet.create({
|
|
303
305
|
container: {
|
|
304
|
-
paddingBottom: '
|
|
306
|
+
paddingBottom: '20@vs',
|
|
307
|
+
paddingTop: '40@vs',
|
|
305
308
|
flex: 1,
|
|
306
309
|
justifyContent: 'space-between',
|
|
307
310
|
},
|
|
@@ -359,10 +362,11 @@ const styles = ScaledSheet.create({
|
|
|
359
362
|
},
|
|
360
363
|
title: {
|
|
361
364
|
fontSize: '16@vs',
|
|
365
|
+
fontWeight: '500',
|
|
362
366
|
},
|
|
363
367
|
iconContainer: {
|
|
364
368
|
paddingHorizontal: '20@s',
|
|
365
|
-
paddingVertical: '
|
|
369
|
+
paddingVertical: '30@vs',
|
|
366
370
|
},
|
|
367
371
|
inputContainer: {
|
|
368
372
|
flexDirection: 'row',
|
|
@@ -2,6 +2,7 @@ import { TouchableOpacity, View } from 'react-native';
|
|
|
2
2
|
import { useThemeColors } from '../hooks/useThemeColors';
|
|
3
3
|
import { AppText } from './AppText';
|
|
4
4
|
import { ScaledSheet } from './ScaledSheet';
|
|
5
|
+
import { activeOpacity } from '../constants/activeOpacity';
|
|
5
6
|
|
|
6
7
|
interface InitFailedProps {
|
|
7
8
|
setInitFailed: (value: boolean) => void;
|
|
@@ -15,6 +16,7 @@ export function InitFailed({ setInitFailed }: InitFailedProps) {
|
|
|
15
16
|
style={[styles.container, { backgroundColor: themeColors.background }]}
|
|
16
17
|
>
|
|
17
18
|
<TouchableOpacity
|
|
19
|
+
activeOpacity={activeOpacity}
|
|
18
20
|
style={[styles.retryButton, { backgroundColor: themeColors.primary }]}
|
|
19
21
|
onPress={() => setInitFailed(false)}
|
|
20
22
|
>
|
|
@@ -4,6 +4,8 @@ import { useState } from 'react';
|
|
|
4
4
|
import { sendCustomerMessage } from '../api';
|
|
5
5
|
import { useThemeColors } from '../hooks/useThemeColors';
|
|
6
6
|
import { ScaledSheet } from './ScaledSheet';
|
|
7
|
+
import { useLocalize } from '../hooks/useLocalize';
|
|
8
|
+
import { activeOpacity } from '../constants/activeOpacity';
|
|
7
9
|
|
|
8
10
|
const sendDark = require('../assets/arrow-right.png');
|
|
9
11
|
|
|
@@ -16,6 +18,7 @@ export function MessageInput({
|
|
|
16
18
|
const [value, setValue] = useState('');
|
|
17
19
|
const customer = useAppStore((s) => s.customer!);
|
|
18
20
|
const themeColors = useThemeColors();
|
|
21
|
+
const localize = useLocalize();
|
|
19
22
|
|
|
20
23
|
const sendMessage = () => {
|
|
21
24
|
if (value.trim()) {
|
|
@@ -26,7 +29,7 @@ export function MessageInput({
|
|
|
26
29
|
approved: false,
|
|
27
30
|
content: value,
|
|
28
31
|
created_at: date,
|
|
29
|
-
|
|
32
|
+
customer: {
|
|
30
33
|
name: customer.name,
|
|
31
34
|
profile_photo_url: null,
|
|
32
35
|
},
|
|
@@ -51,7 +54,8 @@ export function MessageInput({
|
|
|
51
54
|
alteredData[itemIndex] = {
|
|
52
55
|
id: res.message.id,
|
|
53
56
|
content: res.message.content,
|
|
54
|
-
|
|
57
|
+
customer:
|
|
58
|
+
res.message.customer ?? alteredData[itemIndex]?.customer,
|
|
55
59
|
created_at: new Date(res.message.created_at),
|
|
56
60
|
approved: true,
|
|
57
61
|
};
|
|
@@ -82,7 +86,7 @@ export function MessageInput({
|
|
|
82
86
|
content: alteredData[itemIndex]?.content ?? '',
|
|
83
87
|
created_at: alteredData[itemIndex]?.created_at ?? new Date(),
|
|
84
88
|
approved: alteredData[itemIndex]?.approved ?? false,
|
|
85
|
-
|
|
89
|
+
customer: alteredData[itemIndex]?.customer ?? null,
|
|
86
90
|
error: true,
|
|
87
91
|
};
|
|
88
92
|
useAppStore.setState({
|
|
@@ -114,23 +118,18 @@ export function MessageInput({
|
|
|
114
118
|
{
|
|
115
119
|
backgroundColor: themeColors.background,
|
|
116
120
|
color: themeColors.text,
|
|
117
|
-
borderColor: themeColors.
|
|
121
|
+
borderColor: themeColors.silver,
|
|
118
122
|
},
|
|
119
123
|
]}
|
|
120
|
-
placeholder=
|
|
124
|
+
placeholder={localize('chat.messageInput.placeholder')}
|
|
121
125
|
placeholderTextColor={themeColors.text + '80'}
|
|
122
126
|
/>
|
|
123
127
|
<TouchableOpacity
|
|
124
|
-
style={[
|
|
125
|
-
styles.sendButton,
|
|
126
|
-
{ backgroundColor: themeColors.dark_background },
|
|
127
|
-
]}
|
|
128
|
+
style={[styles.sendButton]}
|
|
128
129
|
onPress={sendMessage}
|
|
130
|
+
activeOpacity={activeOpacity}
|
|
129
131
|
>
|
|
130
|
-
<Image
|
|
131
|
-
style={[styles.sendIcon, { tintColor: themeColors.light_text }]}
|
|
132
|
-
source={sendDark}
|
|
133
|
-
/>
|
|
132
|
+
<Image style={[styles.sendIcon]} source={sendDark} />
|
|
134
133
|
</TouchableOpacity>
|
|
135
134
|
</View>
|
|
136
135
|
);
|
|
@@ -157,14 +156,14 @@ const styles = ScaledSheet.create({
|
|
|
157
156
|
maxHeight: 190,
|
|
158
157
|
},
|
|
159
158
|
sendButton: {
|
|
160
|
-
width: '40@
|
|
159
|
+
width: '40@vs',
|
|
161
160
|
height: '40@vs',
|
|
162
161
|
borderRadius: '20@vs',
|
|
163
162
|
justifyContent: 'center',
|
|
164
163
|
alignItems: 'center',
|
|
165
164
|
},
|
|
166
165
|
sendIcon: {
|
|
167
|
-
width: '
|
|
168
|
-
height: '
|
|
166
|
+
width: '40@vs',
|
|
167
|
+
height: '40@vs',
|
|
169
168
|
},
|
|
170
169
|
});
|
|
@@ -30,7 +30,7 @@ export function MessageItem({
|
|
|
30
30
|
onShowPopup: () => void;
|
|
31
31
|
}) {
|
|
32
32
|
const themeColors = useThemeColors();
|
|
33
|
-
const isDeviceOwner =
|
|
33
|
+
const isDeviceOwner = !item.user && !item.bot;
|
|
34
34
|
const formattedDate = new Date(item.created_at).toLocaleTimeString([], {
|
|
35
35
|
hour: '2-digit',
|
|
36
36
|
minute: '2-digit',
|
|
@@ -102,7 +102,7 @@ export function MessageItem({
|
|
|
102
102
|
// A single line message with enough space for the timestamp
|
|
103
103
|
const isSingleLineWithSpace =
|
|
104
104
|
layoutRef.current.lines === 1 &&
|
|
105
|
-
layoutRef.current.lastLineWidth
|
|
105
|
+
layoutRef.current.lastLineWidth > layoutRef.current.totalWidth * 0.8;
|
|
106
106
|
|
|
107
107
|
// For multi-line messages, check if the last line has space
|
|
108
108
|
const isMultiLineWithSpace =
|
|
@@ -126,8 +126,8 @@ export function MessageItem({
|
|
|
126
126
|
style={[
|
|
127
127
|
styles.messageBubble,
|
|
128
128
|
isDeviceOwner
|
|
129
|
-
?
|
|
130
|
-
:
|
|
129
|
+
? { backgroundColor: themeColors.light_green }
|
|
130
|
+
: { backgroundColor: themeColors.ghost },
|
|
131
131
|
]}
|
|
132
132
|
>
|
|
133
133
|
<View
|
|
@@ -173,7 +173,6 @@ export function MessageItem({
|
|
|
173
173
|
|
|
174
174
|
const styles = ScaledSheet.create({
|
|
175
175
|
messageItem: {
|
|
176
|
-
marginVertical: '5@vs',
|
|
177
176
|
maxWidth: '80%',
|
|
178
177
|
minHeight: 60,
|
|
179
178
|
minWidth: 100,
|
|
@@ -189,12 +188,6 @@ const styles = ScaledSheet.create({
|
|
|
189
188
|
paddingHorizontal: '12@s',
|
|
190
189
|
borderRadius: '20@vs',
|
|
191
190
|
},
|
|
192
|
-
leftBubble: {
|
|
193
|
-
borderTopLeftRadius: 4,
|
|
194
|
-
},
|
|
195
|
-
rightBubble: {
|
|
196
|
-
borderTopRightRadius: 4,
|
|
197
|
-
},
|
|
198
191
|
inlineContainer: {
|
|
199
192
|
flexDirection: 'row',
|
|
200
193
|
justifyContent: 'space-between',
|
|
@@ -250,7 +243,6 @@ const styles = ScaledSheet.create({
|
|
|
250
243
|
width: '12@vs',
|
|
251
244
|
height: '12@vs',
|
|
252
245
|
marginLeft: '4@s',
|
|
253
|
-
tintColor: '#000000',
|
|
254
246
|
},
|
|
255
247
|
infoIcon: {
|
|
256
248
|
width: '12@vs',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const activeOpacity = 0.8;
|