@developer_tribe/react-native-comnyx 0.9.0 → 0.10.1
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/android/build.gradle +6 -12
- package/android/src/main/java/com/comnyx/ComnyxPackage.kt +8 -26
- package/android/src/main/java/com/comnyx/src/messaging/firebase/FirebaseMessagingService.kt +5 -1
- package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt +2 -2
- package/lib/commonjs/components/ChatList.js +106 -100
- package/lib/commonjs/components/ChatList.js.map +1 -1
- package/lib/commonjs/components/CustomerForm.js +179 -173
- package/lib/commonjs/components/CustomerForm.js.map +1 -1
- package/lib/commonjs/components/EmptyList.js +7 -5
- package/lib/commonjs/components/EmptyList.js.map +1 -1
- package/lib/commonjs/notifications/initializeNotifications.js +16 -16
- package/lib/commonjs/notifications/initializeNotifications.js.map +1 -1
- package/lib/module/components/ChatList.js +107 -101
- package/lib/module/components/ChatList.js.map +1 -1
- package/lib/module/components/CustomerForm.js +180 -174
- package/lib/module/components/CustomerForm.js.map +1 -1
- package/lib/module/components/EmptyList.js +8 -6
- package/lib/module/components/EmptyList.js.map +1 -1
- package/lib/module/notifications/initializeNotifications.js +16 -16
- package/lib/module/notifications/initializeNotifications.js.map +1 -1
- package/lib/typescript/src/components/ChatList.d.ts.map +1 -1
- package/lib/typescript/src/components/CustomerForm.d.ts.map +1 -1
- package/lib/typescript/src/components/EmptyList.d.ts.map +1 -1
- package/lib/typescript/src/notifications/initializeNotifications.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/ChatList.tsx +123 -110
- package/src/components/CustomerForm.tsx +212 -194
- package/src/components/EmptyList.tsx +10 -3
- package/src/notifications/initializeNotifications.ts +21 -19
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
ScrollView,
|
|
8
8
|
StatusBar,
|
|
9
9
|
ActivityIndicator,
|
|
10
|
+
KeyboardAvoidingView,
|
|
11
|
+
Platform,
|
|
10
12
|
} from 'react-native';
|
|
11
13
|
import { useForm, Controller } from 'react-hook-form';
|
|
12
14
|
import { createCustomer } from '../api';
|
|
@@ -122,218 +124,234 @@ export function CustomerForm({
|
|
|
122
124
|
animated={false}
|
|
123
125
|
translucent
|
|
124
126
|
/>
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
activeOpacity={1}
|
|
127
|
+
<KeyboardAvoidingView
|
|
128
|
+
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
|
129
|
+
style={{ flex: 1 }}
|
|
129
130
|
>
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
<TouchableOpacity
|
|
132
|
+
style={[
|
|
133
|
+
styles.container,
|
|
134
|
+
{ backgroundColor: themeColors.background },
|
|
135
|
+
]}
|
|
136
|
+
onPress={Keyboard.dismiss}
|
|
137
|
+
activeOpacity={1}
|
|
133
138
|
>
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
{ backgroundColor: themeColors.background },
|
|
138
|
-
]}
|
|
139
|
+
<ScrollView
|
|
140
|
+
contentContainerStyle={styles.scrollContainer}
|
|
141
|
+
keyboardShouldPersistTaps="handled"
|
|
139
142
|
>
|
|
140
|
-
<TouchableOpacity
|
|
141
|
-
activeOpacity={1}
|
|
142
|
-
style={[
|
|
143
|
-
styles.iconContainer,
|
|
144
|
-
{ backgroundColor: themeColors.dark_background },
|
|
145
|
-
]}
|
|
146
|
-
onPress={onBack}
|
|
147
|
-
>
|
|
148
|
-
<Image
|
|
149
|
-
source={closeIcon}
|
|
150
|
-
style={[
|
|
151
|
-
styles.closeIcon,
|
|
152
|
-
{ tintColor: themeColors.light_text },
|
|
153
|
-
]}
|
|
154
|
-
/>
|
|
155
|
-
</TouchableOpacity>
|
|
156
143
|
<View
|
|
157
144
|
style={[
|
|
158
|
-
styles.
|
|
159
|
-
{ backgroundColor: themeColors.
|
|
145
|
+
styles.container,
|
|
146
|
+
{ backgroundColor: themeColors.background },
|
|
160
147
|
]}
|
|
161
148
|
>
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
style={[styles.headerText, { color: themeColors.gainsboro }]}
|
|
165
|
-
/>
|
|
166
|
-
<AppText
|
|
167
|
-
localization="customer.form.instructions"
|
|
168
|
-
style={[styles.headerText, { color: themeColors.light_text }]}
|
|
169
|
-
/>
|
|
170
|
-
</View>
|
|
171
|
-
<View style={styles.titleContainer}>
|
|
172
|
-
<AppText
|
|
149
|
+
<TouchableOpacity
|
|
150
|
+
activeOpacity={1}
|
|
173
151
|
style={[
|
|
174
|
-
styles.
|
|
175
|
-
{
|
|
176
|
-
color: themeColors.slate,
|
|
177
|
-
},
|
|
152
|
+
styles.iconContainer,
|
|
153
|
+
{ backgroundColor: themeColors.dark_background },
|
|
178
154
|
]}
|
|
155
|
+
onPress={onBack}
|
|
179
156
|
>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
maxLength: {
|
|
190
|
-
value: 30,
|
|
191
|
-
message: localize(
|
|
192
|
-
'customer.form.validation.name.maxLength'
|
|
193
|
-
),
|
|
194
|
-
},
|
|
195
|
-
}}
|
|
196
|
-
render={({ field: { onChange, value } }) => (
|
|
197
|
-
<View
|
|
198
|
-
style={[
|
|
199
|
-
styles.inputContainer,
|
|
200
|
-
{ borderBottomColor: themeColors.ghost },
|
|
201
|
-
]}
|
|
202
|
-
>
|
|
203
|
-
<TextInput
|
|
204
|
-
style={inputStyle}
|
|
205
|
-
placeholder={localize('customer.form.placeholder.name')}
|
|
206
|
-
placeholderTextColor={themeColors.gainsboro}
|
|
207
|
-
value={value}
|
|
208
|
-
onChangeText={onChange}
|
|
209
|
-
/>
|
|
210
|
-
{errors.name && (
|
|
211
|
-
<InfoButton
|
|
212
|
-
title={'customer.form.failed.name'}
|
|
213
|
-
description={'customer.form.failed.name.desc'}
|
|
214
|
-
/>
|
|
215
|
-
)}
|
|
216
|
-
</View>
|
|
217
|
-
)}
|
|
218
|
-
name="name"
|
|
219
|
-
/>
|
|
220
|
-
<AppText
|
|
157
|
+
<Image
|
|
158
|
+
source={closeIcon}
|
|
159
|
+
style={[
|
|
160
|
+
styles.closeIcon,
|
|
161
|
+
{ tintColor: themeColors.light_text },
|
|
162
|
+
]}
|
|
163
|
+
/>
|
|
164
|
+
</TouchableOpacity>
|
|
165
|
+
<View
|
|
221
166
|
style={[
|
|
222
|
-
styles.
|
|
223
|
-
{
|
|
224
|
-
color: themeColors.slate,
|
|
225
|
-
},
|
|
167
|
+
styles.headerContainer,
|
|
168
|
+
{ backgroundColor: themeColors.dark_background },
|
|
226
169
|
]}
|
|
227
170
|
>
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
171
|
+
<AppText
|
|
172
|
+
localization="customer.form.title"
|
|
173
|
+
style={[styles.headerText, { color: themeColors.gainsboro }]}
|
|
174
|
+
/>
|
|
175
|
+
<AppText
|
|
176
|
+
localization="customer.form.instructions"
|
|
177
|
+
style={[styles.headerText, { color: themeColors.light_text }]}
|
|
178
|
+
/>
|
|
179
|
+
</View>
|
|
180
|
+
<View style={styles.titleContainer}>
|
|
181
|
+
<AppText
|
|
182
|
+
style={[
|
|
183
|
+
styles.title,
|
|
184
|
+
{
|
|
185
|
+
color: themeColors.slate,
|
|
186
|
+
},
|
|
187
|
+
]}
|
|
188
|
+
>
|
|
189
|
+
{localize('customer.form.name')}
|
|
190
|
+
</AppText>
|
|
191
|
+
<Controller
|
|
192
|
+
control={control}
|
|
193
|
+
rules={{
|
|
194
|
+
required: {
|
|
195
|
+
value: true,
|
|
196
|
+
message: localize(
|
|
197
|
+
'customer.form.validation.name.required'
|
|
198
|
+
),
|
|
199
|
+
},
|
|
200
|
+
maxLength: {
|
|
201
|
+
value: 30,
|
|
202
|
+
message: localize(
|
|
203
|
+
'customer.form.validation.name.maxLength'
|
|
204
|
+
),
|
|
205
|
+
},
|
|
206
|
+
}}
|
|
207
|
+
render={({ field: { onChange, value } }) => (
|
|
208
|
+
<View
|
|
209
|
+
style={[
|
|
210
|
+
styles.inputContainer,
|
|
211
|
+
{ borderBottomColor: themeColors.ghost },
|
|
212
|
+
]}
|
|
213
|
+
>
|
|
214
|
+
<TextInput
|
|
215
|
+
style={inputStyle}
|
|
216
|
+
placeholder={localize('customer.form.placeholder.name')}
|
|
217
|
+
placeholderTextColor={themeColors.gainsboro}
|
|
218
|
+
value={value}
|
|
219
|
+
onChangeText={onChange}
|
|
257
220
|
/>
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
221
|
+
{errors.name && (
|
|
222
|
+
<InfoButton
|
|
223
|
+
title={'customer.form.failed.name'}
|
|
224
|
+
description={'customer.form.failed.name.desc'}
|
|
225
|
+
/>
|
|
226
|
+
)}
|
|
227
|
+
</View>
|
|
228
|
+
)}
|
|
229
|
+
name="name"
|
|
230
|
+
/>
|
|
231
|
+
<AppText
|
|
232
|
+
style={[
|
|
233
|
+
styles.title,
|
|
234
|
+
{
|
|
235
|
+
color: themeColors.slate,
|
|
236
|
+
},
|
|
237
|
+
]}
|
|
238
|
+
>
|
|
239
|
+
Email
|
|
240
|
+
</AppText>
|
|
241
|
+
<Controller
|
|
242
|
+
control={control}
|
|
243
|
+
rules={{
|
|
244
|
+
pattern: {
|
|
245
|
+
value: /^\S+@\S+$/i,
|
|
246
|
+
message: localize(
|
|
247
|
+
'customer.form.validation.email.pattern'
|
|
248
|
+
),
|
|
249
|
+
},
|
|
250
|
+
}}
|
|
251
|
+
render={({ field: { onChange, value } }) => (
|
|
252
|
+
<View
|
|
253
|
+
style={[
|
|
254
|
+
styles.inputContainer,
|
|
255
|
+
{ borderBottomColor: themeColors.ghost },
|
|
256
|
+
]}
|
|
257
|
+
>
|
|
258
|
+
<TextInput
|
|
259
|
+
style={inputStyle}
|
|
260
|
+
placeholder={localize(
|
|
261
|
+
'customer.form.placeholder.email'
|
|
262
|
+
)}
|
|
263
|
+
placeholderTextColor={themeColors.gainsboro}
|
|
264
|
+
value={value}
|
|
265
|
+
onChangeText={onChange}
|
|
266
|
+
keyboardType="email-address"
|
|
303
267
|
/>
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
268
|
+
{errors.email && (
|
|
269
|
+
<InfoButton
|
|
270
|
+
title={'customer.form.failed.email'}
|
|
271
|
+
description={'customer.form.failed.email.desc'}
|
|
272
|
+
/>
|
|
273
|
+
)}
|
|
274
|
+
</View>
|
|
275
|
+
)}
|
|
276
|
+
name="email"
|
|
277
|
+
/>
|
|
278
|
+
<AppText
|
|
279
|
+
style={[
|
|
280
|
+
styles.title,
|
|
281
|
+
{
|
|
282
|
+
color: themeColors.slate,
|
|
283
|
+
},
|
|
284
|
+
]}
|
|
285
|
+
>
|
|
286
|
+
Phone
|
|
287
|
+
</AppText>
|
|
288
|
+
<Controller
|
|
289
|
+
control={control}
|
|
290
|
+
rules={{
|
|
291
|
+
validate: (value) => {
|
|
292
|
+
if (!value) return true;
|
|
293
|
+
return (
|
|
294
|
+
typeof value === 'string' ||
|
|
295
|
+
localize('customer.form.validation.phone.invalid')
|
|
296
|
+
);
|
|
297
|
+
},
|
|
298
|
+
}}
|
|
299
|
+
render={({ field: { onChange, value } }) => (
|
|
300
|
+
<View
|
|
301
|
+
style={[
|
|
302
|
+
styles.inputContainer,
|
|
303
|
+
{ borderBottomColor: themeColors.ghost },
|
|
304
|
+
]}
|
|
305
|
+
>
|
|
306
|
+
<TextInput
|
|
307
|
+
style={inputStyle}
|
|
308
|
+
placeholder={localize(
|
|
309
|
+
'customer.form.placeholder.phone'
|
|
310
|
+
)}
|
|
311
|
+
placeholderTextColor={themeColors.gainsboro}
|
|
312
|
+
value={value}
|
|
313
|
+
onChangeText={onChange}
|
|
314
|
+
keyboardType="phone-pad"
|
|
315
|
+
/>
|
|
316
|
+
{errors.phone && (
|
|
317
|
+
<InfoButton
|
|
318
|
+
title={'customer.form.failed.phone'}
|
|
319
|
+
description={'customer.form.failed.phone.desc'}
|
|
320
|
+
/>
|
|
321
|
+
)}
|
|
322
|
+
</View>
|
|
323
|
+
)}
|
|
324
|
+
name="phone"
|
|
325
|
+
/>
|
|
326
|
+
</View>
|
|
309
327
|
</View>
|
|
310
|
-
</
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
328
|
+
</ScrollView>
|
|
329
|
+
<TouchableOpacity
|
|
330
|
+
activeOpacity={activeOpacity}
|
|
331
|
+
style={[
|
|
332
|
+
styles.button,
|
|
333
|
+
{ backgroundColor: themeColors.dark_background },
|
|
334
|
+
]}
|
|
335
|
+
onPress={handleSubmit(onSubmit)}
|
|
336
|
+
>
|
|
337
|
+
<AppText
|
|
338
|
+
localization="customer.form.submit"
|
|
339
|
+
style={[styles.buttonText, { color: themeColors.light_text }]}
|
|
340
|
+
/>
|
|
341
|
+
</TouchableOpacity>
|
|
342
|
+
<CustomPopup
|
|
343
|
+
isVisible={popupVisible}
|
|
344
|
+
onClose={() => setPopupVisible(false)}
|
|
345
|
+
title={popupContent.title}
|
|
346
|
+
description={popupContent.description}
|
|
347
|
+
onCancelButton={() => {
|
|
348
|
+
setPopupVisible(false);
|
|
349
|
+
setPopupContent({ title: '', description: '' });
|
|
350
|
+
}}
|
|
351
|
+
buttonText={'customer.form.cancel' as keyof LocalizationKeys}
|
|
323
352
|
/>
|
|
324
353
|
</TouchableOpacity>
|
|
325
|
-
|
|
326
|
-
isVisible={popupVisible}
|
|
327
|
-
onClose={() => setPopupVisible(false)}
|
|
328
|
-
title={popupContent.title}
|
|
329
|
-
description={popupContent.description}
|
|
330
|
-
onCancelButton={() => {
|
|
331
|
-
setPopupVisible(false);
|
|
332
|
-
setPopupContent({ title: '', description: '' });
|
|
333
|
-
}}
|
|
334
|
-
buttonText={'customer.form.cancel' as keyof LocalizationKeys}
|
|
335
|
-
/>
|
|
336
|
-
</TouchableOpacity>
|
|
354
|
+
</KeyboardAvoidingView>
|
|
337
355
|
</>
|
|
338
356
|
);
|
|
339
357
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { View, Image } from 'react-native';
|
|
1
|
+
import { View, Image, Platform } from 'react-native';
|
|
2
2
|
import { useThemeColors } from '../hooks/useThemeColors';
|
|
3
3
|
import { AppText } from './AppText';
|
|
4
4
|
import type { LocalizationKeys } from '../types/LocalizationKeys';
|
|
@@ -11,7 +11,15 @@ export function EmptyList() {
|
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
13
|
<View
|
|
14
|
-
style={[
|
|
14
|
+
style={[
|
|
15
|
+
styles.container,
|
|
16
|
+
{
|
|
17
|
+
backgroundColor: themeColors.background,
|
|
18
|
+
transform: [
|
|
19
|
+
Platform.OS === 'ios' ? { scaleY: -1 } : { rotate: '180deg' },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
]}
|
|
15
23
|
>
|
|
16
24
|
<Image
|
|
17
25
|
source={notificationIcon}
|
|
@@ -37,7 +45,6 @@ const styles = ScaledSheet.create({
|
|
|
37
45
|
paddingHorizontal: '20@s',
|
|
38
46
|
paddingVertical: '20@vs',
|
|
39
47
|
gap: 15,
|
|
40
|
-
transform: [{ rotate: '180deg' }],
|
|
41
48
|
},
|
|
42
49
|
title: {
|
|
43
50
|
fontSize: '18@vs',
|
|
@@ -60,10 +60,30 @@ function changePermissionStatus(status: NotificationPermissionStatus) {
|
|
|
60
60
|
|
|
61
61
|
async function initializeNativeNotifications() {
|
|
62
62
|
const state = useAppStore.getState();
|
|
63
|
+
//TODO: better event listener. Event listener doesn't work if its set after initialize
|
|
64
|
+
globalSubscriptions.subscriptionsForNotification = [
|
|
65
|
+
ComnyxNotifications.addEventListener('TOKEN_INIT', (data) => {
|
|
66
|
+
if (Platform.OS === 'ios') {
|
|
67
|
+
accumulator.add({
|
|
68
|
+
apnsToken: data.token,
|
|
69
|
+
});
|
|
70
|
+
} else if (Platform.OS === 'android') {
|
|
71
|
+
accumulator.add({
|
|
72
|
+
fcmToken: data.token,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
ComnyxNotifications.addEventListener('TOKEN_FAILED', (data) => {
|
|
77
|
+
//TODO: logger
|
|
78
|
+
console.error('TOKEN_FAILED', data);
|
|
79
|
+
}),
|
|
80
|
+
];
|
|
63
81
|
return await nativeComnyx.initialize().then((res) => {
|
|
64
82
|
state.setNotificationInitialized(true);
|
|
65
83
|
if (res.success) {
|
|
84
|
+
|
|
66
85
|
accumulator.add({
|
|
86
|
+
platform: Platform.OS,
|
|
67
87
|
country: res.country,
|
|
68
88
|
language: res.language, //ComnyxSupport burayı override ediyor!.
|
|
69
89
|
timezone: res.timezone,
|
|
@@ -157,24 +177,6 @@ export async function initializeNotifications(
|
|
|
157
177
|
}
|
|
158
178
|
);
|
|
159
179
|
|
|
160
|
-
|
|
161
|
-
ComnyxNotifications.addEventListener('TOKEN_INIT', (data) => {
|
|
162
|
-
if (Platform.OS === 'ios') {
|
|
163
|
-
accumulator.add({
|
|
164
|
-
apnsToken: data.token,
|
|
165
|
-
platform: 'ios',
|
|
166
|
-
});
|
|
167
|
-
} else if (Platform.OS === 'android') {
|
|
168
|
-
accumulator.add({
|
|
169
|
-
fcmToken: data.token,
|
|
170
|
-
platform: 'android',
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}),
|
|
174
|
-
ComnyxNotifications.addEventListener('TOKEN_FAILED', (data) => {
|
|
175
|
-
//TODO: logger
|
|
176
|
-
console.error('TOKEN_FAILED', data);
|
|
177
|
-
}),
|
|
178
|
-
];
|
|
180
|
+
|
|
179
181
|
return result;
|
|
180
182
|
}
|