@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.
Files changed (29) hide show
  1. package/android/build.gradle +6 -12
  2. package/android/src/main/java/com/comnyx/ComnyxPackage.kt +8 -26
  3. package/android/src/main/java/com/comnyx/src/messaging/firebase/FirebaseMessagingService.kt +5 -1
  4. package/android/src/main/java/com/comnyx/src/messaging/notifications/NotificationsService.kt +2 -2
  5. package/lib/commonjs/components/ChatList.js +106 -100
  6. package/lib/commonjs/components/ChatList.js.map +1 -1
  7. package/lib/commonjs/components/CustomerForm.js +179 -173
  8. package/lib/commonjs/components/CustomerForm.js.map +1 -1
  9. package/lib/commonjs/components/EmptyList.js +7 -5
  10. package/lib/commonjs/components/EmptyList.js.map +1 -1
  11. package/lib/commonjs/notifications/initializeNotifications.js +16 -16
  12. package/lib/commonjs/notifications/initializeNotifications.js.map +1 -1
  13. package/lib/module/components/ChatList.js +107 -101
  14. package/lib/module/components/ChatList.js.map +1 -1
  15. package/lib/module/components/CustomerForm.js +180 -174
  16. package/lib/module/components/CustomerForm.js.map +1 -1
  17. package/lib/module/components/EmptyList.js +8 -6
  18. package/lib/module/components/EmptyList.js.map +1 -1
  19. package/lib/module/notifications/initializeNotifications.js +16 -16
  20. package/lib/module/notifications/initializeNotifications.js.map +1 -1
  21. package/lib/typescript/src/components/ChatList.d.ts.map +1 -1
  22. package/lib/typescript/src/components/CustomerForm.d.ts.map +1 -1
  23. package/lib/typescript/src/components/EmptyList.d.ts.map +1 -1
  24. package/lib/typescript/src/notifications/initializeNotifications.d.ts.map +1 -1
  25. package/package.json +2 -2
  26. package/src/components/ChatList.tsx +123 -110
  27. package/src/components/CustomerForm.tsx +212 -194
  28. package/src/components/EmptyList.tsx +10 -3
  29. 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
- <TouchableOpacity
126
- style={[styles.container, { backgroundColor: themeColors.background }]}
127
- onPress={Keyboard.dismiss}
128
- activeOpacity={1}
127
+ <KeyboardAvoidingView
128
+ behavior={Platform.OS === 'ios' ? 'padding' : undefined}
129
+ style={{ flex: 1 }}
129
130
  >
130
- <ScrollView
131
- contentContainerStyle={styles.scrollContainer}
132
- keyboardShouldPersistTaps="handled"
131
+ <TouchableOpacity
132
+ style={[
133
+ styles.container,
134
+ { backgroundColor: themeColors.background },
135
+ ]}
136
+ onPress={Keyboard.dismiss}
137
+ activeOpacity={1}
133
138
  >
134
- <View
135
- style={[
136
- styles.container,
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.headerContainer,
159
- { backgroundColor: themeColors.dark_background },
145
+ styles.container,
146
+ { backgroundColor: themeColors.background },
160
147
  ]}
161
148
  >
162
- <AppText
163
- localization="customer.form.title"
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.title,
175
- {
176
- color: themeColors.slate,
177
- },
152
+ styles.iconContainer,
153
+ { backgroundColor: themeColors.dark_background },
178
154
  ]}
155
+ onPress={onBack}
179
156
  >
180
- {localize('customer.form.name')}
181
- </AppText>
182
- <Controller
183
- control={control}
184
- rules={{
185
- required: {
186
- value: true,
187
- message: localize('customer.form.validation.name.required'),
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.title,
223
- {
224
- color: themeColors.slate,
225
- },
167
+ styles.headerContainer,
168
+ { backgroundColor: themeColors.dark_background },
226
169
  ]}
227
170
  >
228
- Email
229
- </AppText>
230
- <Controller
231
- control={control}
232
- rules={{
233
- pattern: {
234
- value: /^\S+@\S+$/i,
235
- message: localize('customer.form.validation.email.pattern'),
236
- },
237
- }}
238
- render={({ field: { onChange, value } }) => (
239
- <View
240
- style={[
241
- styles.inputContainer,
242
- { borderBottomColor: themeColors.ghost },
243
- ]}
244
- >
245
- <TextInput
246
- style={inputStyle}
247
- placeholder={localize('customer.form.placeholder.email')}
248
- placeholderTextColor={themeColors.gainsboro}
249
- value={value}
250
- onChangeText={onChange}
251
- keyboardType="email-address"
252
- />
253
- {errors.email && (
254
- <InfoButton
255
- title={'customer.form.failed.email'}
256
- description={'customer.form.failed.email.desc'}
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
- </View>
260
- )}
261
- name="email"
262
- />
263
- <AppText
264
- style={[
265
- styles.title,
266
- {
267
- color: themeColors.slate,
268
- },
269
- ]}
270
- >
271
- Phone
272
- </AppText>
273
- <Controller
274
- control={control}
275
- rules={{
276
- validate: (value) => {
277
- if (!value) return true;
278
- return (
279
- typeof value === 'string' ||
280
- localize('customer.form.validation.phone.invalid')
281
- );
282
- },
283
- }}
284
- render={({ field: { onChange, value } }) => (
285
- <View
286
- style={[
287
- styles.inputContainer,
288
- { borderBottomColor: themeColors.ghost },
289
- ]}
290
- >
291
- <TextInput
292
- style={inputStyle}
293
- placeholder={localize('customer.form.placeholder.phone')}
294
- placeholderTextColor={themeColors.gainsboro}
295
- value={value}
296
- onChangeText={onChange}
297
- keyboardType="phone-pad"
298
- />
299
- {errors.phone && (
300
- <InfoButton
301
- title={'customer.form.failed.phone'}
302
- description={'customer.form.failed.phone.desc'}
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
- </View>
306
- )}
307
- name="phone"
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
- </View>
311
- </ScrollView>
312
- <TouchableOpacity
313
- activeOpacity={activeOpacity}
314
- style={[
315
- styles.button,
316
- { backgroundColor: themeColors.dark_background },
317
- ]}
318
- onPress={handleSubmit(onSubmit)}
319
- >
320
- <AppText
321
- localization="customer.form.submit"
322
- style={[styles.buttonText, { color: themeColors.light_text }]}
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
- <CustomPopup
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={[styles.container, { backgroundColor: themeColors.background }]}
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
- globalSubscriptions.subscriptionsForNotification = [
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
  }