@trycourier/courier-react-native 4.1.0 → 5.0.0
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 +1 -1
- package/android/src/main/java/com/courierreactnative/CourierInboxViewManager.kt +131 -2
- package/android/src/main/java/com/courierreactnative/CourierReactNativeActivity.kt +6 -4
- package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +71 -20
- package/android/src/main/java/com/courierreactnative/ReactNativeModule.kt +1 -2
- package/android/src/main/java/com/courierreactnative/Utils.kt +37 -144
- package/courier-react-native.podspec +1 -1
- package/ios/CourierInboxReactNativeManager.m +2 -0
- package/ios/CourierInboxReactNativeManager.swift +165 -0
- package/ios/CourierReactNativeDelegate.m +1 -1
- package/ios/CourierReactNativeEventEmitter.swift +1 -1
- package/ios/CourierReactNativeModule.m +9 -2
- package/ios/CourierSharedModule.swift +121 -50
- package/ios/Utils.swift +1 -2
- package/lib/commonjs/Modules.js +5 -0
- package/lib/commonjs/Modules.js.map +1 -1
- package/lib/commonjs/index.js +84 -22
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
- package/lib/commonjs/models/InboxMessageFeed.js +2 -0
- package/lib/commonjs/models/InboxMessageFeed.js.map +1 -0
- package/lib/commonjs/views/CourierInboxView.js +3 -8
- package/lib/commonjs/views/CourierInboxView.js.map +1 -1
- package/lib/commonjs/views/CourierPreferencesView.js +2 -8
- package/lib/commonjs/views/CourierPreferencesView.js.map +1 -1
- package/lib/module/Modules.js +6 -1
- package/lib/module/Modules.js.map +1 -1
- package/lib/module/index.js +84 -22
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js.map +1 -1
- package/lib/module/models/InboxMessageFeed.js +2 -0
- package/lib/module/models/InboxMessageFeed.js.map +1 -0
- package/lib/module/views/CourierInboxView.js +4 -9
- package/lib/module/views/CourierInboxView.js.map +1 -1
- package/lib/module/views/CourierPreferencesView.js +3 -9
- package/lib/module/views/CourierPreferencesView.js.map +1 -1
- package/lib/typescript/src/Modules.d.ts +1 -0
- package/lib/typescript/src/Modules.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +20 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierInboxListener.d.ts +7 -0
- package/lib/typescript/src/models/CourierInboxListener.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierInboxTheme.d.ts +27 -0
- package/lib/typescript/src/models/CourierInboxTheme.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessageFeed.d.ts +2 -0
- package/lib/typescript/src/models/InboxMessageFeed.d.ts.map +1 -0
- package/lib/typescript/src/views/CourierInboxView.d.ts +1 -0
- package/lib/typescript/src/views/CourierInboxView.d.ts.map +1 -1
- package/lib/typescript/src/views/CourierPreferencesView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Modules.tsx +9 -1
- package/src/index.tsx +100 -27
- package/src/models/CourierInboxListener.tsx +8 -1
- package/src/models/CourierInboxTheme.tsx +33 -0
- package/src/models/InboxMessageFeed.tsx +1 -0
- package/src/views/CourierInboxView.tsx +5 -15
- package/src/views/CourierPreferencesView.tsx +3 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","DeviceEventEmitter","Platform","
|
|
1
|
+
{"version":3,"names":["React","useEffect","DeviceEventEmitter","Platform","Modules","CourierPreferences","getNativeComponent","CourierPreferencesView","props","onScrollPreferencesListener","undefined","_onScrollPreferencesL","remove","_onScrollPreferencesL2","OS","onScrollPreferences","addListener","event","contentOffset","onPreferenceError","message","createElement","mode","theme","light","dark","nativeEvent","style"],"sourceRoot":"../../../src","sources":["views/CourierPreferencesView.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,kBAAkB,EAAuBC,QAAQ,QAAmB,cAAc;AAE3F,SAASC,OAAO,QAAQ,YAAY;AAapC,MAAMC,kBAAkB,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IAAK;IACjBC,KAAK,EAAEf,KAAK,CAACe,KAAK,IAAI;MAAEC,KAAK,EAAEd,SAAS;MAAEe,IAAI,EAAEf;IAAU,CAAE;IAC5DK,mBAAmB,EAAGE,KAAU,IAAKF,mBAAmB,CAACE,KAAK,CAACS,WAAW,CAAE;IAC5EP,iBAAiB,EAAGF,KAAU,IAAKE,iBAAiB,CAACF,KAAK,CAACS,WAAW,CAAE;IACxEC,KAAK,EAAEnB,KAAK,CAACmB;EAAM,CACpB,CAAC;AAGN,CAAC","ignoreList":[]}
|
|
@@ -4,5 +4,6 @@ export declare class Modules {
|
|
|
4
4
|
static readonly Shared: any;
|
|
5
5
|
static readonly System: any;
|
|
6
6
|
static getNativeModule<T>(nativeModule: T | undefined): T;
|
|
7
|
+
static getNativeComponent(componentName: string): import("react-native").HostComponent<any> | (() => never);
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=Modules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modules.d.ts","sourceRoot":"","sources":["../../../src/Modules.tsx"],"names":[],"mappings":"AAEA,qBAAa,OAAO;IAElB,MAAM,CAAC,QAAQ,CAAC,aAAa,SAIG;IAEhC,MAAM,CAAC,QAAQ,CAAC,MAAM,MAA8D;IACpF,MAAM,CAAC,QAAQ,CAAC,MAAM,MAA8D;IACpF,MAAM,CAAC,QAAQ,CAAC,MAAM,MAA8D;IAEpF,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"Modules.d.ts","sourceRoot":"","sources":["../../../src/Modules.tsx"],"names":[],"mappings":"AAEA,qBAAa,OAAO;IAElB,MAAM,CAAC,QAAQ,CAAC,aAAa,SAIG;IAEhC,MAAM,CAAC,QAAQ,CAAC,MAAM,MAA8D;IACpF,MAAM,CAAC,QAAQ,CAAC,MAAM,MAA8D;IACpF,MAAM,CAAC,QAAQ,CAAC,MAAM,MAA8D;IAEpF,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC;IAazD,MAAM,CAAC,kBAAkB,CAAC,aAAa,EAAE,MAAM;CAQhD"}
|
|
@@ -4,6 +4,7 @@ import { CourierAuthenticationListener } from './models/CourierAuthenticationLis
|
|
|
4
4
|
import { InboxMessage } from './models/InboxMessage';
|
|
5
5
|
import { CourierPushProvider } from './models/CourierPushProvider';
|
|
6
6
|
import { CourierClient } from './client/CourierClient';
|
|
7
|
+
import { InboxMessageFeed } from './models/InboxMessageFeed';
|
|
7
8
|
export { CourierClient } from './client/CourierClient';
|
|
8
9
|
export { BrandClient } from './client/BrandClient';
|
|
9
10
|
export { CourierBrandResponse } from './models/CourierBrand';
|
|
@@ -263,14 +264,28 @@ declare class Courier {
|
|
|
263
264
|
* @param {Object} props - The properties object.
|
|
264
265
|
* @param {Function} [props.onInitialLoad] - Callback function called when the inbox is initially loaded.
|
|
265
266
|
* @param {Function} [props.onError] - Callback function called when an error occurs. Receives the error message as a parameter.
|
|
266
|
-
* @param {Function} [props.
|
|
267
|
+
* @param {Function} [props.onUnreadCountChanged] - Callback function called when the unread count changes.
|
|
268
|
+
* @param {Function} [props.onFeedChanged] - Callback function called when the feed changes.
|
|
269
|
+
* @param {Function} [props.onArchiveChanged] - Callback function called when the archive changes.
|
|
270
|
+
* @param {Function} [props.onPageAdded] - Callback function called when a new page is added.
|
|
271
|
+
* @param {Function} [props.onMessageChanged] - Callback function called when a message changes.
|
|
272
|
+
* @param {Function} [props.onMessageAdded] - Callback function called when a new message is added.
|
|
273
|
+
* @param {Function} [props.onMessageRemoved] - Callback function called when a message is removed.
|
|
267
274
|
* @returns {CourierInboxListener} A listener object that can be used to remove the listener later.
|
|
268
275
|
*/
|
|
269
276
|
addInboxListener(props: {
|
|
270
277
|
onInitialLoad?: () => void;
|
|
271
278
|
onError?: (error: string) => void;
|
|
272
|
-
|
|
279
|
+
onUnreadCountChanged?: (unreadCount: number) => void;
|
|
280
|
+
onFeedChanged?: (messages: InboxMessage[], totalMessageCount: number, canPaginate: boolean) => void;
|
|
281
|
+
onArchiveChanged?: (messages: InboxMessage[], totalMessageCount: number, canPaginate: boolean) => void;
|
|
282
|
+
onPageAdded?: (feed: InboxMessageFeed, messages: InboxMessage[], totalMessageCount: number, canPaginate: boolean) => void;
|
|
283
|
+
onMessageChanged?: (feed: InboxMessageFeed, index: number, message: InboxMessage) => void;
|
|
284
|
+
onMessageAdded?: (feed: InboxMessageFeed, index: number, message: InboxMessage) => void;
|
|
285
|
+
onMessageRemoved?: (feed: InboxMessageFeed, index: number, message: InboxMessage) => void;
|
|
273
286
|
}): CourierInboxListener;
|
|
287
|
+
private convertMessages;
|
|
288
|
+
private convertMessage;
|
|
274
289
|
/**
|
|
275
290
|
* Removes a specific inbox listener.
|
|
276
291
|
* @param {Object} props - The properties object.
|
|
@@ -294,7 +309,9 @@ declare class Courier {
|
|
|
294
309
|
* Fetches the next page of inbox messages.
|
|
295
310
|
* @returns {Promise<InboxMessage[]>} A promise that resolves with an array of fetched inbox messages.
|
|
296
311
|
*/
|
|
297
|
-
fetchNextPageOfMessages(
|
|
312
|
+
fetchNextPageOfMessages(props: {
|
|
313
|
+
inboxMessageFeed: InboxMessageFeed;
|
|
314
|
+
}): Promise<InboxMessage[]>;
|
|
298
315
|
}
|
|
299
316
|
export default Courier;
|
|
300
317
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,mB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,MAAM,CAAA;KAAE,GAAG,MAAM;IA6BjE;;OAEG;IACI,uBAAuB;IAqB9B;;;;OAIG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C;;;OAGG;IACU,uBAAuB,CAAC,KAAK,EAAE;QAAE,gBAAgB,EAAE,gBAAgB,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAK7G;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -4,6 +4,13 @@ export declare class CourierInboxListener {
|
|
|
4
4
|
onInitialLoad?: EmitterSubscription;
|
|
5
5
|
onError?: EmitterSubscription;
|
|
6
6
|
onMessagesChanged?: EmitterSubscription;
|
|
7
|
+
onUnreadCountChanged?: EmitterSubscription;
|
|
8
|
+
onFeedChanged?: EmitterSubscription;
|
|
9
|
+
onArchiveChanged?: EmitterSubscription;
|
|
10
|
+
onPageAdded?: EmitterSubscription;
|
|
11
|
+
onMessageChanged?: EmitterSubscription;
|
|
12
|
+
onMessageAdded?: EmitterSubscription;
|
|
13
|
+
onMessageRemoved?: EmitterSubscription;
|
|
7
14
|
constructor(id: string);
|
|
8
15
|
remove(): void;
|
|
9
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CourierInboxListener.d.ts","sourceRoot":"","sources":["../../../../src/models/CourierInboxListener.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,qBAAa,oBAAoB;IAE/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,OAAO,CAAC,EAAE,mBAAmB,CAAA;IAC7B,iBAAiB,CAAC,EAAE,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"CourierInboxListener.d.ts","sourceRoot":"","sources":["../../../../src/models/CourierInboxListener.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD,qBAAa,oBAAoB;IAE/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,OAAO,CAAC,EAAE,mBAAmB,CAAA;IAC7B,iBAAiB,CAAC,EAAE,mBAAmB,CAAA;IACvC,oBAAoB,CAAC,EAAE,mBAAmB,CAAA;IAC1C,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,gBAAgB,CAAC,EAAE,mBAAmB,CAAA;IACtC,WAAW,CAAC,EAAE,mBAAmB,CAAA;IACjC,gBAAgB,CAAC,EAAE,mBAAmB,CAAA;IACtC,cAAc,CAAC,EAAE,mBAAmB,CAAA;IACpC,gBAAgB,CAAC,EAAE,mBAAmB,CAAA;gBAEjC,EAAE,EAAE,MAAM;IAIf,MAAM;CAId"}
|
|
@@ -13,8 +13,35 @@ export interface CourierInboxUnreadIndicatorStyle {
|
|
|
13
13
|
indicator?: 'dot' | 'line';
|
|
14
14
|
color?: string;
|
|
15
15
|
}
|
|
16
|
+
export interface CourierInboxTabIndicatorStyle {
|
|
17
|
+
font?: CourierFont;
|
|
18
|
+
color?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CourierInboxTabItemStyle {
|
|
21
|
+
font?: CourierFont;
|
|
22
|
+
indicator?: CourierInboxTabIndicatorStyle;
|
|
23
|
+
}
|
|
24
|
+
export interface CourierInboxTabStyle {
|
|
25
|
+
selected?: CourierInboxTabItemStyle;
|
|
26
|
+
unselected?: CourierInboxTabItemStyle;
|
|
27
|
+
}
|
|
28
|
+
export interface CourierSwipeActionStyle {
|
|
29
|
+
icon?: string;
|
|
30
|
+
color?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface CourierReadingSwipeActionStyle {
|
|
33
|
+
read?: CourierSwipeActionStyle;
|
|
34
|
+
unread?: CourierSwipeActionStyle;
|
|
35
|
+
}
|
|
36
|
+
export interface CourierArchivingSwipeActionStyle {
|
|
37
|
+
archive?: CourierSwipeActionStyle;
|
|
38
|
+
}
|
|
16
39
|
export interface CourierInboxTheme {
|
|
17
40
|
brandId?: string;
|
|
41
|
+
tabIndicatorColor?: string;
|
|
42
|
+
tabStyle?: CourierInboxTabStyle;
|
|
43
|
+
readingSwipeActionStyle?: CourierReadingSwipeActionStyle;
|
|
44
|
+
archivingSwipeActionStyle?: CourierArchivingSwipeActionStyle;
|
|
18
45
|
loadingIndicatorColor?: string;
|
|
19
46
|
unreadIndicatorStyle?: CourierInboxUnreadIndicatorStyle;
|
|
20
47
|
titleStyle?: CourierInboxTextStyle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CourierInboxTheme.d.ts","sourceRoot":"","sources":["../../../../src/models/CourierInboxTheme.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,IAAI,CAAC,EAAE,aAAa,CAAA;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,IAAI,CAAC,EAAE,WAAW,CAAA;CACnB;AAED,MAAM,WAAW,gCAAgC;IAC/C,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,oBAAoB,CAAC,EAAE,gCAAgC,CAAA;IACvD,UAAU,CAAC,EAAE,qBAAqB,CAAA;IAClC,SAAS,CAAC,EAAE,qBAAqB,CAAA;IACjC,SAAS,CAAC,EAAE,qBAAqB,CAAA;IACjC,WAAW,CAAC,EAAE,uBAAuB,CAA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AAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC;QACvG,UAAU,CAAC,EAAE;YACX,cAAc,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,kBAAkB,CAAC;YAC5D,eAAe,CAAC,EAAE;gBAAE,GAAG,CAAC,EAAE,MAAM,CAAC;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YACnF,cAAc,CAAC,EAAE,MAAM,CAAC;YACxB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;SACvD,CAAA;KACF,CAAC;IACF,OAAO,CAAC,EAAE;QACR,qBAAqB,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;KAC7C,CAAA;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InboxMessageFeed.d.ts","sourceRoot":"","sources":["../../../../src/models/InboxMessageFeed.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,UAAU,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { InboxAction } from "../models/InboxAction";
|
|
|
4
4
|
import { InboxMessage } from "../models/InboxMessage";
|
|
5
5
|
import { CourierInboxTheme } from "src/models/CourierInboxTheme";
|
|
6
6
|
type CourierInboxViewProps = {
|
|
7
|
+
canSwipePages?: boolean;
|
|
7
8
|
theme?: {
|
|
8
9
|
light?: CourierInboxTheme;
|
|
9
10
|
dark?: CourierInboxTheme;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CourierInboxView.d.ts","sourceRoot":"","sources":["../../../../src/views/CourierInboxView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"CourierInboxView.d.ts","sourceRoot":"","sources":["../../../../src/views/CourierInboxView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAY,SAAS,EAA2C,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,KAAK,qBAAqB,GAAG;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE;QACN,KAAK,CAAC,EAAE,iBAAiB,CAAC;QAC1B,IAAI,CAAC,EAAE,iBAAiB,CAAA;KACzB,CAAC;IACF,0BAA0B,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5E,mCAAmC,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1G,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAIF,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,sBAkG5D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CourierPreferencesView.d.ts","sourceRoot":"","sources":["../../../../src/views/CourierPreferencesView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"CourierPreferencesView.d.ts","sourceRoot":"","sources":["../../../../src/views/CourierPreferencesView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAqD,SAAS,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAGrG,KAAK,uBAAuB,GAAG;IAC7B,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,KAAK,CAAC,EAAE;QACN,KAAK,CAAC,EAAE,uBAAuB,CAAC;QAChC,IAAI,CAAC,EAAE,uBAAuB,CAAA;KAC/B,CAAC;IACF,mBAAmB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAIF,eAAO,MAAM,sBAAsB,UAAW,uBAAuB,sBAwDpE,CAAA"}
|
package/package.json
CHANGED
package/src/Modules.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NativeModules, Platform } from "react-native";
|
|
1
|
+
import { NativeModules, Platform, UIManager, requireNativeComponent } from "react-native";
|
|
2
2
|
|
|
3
3
|
export class Modules {
|
|
4
4
|
|
|
@@ -25,4 +25,12 @@ export class Modules {
|
|
|
25
25
|
) as T;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
static getNativeComponent(componentName: string) {
|
|
29
|
+
return UIManager.getViewManagerConfig(componentName) != null
|
|
30
|
+
? requireNativeComponent<any>(componentName)
|
|
31
|
+
: () => {
|
|
32
|
+
throw new Error(Modules.LINKING_ERROR);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
}
|
package/src/index.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { Modules } from './Modules';
|
|
|
13
13
|
import Broadcaster from './Broadcaster';
|
|
14
14
|
import { CourierClient } from './client/CourierClient';
|
|
15
15
|
import { Events, Utils } from './utils';
|
|
16
|
+
import { InboxMessageFeed } from './models/InboxMessageFeed';
|
|
16
17
|
|
|
17
18
|
export { CourierClient } from './client/CourierClient';
|
|
18
19
|
export { BrandClient } from './client/BrandClient';
|
|
@@ -506,22 +507,50 @@ class Courier {
|
|
|
506
507
|
* @param {Object} props - The properties object.
|
|
507
508
|
* @param {Function} [props.onInitialLoad] - Callback function called when the inbox is initially loaded.
|
|
508
509
|
* @param {Function} [props.onError] - Callback function called when an error occurs. Receives the error message as a parameter.
|
|
509
|
-
* @param {Function} [props.
|
|
510
|
+
* @param {Function} [props.onUnreadCountChanged] - Callback function called when the unread count changes.
|
|
511
|
+
* @param {Function} [props.onFeedChanged] - Callback function called when the feed changes.
|
|
512
|
+
* @param {Function} [props.onArchiveChanged] - Callback function called when the archive changes.
|
|
513
|
+
* @param {Function} [props.onPageAdded] - Callback function called when a new page is added.
|
|
514
|
+
* @param {Function} [props.onMessageChanged] - Callback function called when a message changes.
|
|
515
|
+
* @param {Function} [props.onMessageAdded] - Callback function called when a new message is added.
|
|
516
|
+
* @param {Function} [props.onMessageRemoved] - Callback function called when a message is removed.
|
|
510
517
|
* @returns {CourierInboxListener} A listener object that can be used to remove the listener later.
|
|
511
518
|
*/
|
|
512
|
-
public addInboxListener(props: {
|
|
519
|
+
public addInboxListener(props: {
|
|
520
|
+
onInitialLoad?: () => void,
|
|
521
|
+
onError?: (error: string) => void,
|
|
522
|
+
onUnreadCountChanged?: (unreadCount: number) => void,
|
|
523
|
+
onFeedChanged?: (messages: InboxMessage[], totalMessageCount: number, canPaginate: boolean) => void,
|
|
524
|
+
onArchiveChanged?: (messages: InboxMessage[], totalMessageCount: number, canPaginate: boolean) => void,
|
|
525
|
+
onPageAdded?: (feed: InboxMessageFeed, messages: InboxMessage[], totalMessageCount: number, canPaginate: boolean) => void,
|
|
526
|
+
onMessageChanged?: (feed: InboxMessageFeed, index: number, message: InboxMessage) => void,
|
|
527
|
+
onMessageAdded?: (feed: InboxMessageFeed, index: number, message: InboxMessage) => void,
|
|
528
|
+
onMessageRemoved?: (feed: InboxMessageFeed, index: number, message: InboxMessage) => void
|
|
529
|
+
}): CourierInboxListener {
|
|
513
530
|
|
|
514
531
|
const listenerIds = {
|
|
515
532
|
loading: `inbox_loading_${Utils.generateUUID()}`,
|
|
516
533
|
error: `inbox_error_${Utils.generateUUID()}`,
|
|
517
|
-
|
|
534
|
+
unreadCount: `inbox_unread_count_${Utils.generateUUID()}`,
|
|
535
|
+
feed: `inbox_feed_${Utils.generateUUID()}`,
|
|
536
|
+
archive: `inbox_archive_${Utils.generateUUID()}`,
|
|
537
|
+
pageAdded: `inbox_page_added_${Utils.generateUUID()}`,
|
|
538
|
+
messageChanged: `inbox_message_changed_${Utils.generateUUID()}`,
|
|
539
|
+
messageAdded: `inbox_message_added_${Utils.generateUUID()}`,
|
|
540
|
+
messageRemoved: `inbox_message_removed_${Utils.generateUUID()}`
|
|
518
541
|
}
|
|
519
542
|
|
|
520
543
|
// Set the listener id
|
|
521
544
|
const id = Modules.Shared.addInboxListener(
|
|
522
545
|
listenerIds.loading,
|
|
523
546
|
listenerIds.error,
|
|
524
|
-
listenerIds.
|
|
547
|
+
listenerIds.unreadCount,
|
|
548
|
+
listenerIds.feed,
|
|
549
|
+
listenerIds.archive,
|
|
550
|
+
listenerIds.pageAdded,
|
|
551
|
+
listenerIds.messageChanged,
|
|
552
|
+
listenerIds.messageAdded,
|
|
553
|
+
listenerIds.messageRemoved
|
|
525
554
|
);
|
|
526
555
|
|
|
527
556
|
// Create the initial listeners
|
|
@@ -535,32 +564,64 @@ class Courier {
|
|
|
535
564
|
props.onError?.(event);
|
|
536
565
|
});
|
|
537
566
|
|
|
538
|
-
listener.
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
567
|
+
listener.onUnreadCountChanged = this.sharedBroadcaster.addListener(listenerIds.unreadCount, (event: any) => {
|
|
568
|
+
props.onUnreadCountChanged?.(event);
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
listener.onFeedChanged = this.sharedBroadcaster.addListener(listenerIds.feed, (event: any) => {
|
|
572
|
+
const convertedMessages = this.convertMessages(event.messages);
|
|
573
|
+
props.onFeedChanged?.(convertedMessages, event.totalMessageCount, event.canPaginate);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
listener.onArchiveChanged = this.sharedBroadcaster.addListener(listenerIds.archive, (event: any) => {
|
|
577
|
+
const convertedMessages = this.convertMessages(event.messages);
|
|
578
|
+
props.onArchiveChanged?.(convertedMessages, event.totalMessageCount, event.canPaginate);
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
listener.onPageAdded = this.sharedBroadcaster.addListener(listenerIds.pageAdded, (event: any) => {
|
|
582
|
+
const convertedMessages = this.convertMessages(event.messages);
|
|
583
|
+
props.onPageAdded?.(event.feed === 'archived' ? 'archived' : 'feed', convertedMessages, event.totalMessageCount, event.canPaginate);
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
listener.onMessageChanged = this.sharedBroadcaster.addListener(listenerIds.messageChanged, (event: any) => {
|
|
587
|
+
const convertedMessage = this.convertMessage(event.message);
|
|
588
|
+
props.onMessageChanged?.(event.feed === 'archived' ? 'archived' : 'feed', event.index, convertedMessage);
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
listener.onMessageAdded = this.sharedBroadcaster.addListener(listenerIds.messageAdded, (event: any) => {
|
|
592
|
+
const convertedMessage = this.convertMessage(event.message);
|
|
593
|
+
props.onMessageAdded?.(event.feed === 'archived' ? 'archived' : 'feed', event.index, convertedMessage);
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
listener.onMessageRemoved = this.sharedBroadcaster.addListener(listenerIds.messageRemoved, (event: any) => {
|
|
597
|
+
const convertedMessage = this.convertMessage(event.message);
|
|
598
|
+
props.onMessageRemoved?.(event.feed === 'archived' ? 'archived' : 'feed', event.index, convertedMessage);
|
|
557
599
|
});
|
|
558
600
|
|
|
559
601
|
// Add listener to manager
|
|
560
602
|
this.inboxListeners.set(id, listener);
|
|
561
603
|
|
|
562
604
|
return listener;
|
|
605
|
+
}
|
|
563
606
|
|
|
607
|
+
private convertMessages(messages: string[]): InboxMessage[] {
|
|
608
|
+
return messages.map(jsonString => {
|
|
609
|
+
try {
|
|
610
|
+
return JSON.parse(jsonString) as InboxMessage;
|
|
611
|
+
} catch (error) {
|
|
612
|
+
Courier.log(`Error parsing message: ${error}`);
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
}).filter((message): message is InboxMessage => message !== null);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
private convertMessage(message: string): InboxMessage {
|
|
619
|
+
try {
|
|
620
|
+
return JSON.parse(message) as InboxMessage;
|
|
621
|
+
} catch (error) {
|
|
622
|
+
Courier.log(`Error parsing message: ${error}`);
|
|
623
|
+
throw error;
|
|
624
|
+
}
|
|
564
625
|
}
|
|
565
626
|
|
|
566
627
|
/**
|
|
@@ -581,7 +642,13 @@ class Courier {
|
|
|
581
642
|
const listener = this.inboxListeners.get(props.listenerId);
|
|
582
643
|
listener?.onInitialLoad?.remove();
|
|
583
644
|
listener?.onError?.remove();
|
|
584
|
-
listener?.
|
|
645
|
+
listener?.onUnreadCountChanged?.remove();
|
|
646
|
+
listener?.onFeedChanged?.remove();
|
|
647
|
+
listener?.onArchiveChanged?.remove();
|
|
648
|
+
listener?.onPageAdded?.remove();
|
|
649
|
+
listener?.onMessageChanged?.remove();
|
|
650
|
+
listener?.onMessageAdded?.remove();
|
|
651
|
+
listener?.onMessageRemoved?.remove();
|
|
585
652
|
|
|
586
653
|
// Remove the listener
|
|
587
654
|
this.inboxListeners.delete(props.listenerId);
|
|
@@ -604,7 +671,13 @@ class Courier {
|
|
|
604
671
|
this.inboxListeners.forEach((listener) => {
|
|
605
672
|
listener?.onInitialLoad?.remove();
|
|
606
673
|
listener?.onError?.remove();
|
|
607
|
-
listener?.
|
|
674
|
+
listener?.onUnreadCountChanged?.remove();
|
|
675
|
+
listener?.onFeedChanged?.remove();
|
|
676
|
+
listener?.onArchiveChanged?.remove();
|
|
677
|
+
listener?.onPageAdded?.remove();
|
|
678
|
+
listener?.onMessageChanged?.remove();
|
|
679
|
+
listener?.onMessageAdded?.remove();
|
|
680
|
+
listener?.onMessageRemoved?.remove();
|
|
608
681
|
});
|
|
609
682
|
this.inboxListeners.clear();
|
|
610
683
|
|
|
@@ -623,8 +696,8 @@ class Courier {
|
|
|
623
696
|
* Fetches the next page of inbox messages.
|
|
624
697
|
* @returns {Promise<InboxMessage[]>} A promise that resolves with an array of fetched inbox messages.
|
|
625
698
|
*/
|
|
626
|
-
public async fetchNextPageOfMessages(): Promise<InboxMessage[]> {
|
|
627
|
-
const messages = await Modules.Shared.fetchNextPageOfMessages();
|
|
699
|
+
public async fetchNextPageOfMessages(props: { inboxMessageFeed: InboxMessageFeed }): Promise<InboxMessage[]> {
|
|
700
|
+
const messages = await Modules.Shared.fetchNextPageOfMessages(props.inboxMessageFeed);
|
|
628
701
|
return messages.map((message: string) => JSON.parse(message));
|
|
629
702
|
}
|
|
630
703
|
|
|
@@ -7,7 +7,14 @@ export class CourierInboxListener {
|
|
|
7
7
|
public onInitialLoad?: EmitterSubscription
|
|
8
8
|
public onError?: EmitterSubscription
|
|
9
9
|
public onMessagesChanged?: EmitterSubscription
|
|
10
|
-
|
|
10
|
+
public onUnreadCountChanged?: EmitterSubscription
|
|
11
|
+
public onFeedChanged?: EmitterSubscription
|
|
12
|
+
public onArchiveChanged?: EmitterSubscription
|
|
13
|
+
public onPageAdded?: EmitterSubscription
|
|
14
|
+
public onMessageChanged?: EmitterSubscription
|
|
15
|
+
public onMessageAdded?: EmitterSubscription
|
|
16
|
+
public onMessageRemoved?: EmitterSubscription
|
|
17
|
+
|
|
11
18
|
constructor(id: string) {
|
|
12
19
|
this.listenerId = id;
|
|
13
20
|
}
|
|
@@ -17,8 +17,41 @@ export interface CourierInboxUnreadIndicatorStyle {
|
|
|
17
17
|
color?: string
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export interface CourierInboxTabIndicatorStyle {
|
|
21
|
+
font?: CourierFont
|
|
22
|
+
color?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface CourierInboxTabItemStyle {
|
|
26
|
+
font?: CourierFont
|
|
27
|
+
indicator?: CourierInboxTabIndicatorStyle
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CourierInboxTabStyle {
|
|
31
|
+
selected?: CourierInboxTabItemStyle
|
|
32
|
+
unselected?: CourierInboxTabItemStyle
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CourierSwipeActionStyle {
|
|
36
|
+
icon?: string
|
|
37
|
+
color?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface CourierReadingSwipeActionStyle {
|
|
41
|
+
read?: CourierSwipeActionStyle
|
|
42
|
+
unread?: CourierSwipeActionStyle
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface CourierArchivingSwipeActionStyle {
|
|
46
|
+
archive?: CourierSwipeActionStyle
|
|
47
|
+
}
|
|
48
|
+
|
|
20
49
|
export interface CourierInboxTheme {
|
|
21
50
|
brandId?: string,
|
|
51
|
+
tabIndicatorColor?: string,
|
|
52
|
+
tabStyle?: CourierInboxTabStyle,
|
|
53
|
+
readingSwipeActionStyle?: CourierReadingSwipeActionStyle
|
|
54
|
+
archivingSwipeActionStyle?: CourierArchivingSwipeActionStyle
|
|
22
55
|
loadingIndicatorColor?: string
|
|
23
56
|
unreadIndicatorStyle?: CourierInboxUnreadIndicatorStyle
|
|
24
57
|
titleStyle?: CourierInboxTextStyle
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type InboxMessageFeed = 'feed' | 'archived';
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
|
-
import { Platform,
|
|
2
|
+
import { Platform, ViewStyle, DeviceEventEmitter, EmitterSubscription } from "react-native";
|
|
3
3
|
import { InboxAction } from "../models/InboxAction";
|
|
4
4
|
import { InboxMessage } from "../models/InboxMessage";
|
|
5
5
|
import { CourierInboxTheme } from "src/models/CourierInboxTheme";
|
|
6
|
+
import { Modules } from "../Modules";
|
|
6
7
|
|
|
7
8
|
type CourierInboxViewProps = {
|
|
9
|
+
canSwipePages?: boolean,
|
|
8
10
|
theme?: {
|
|
9
11
|
light?: CourierInboxTheme,
|
|
10
12
|
dark?: CourierInboxTheme
|
|
@@ -15,20 +17,7 @@ type CourierInboxViewProps = {
|
|
|
15
17
|
style?: ViewStyle;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const LINKING_ERROR =
|
|
21
|
-
`The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
22
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
23
|
-
'- You rebuilt the app after installing the package\n' +
|
|
24
|
-
'- You are not using Expo Go\n';
|
|
25
|
-
|
|
26
|
-
const CourierInbox =
|
|
27
|
-
UIManager.getViewManagerConfig(ComponentName) != null
|
|
28
|
-
? requireNativeComponent<CourierInboxViewProps>(ComponentName)
|
|
29
|
-
: () => {
|
|
30
|
-
throw new Error(LINKING_ERROR);
|
|
31
|
-
};
|
|
20
|
+
const CourierInbox = Modules.getNativeComponent('CourierInboxView');
|
|
32
21
|
|
|
33
22
|
export const CourierInboxView = (props: CourierInboxViewProps) => {
|
|
34
23
|
|
|
@@ -119,6 +108,7 @@ export const CourierInboxView = (props: CourierInboxViewProps) => {
|
|
|
119
108
|
|
|
120
109
|
return (
|
|
121
110
|
<CourierInbox
|
|
111
|
+
canSwipePages={props.canSwipePages ?? false}
|
|
122
112
|
theme={props.theme ?? { light: undefined, dark: undefined }}
|
|
123
113
|
onClickInboxMessageAtIndex={(event: any) => onClickInboxMessageAtIndex(event.nativeEvent)}
|
|
124
114
|
onClickInboxActionForMessageAtIndex={(event: any) => onClickInboxActionForMessageAtIndex(event.nativeEvent)}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
|
-
import { DeviceEventEmitter, EmitterSubscription, Platform,
|
|
2
|
+
import { DeviceEventEmitter, EmitterSubscription, Platform, ViewStyle } from "react-native";
|
|
3
3
|
import { CourierPreferencesMode, CourierPreferencesTheme } from "src/models/CourierPreferencesTheme";
|
|
4
|
+
import { Modules } from "../Modules";
|
|
4
5
|
|
|
5
6
|
type CourierPreferencesProps = {
|
|
6
7
|
mode?: CourierPreferencesMode,
|
|
@@ -13,20 +14,7 @@ type CourierPreferencesProps = {
|
|
|
13
14
|
style?: ViewStyle;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const LINKING_ERROR =
|
|
19
|
-
`The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
20
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
21
|
-
'- You rebuilt the app after installing the package\n' +
|
|
22
|
-
'- You are not using Expo Go\n';
|
|
23
|
-
|
|
24
|
-
const CourierPreferences =
|
|
25
|
-
UIManager.getViewManagerConfig(ComponentName) != null
|
|
26
|
-
? requireNativeComponent<CourierPreferencesProps>(ComponentName)
|
|
27
|
-
: () => {
|
|
28
|
-
throw new Error(LINKING_ERROR);
|
|
29
|
-
};
|
|
17
|
+
const CourierPreferences = Modules.getNativeComponent('CourierPreferencesView');
|
|
30
18
|
|
|
31
19
|
export const CourierPreferencesView = (props: CourierPreferencesProps) => {
|
|
32
20
|
|