@trycourier/courier-react-native 4.1.1 → 5.0.2

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 (48) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/courierreactnative/CourierInboxViewManager.kt +129 -0
  3. package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +71 -20
  4. package/android/src/main/java/com/courierreactnative/Utils.kt +1 -1
  5. package/courier-react-native.podspec +1 -1
  6. package/ios/CourierInboxReactNativeManager.m +2 -0
  7. package/ios/CourierInboxReactNativeManager.swift +165 -0
  8. package/ios/CourierReactNativeDelegate.m +1 -1
  9. package/ios/CourierReactNativeEventEmitter.swift +1 -1
  10. package/ios/CourierReactNativeModule.m +9 -2
  11. package/ios/CourierSharedModule.swift +121 -50
  12. package/lib/commonjs/index.js +114 -22
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
  15. package/lib/commonjs/models/InboxMessageFeed.js +2 -0
  16. package/lib/commonjs/models/InboxMessageFeed.js.map +1 -0
  17. package/lib/commonjs/models/InboxMessageSet.js +6 -0
  18. package/lib/commonjs/models/InboxMessageSet.js.map +1 -0
  19. package/lib/commonjs/views/CourierInboxView.js +1 -0
  20. package/lib/commonjs/views/CourierInboxView.js.map +1 -1
  21. package/lib/module/index.js +108 -22
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/models/CourierInboxListener.js.map +1 -1
  24. package/lib/module/models/InboxMessageFeed.js +2 -0
  25. package/lib/module/models/InboxMessageFeed.js.map +1 -0
  26. package/lib/module/models/InboxMessageSet.js +2 -0
  27. package/lib/module/models/InboxMessageSet.js.map +1 -0
  28. package/lib/module/views/CourierInboxView.js +1 -0
  29. package/lib/module/views/CourierInboxView.js.map +1 -1
  30. package/lib/typescript/src/index.d.ts +22 -3
  31. package/lib/typescript/src/index.d.ts.map +1 -1
  32. package/lib/typescript/src/models/CourierInboxListener.d.ts +7 -0
  33. package/lib/typescript/src/models/CourierInboxListener.d.ts.map +1 -1
  34. package/lib/typescript/src/models/CourierInboxTheme.d.ts +27 -0
  35. package/lib/typescript/src/models/CourierInboxTheme.d.ts.map +1 -1
  36. package/lib/typescript/src/models/InboxMessageFeed.d.ts +2 -0
  37. package/lib/typescript/src/models/InboxMessageFeed.d.ts.map +1 -0
  38. package/lib/typescript/src/models/InboxMessageSet.d.ts +7 -0
  39. package/lib/typescript/src/models/InboxMessageSet.d.ts.map +1 -0
  40. package/lib/typescript/src/views/CourierInboxView.d.ts +1 -0
  41. package/lib/typescript/src/views/CourierInboxView.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/src/index.tsx +125 -27
  44. package/src/models/CourierInboxListener.tsx +8 -1
  45. package/src/models/CourierInboxTheme.tsx +33 -0
  46. package/src/models/InboxMessageFeed.tsx +1 -0
  47. package/src/models/InboxMessageSet.tsx +7 -0
  48. package/src/views/CourierInboxView.tsx +2 -0
@@ -104,7 +104,7 @@ dependencies {
104
104
  implementation 'com.google.code.gson:gson:2.11.0'
105
105
 
106
106
  // Courier Core SDK
107
- api 'com.github.trycourier:courier-android:4.4.1'
107
+ api 'com.github.trycourier:courier-android:4.6.3'
108
108
  api 'androidx.recyclerview:recyclerview:1.3.2'
109
109
 
110
110
  }
@@ -102,6 +102,12 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {
102
102
 
103
103
  val brandId = getString("brandId")
104
104
 
105
+ val tabIndicatorColor = getString("tabIndicatorColor")
106
+ val tabStyle = getMap("tabStyle")
107
+
108
+ val readingSwipeActionStyle = getMap("readingSwipeActionStyle")
109
+ val archivingSwipeActionStyle = getMap("archivingSwipeActionStyle")
110
+
105
111
  val unreadIndicatorStyle = getMap("unreadIndicatorStyle")
106
112
  val loadingIndicatorColor = getString("loadingIndicatorColor")
107
113
 
@@ -115,6 +121,33 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {
115
121
 
116
122
  return CourierInboxTheme(
117
123
  brandId = brandId,
124
+ tabIndicatorColor = tabIndicatorColor?.toColor(),
125
+ tabStyle = tabStyle?.toTabStyle(context) ?: CourierStyles.Inbox.TabStyle(
126
+ selected = CourierStyles.Inbox.TabItemStyle(
127
+ font = CourierStyles.Font(
128
+ sizeInSp = 18
129
+ ),
130
+ indicator = CourierStyles.Inbox.TabIndicatorStyle(
131
+ font = CourierStyles.Font(
132
+ sizeInSp = 14
133
+ ),
134
+ color = null
135
+ )
136
+ ),
137
+ unselected = CourierStyles.Inbox.TabItemStyle(
138
+ font = CourierStyles.Font(
139
+ sizeInSp = 18
140
+ ),
141
+ indicator = CourierStyles.Inbox.TabIndicatorStyle(
142
+ font = CourierStyles.Font(
143
+ sizeInSp = 14
144
+ ),
145
+ color = null
146
+ )
147
+ )
148
+ ),
149
+ readingSwipeActionStyle = readingSwipeActionStyle?.toReadingSwipeActionStyle() ?: CourierStyles.Inbox.ReadingSwipeActionStyle(),
150
+ archivingSwipeActionStyle = archivingSwipeActionStyle?.toArchivingSwipeActionStyle() ?: CourierStyles.Inbox.ArchivingSwipeActionStyle(),
118
151
  unreadIndicatorStyle = unreadIndicatorStyle?.toUnreadIndicatorStyle() ?: CourierStyles.Inbox.UnreadIndicatorStyle(),
119
152
  loadingIndicatorColor = loadingIndicatorColor?.toColor(),
120
153
  titleStyle = titleStyle?.toTextStyle(context) ?: CourierStyles.Inbox.TextStyle(
@@ -154,6 +187,69 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {
154
187
 
155
188
  }
156
189
 
190
+ private fun ReadableMap.toTabStyle(context: Context): CourierStyles.Inbox.TabStyle {
191
+
192
+ val selected = getMap("selected")
193
+ val unselected = getMap("unselected")
194
+
195
+ return CourierStyles.Inbox.TabStyle(
196
+ selected = selected?.toTabItemStyle(context) ?: CourierStyles.Inbox.TabItemStyle(
197
+ font = CourierStyles.Font(
198
+ sizeInSp = 18
199
+ ),
200
+ indicator = CourierStyles.Inbox.TabIndicatorStyle(
201
+ font = CourierStyles.Font(
202
+ sizeInSp = 14
203
+ ),
204
+ color = null
205
+ )
206
+ ),
207
+ unselected = unselected?.toTabItemStyle(context) ?: CourierStyles.Inbox.TabItemStyle(
208
+ font = CourierStyles.Font(
209
+ sizeInSp = 18
210
+ ),
211
+ indicator = CourierStyles.Inbox.TabIndicatorStyle(
212
+ font = CourierStyles.Font(
213
+ sizeInSp = 14
214
+ ),
215
+ color = null
216
+ )
217
+ ),
218
+ )
219
+
220
+ }
221
+
222
+ private fun ReadableMap.toTabItemStyle(context: Context): CourierStyles.Inbox.TabItemStyle {
223
+
224
+ val font = getMap("font")
225
+ val indicator = getMap("indicator")
226
+
227
+ return CourierStyles.Inbox.TabItemStyle(
228
+ font = font?.toFont(context) ?: CourierStyles.Font(
229
+ sizeInSp = 18
230
+ ),
231
+ indicator = indicator?.toTabIndicatorStyle(context) ?: CourierStyles.Inbox.TabIndicatorStyle(
232
+ font = CourierStyles.Font(
233
+ sizeInSp = 14
234
+ ),
235
+ color = null
236
+ ),
237
+ )
238
+
239
+ }
240
+
241
+ private fun ReadableMap.toTabIndicatorStyle(context: Context): CourierStyles.Inbox.TabIndicatorStyle {
242
+
243
+ val font = getMap("font")
244
+ val color = getString("color")
245
+
246
+ return CourierStyles.Inbox.TabIndicatorStyle(
247
+ font = font?.toFont(context) ?: CourierStyles.Font(),
248
+ color = color?.toColor(),
249
+ )
250
+
251
+ }
252
+
157
253
  private fun ReadableMap.toUnreadIndicatorStyle(): CourierStyles.Inbox.UnreadIndicatorStyle {
158
254
 
159
255
  val indicator = getString("indicator")
@@ -172,6 +268,39 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {
172
268
 
173
269
  }
174
270
 
271
+ private fun ReadableMap.toReadingSwipeActionStyle(): CourierStyles.Inbox.ReadingSwipeActionStyle? {
272
+
273
+ val readDict = getMap("read") ?: return null
274
+ val unreadDict = getMap("unread") ?: return null
275
+
276
+ val read = readDict.toSwipeActionStyle() ?: return null
277
+ val unread = unreadDict.toSwipeActionStyle() ?: return null
278
+
279
+ return CourierStyles.Inbox.ReadingSwipeActionStyle(
280
+ read = read,
281
+ unread = unread
282
+ )
283
+
284
+ }
285
+
286
+ private fun ReadableMap.toArchivingSwipeActionStyle(): CourierStyles.Inbox.ArchivingSwipeActionStyle? {
287
+ // TODO: Icon
288
+
289
+ val archiveDict = getMap("archive") ?: return null
290
+ val archive = archiveDict.toSwipeActionStyle() ?: return null
291
+
292
+ return CourierStyles.Inbox.ArchivingSwipeActionStyle(archive = archive)
293
+ }
294
+
295
+ private fun ReadableMap.toSwipeActionStyle(): CourierStyles.Inbox.SwipeActionStyle? {
296
+ // TODO: Icon
297
+
298
+ val colorString = getString("color") ?: return null
299
+ val color = colorString.toColor()
300
+
301
+ return CourierStyles.Inbox.SwipeActionStyle(icon = null, color = color)
302
+ }
303
+
175
304
  private fun ReadableMap.toButtonStyle(context: Context): CourierStyles.Inbox.ButtonStyle {
176
305
 
177
306
  val unread = getMap("unread")
@@ -3,7 +3,7 @@ package com.courierreactnative
3
3
  import com.courier.android.Courier
4
4
  import com.courier.android.models.CourierAuthenticationListener
5
5
  import com.courier.android.models.CourierInboxListener
6
- import com.courier.android.models.InboxMessage
6
+ import com.courier.android.models.InboxMessageSet
7
7
  import com.courier.android.models.remove
8
8
  import com.courier.android.modules.addAuthenticationListener
9
9
  import com.courier.android.modules.addInboxListener
@@ -24,10 +24,12 @@ import com.courier.android.modules.tenantId
24
24
  import com.courier.android.modules.tokens
25
25
  import com.courier.android.modules.unreadMessage
26
26
  import com.courier.android.modules.userId
27
+ import com.courier.android.ui.inbox.InboxMessageFeed
27
28
  import com.facebook.react.bridge.Arguments
28
29
  import com.facebook.react.bridge.Promise
29
30
  import com.facebook.react.bridge.ReactApplicationContext
30
31
  import com.facebook.react.bridge.ReactMethod
32
+ import com.facebook.react.bridge.WritableMap
31
33
  import kotlinx.coroutines.CoroutineScope
32
34
  import kotlinx.coroutines.Dispatchers
33
35
  import kotlinx.coroutines.launch
@@ -235,39 +237,80 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
235
237
  }
236
238
 
237
239
  @ReactMethod(isBlockingSynchronousMethod = true)
238
- fun addInboxListener(loadingId: String, errorId: String, messagesId: String): String {
240
+ fun addInboxListener(loadingId: String, errorId: String, unreadCountId: String, feedId: String, archiveId: String, pageAddedId: String, messageChangedId: String, messageAddedId: String, messageRemovedId: String): String {
239
241
 
240
242
  val listener = Courier.shared.addInboxListener(
241
- onInitialLoad = {
242
-
243
+ onLoading = {
243
244
  reactApplicationContext.sendEvent(
244
245
  eventName = loadingId,
245
246
  value = null
246
247
  )
247
-
248
248
  },
249
249
  onError = { e ->
250
-
251
250
  reactApplicationContext.sendEvent(
252
251
  eventName = errorId,
253
252
  value = e.message ?: "Courier Inbox Error"
254
253
  )
255
-
256
254
  },
257
- onMessagesChanged = { messages: List<InboxMessage>, unreadMessageCount: Int, totalMessageCount: Int, canPaginate: Boolean ->
258
-
255
+ onUnreadCountChanged = { unreadCount ->
256
+ reactApplicationContext.sendEvent(
257
+ eventName = unreadCountId,
258
+ value = unreadCount
259
+ )
260
+ },
261
+ onFeedChanged = { messageSet ->
262
+ reactApplicationContext.sendEvent(
263
+ eventName = feedId,
264
+ value = messageSet.toJson()
265
+ )
266
+ },
267
+ onArchiveChanged = { messageSet ->
268
+ reactApplicationContext.sendEvent(
269
+ eventName = feedId,
270
+ value = messageSet.toJson()
271
+ )
272
+ },
273
+ onPageAdded = { feed, messageSet ->
259
274
  val json = Arguments.createMap()
260
- json.putArray("messages", messages.toList().map { it.toJson() }.toWritableArray())
261
- json.putInt("unreadMessageCount", unreadMessageCount)
262
- json.putInt("totalMessageCount", totalMessageCount)
263
- json.putBoolean("canPaginate", canPaginate)
264
-
275
+ json.putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archived")
276
+ json.putArray("messages", messageSet.messages.map { it.toJson() }.toWritableArray())
277
+ json.putInt("totalMessageCount", messageSet.totalCount)
278
+ json.putBoolean("canPaginate", messageSet.canPaginate)
265
279
  reactApplicationContext.sendEvent(
266
- eventName = messagesId,
280
+ eventName = pageAddedId,
267
281
  value = json
268
282
  )
269
-
270
- }
283
+ },
284
+ onMessageAdded = { feed, index, message ->
285
+ val json = Arguments.createMap()
286
+ json.putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archived")
287
+ json.putInt("index", index)
288
+ json.putString("message", message.toJson())
289
+ reactApplicationContext.sendEvent(
290
+ eventName = messageAddedId,
291
+ value = json
292
+ )
293
+ },
294
+ onMessageChanged = { feed, index, message ->
295
+ val json = Arguments.createMap()
296
+ json.putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archived")
297
+ json.putInt("index", index)
298
+ json.putString("message", message.toJson())
299
+ reactApplicationContext.sendEvent(
300
+ eventName = messageAddedId,
301
+ value = json
302
+ )
303
+ },
304
+ onMessageRemoved = { feed, index, message ->
305
+ val json = Arguments.createMap()
306
+ json.putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archived")
307
+ json.putInt("index", index)
308
+ json.putString("message", message.toJson())
309
+ reactApplicationContext.sendEvent(
310
+ eventName = messageAddedId,
311
+ value = json
312
+ )
313
+ },
271
314
  )
272
315
 
273
316
  // Add listener
@@ -278,6 +321,14 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
278
321
 
279
322
  }
280
323
 
324
+ private fun InboxMessageSet.toJson(): WritableMap? {
325
+ val json = Arguments.createMap()
326
+ json.putArray("messages", messages.toList().map { it.toJson() }.toWritableArray())
327
+ json.putInt("totalMessageCount", totalCount)
328
+ json.putBoolean("canPaginate", canPaginate)
329
+ return json
330
+ }
331
+
281
332
  @ReactMethod(isBlockingSynchronousMethod = true)
282
333
  fun removeInboxListener(listenerId: String): String {
283
334
  val listener = inboxListeners[listenerId]
@@ -300,10 +351,10 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
300
351
  }
301
352
 
302
353
  @ReactMethod
303
- fun fetchNextPageOfMessages(promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
354
+ fun fetchNextPageOfMessages(promise: Promise, inboxMessageFeed: String) = CoroutineScope(Dispatchers.Main).launch {
304
355
  try {
305
- val messages = Courier.shared.fetchNextInboxPage()
306
- promise.resolve(messages.map { it.toJson() }.toWritableArray())
356
+ val messageSet = Courier.shared.fetchNextInboxPage(if (inboxMessageFeed == "archived") InboxMessageFeed.ARCHIVE else InboxMessageFeed.FEED)
357
+ promise.resolve(messageSet?.toJson())
307
358
  } catch (e: Exception) {
308
359
  promise.apiError(e)
309
360
  }
@@ -15,7 +15,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
15
15
  import com.google.gson.GsonBuilder
16
16
 
17
17
  internal object Utils {
18
- val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "4.1.1")
18
+ val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "5.0.2")
19
19
  }
20
20
 
21
21
  internal fun ReactContext.sendEvent(eventName: String, value: Any?) {
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
19
  # Courier Core Dependency
20
- s.dependency "Courier_iOS", "4.5.4"
20
+ s.dependency "Courier_iOS", "5.2.0"
21
21
 
22
22
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
23
23
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
@@ -2,6 +2,8 @@
2
2
 
3
3
  @interface RCT_EXTERN_MODULE(CourierInboxViewManager, RCTViewManager)
4
4
 
5
+ RCT_EXPORT_VIEW_PROPERTY(canSwipePages, BOOL)
6
+
5
7
  RCT_EXPORT_VIEW_PROPERTY(theme, NSDictionary)
6
8
 
7
9
  RCT_EXPORT_VIEW_PROPERTY(onClickInboxMessageAtIndex, RCTBubblingEventBlock)
@@ -14,6 +14,12 @@ class CourierInboxViewManager: RCTViewManager {
14
14
  }
15
15
 
16
16
  class CourierInboxView : UIView {
17
+
18
+ @objc var canSwipePages: Bool = false {
19
+ didSet {
20
+ refresh()
21
+ }
22
+ }
17
23
 
18
24
  @objc var theme: NSDictionary? = [:] {
19
25
  didSet {
@@ -39,6 +45,7 @@ class CourierInboxView : UIView {
39
45
  let darkTheme = theme?["dark"] as? NSDictionary
40
46
 
41
47
  let courierInbox = CourierInbox(
48
+ canSwipePages: self.canSwipePages,
42
49
  lightTheme: lightTheme?.toInboxTheme() ?? .defaultLight,
43
50
  darkTheme: darkTheme?.toInboxTheme() ?? .defaultDark,
44
51
  didClickInboxMessageAtIndex: { [weak self] message, index in
@@ -85,10 +92,160 @@ class CourierInboxView : UIView {
85
92
  UIView.setAnimationsEnabled(true)
86
93
 
87
94
  }
95
+
96
+ internal static func defaultTabStyle() -> CourierStyles.Inbox.TabStyle {
97
+ return CourierStyles.Inbox.TabStyle(
98
+ selected: CourierStyles.Inbox.TabItemStyle(
99
+ font: CourierStyles.Font(
100
+ font: UIFont.boldSystemFont(ofSize: UIFont.labelFontSize),
101
+ color: .label
102
+ ),
103
+ indicator: CourierStyles.Inbox.TabIndicatorStyle(
104
+ font: CourierStyles.Font(
105
+ font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize),
106
+ color: .white
107
+ ),
108
+ color: .systemBlue
109
+ )
110
+ ),
111
+ unselected: CourierStyles.Inbox.TabItemStyle(
112
+ font: CourierStyles.Font(
113
+ font: UIFont.boldSystemFont(ofSize: UIFont.labelFontSize),
114
+ color: .secondaryLabel
115
+ ),
116
+ indicator: CourierStyles.Inbox.TabIndicatorStyle(
117
+ font: CourierStyles.Font(
118
+ font: UIFont.boldSystemFont(ofSize: UIFont.systemFontSize),
119
+ color: .label
120
+ ),
121
+ color: .lightGray
122
+ )
123
+ )
124
+ )
125
+ }
126
+
127
+ internal static func defaultReadingStyle() -> CourierStyles.Inbox.ReadingSwipeActionStyle {
128
+ return CourierStyles.Inbox.ReadingSwipeActionStyle(
129
+ read: CourierStyles.Inbox.SwipeActionStyle(
130
+ icon: UIImage(systemName: "envelope.fill"),
131
+ color: .systemGray
132
+ ),
133
+ unread: CourierStyles.Inbox.SwipeActionStyle(
134
+ icon: UIImage(systemName: "envelope.open.fill"),
135
+ color: .systemBlue
136
+ )
137
+ )
138
+ }
139
+
140
+ internal static func defaultArchivingStyle() -> CourierStyles.Inbox.ArchivingSwipeActionStyle {
141
+ return CourierStyles.Inbox.ArchivingSwipeActionStyle(
142
+ archive: CourierStyles.Inbox.SwipeActionStyle(
143
+ icon: UIImage(systemName: "archivebox.fill"),
144
+ color: .systemRed
145
+ )
146
+ )
147
+ }
88
148
 
89
149
  }
90
150
 
91
151
  internal extension NSDictionary {
152
+
153
+ func toTabStyle() -> CourierStyles.Inbox.TabStyle? {
154
+
155
+ guard let selectedDict = self["selected"] as? NSDictionary, let unselectedDict = self["unselected"] as? NSDictionary else {
156
+ return nil
157
+ }
158
+
159
+ guard let selected = selectedDict.toTabItemStyle(), let unselected = unselectedDict.toTabItemStyle() else {
160
+ return nil
161
+ }
162
+
163
+ return CourierStyles.Inbox.TabStyle(
164
+ selected: selected,
165
+ unselected: unselected
166
+ )
167
+
168
+ }
169
+
170
+ func toTabItemStyle() -> CourierStyles.Inbox.TabItemStyle? {
171
+
172
+ guard let fontDict = self["font"] as? NSDictionary, let indicatorDict = self["indicator"] as? NSDictionary else {
173
+ return nil
174
+ }
175
+
176
+ let font = fontDict.toFont()
177
+ guard let indicator = indicatorDict.toTabIndicatorStyle() else {
178
+ return nil
179
+ }
180
+
181
+ return CourierStyles.Inbox.TabItemStyle(font: font, indicator: indicator)
182
+
183
+ }
184
+
185
+ func toTabIndicatorStyle() -> CourierStyles.Inbox.TabIndicatorStyle? {
186
+
187
+ guard let fontDict = self["font"] as? NSDictionary, let colorString = self["color"] as? String else {
188
+ return nil
189
+ }
190
+
191
+ let font = fontDict.toFont()
192
+ guard let color = colorString.toColor() else {
193
+ return nil
194
+ }
195
+
196
+ return CourierStyles.Inbox.TabIndicatorStyle(
197
+ font: font,
198
+ color: color
199
+ )
200
+
201
+ }
202
+
203
+ func toReadingSwipeActionStyle() -> CourierStyles.Inbox.ReadingSwipeActionStyle? {
204
+
205
+ guard let readDict = self["read"] as? NSDictionary, let unreadDict = self["unread"] as? NSDictionary else {
206
+ return nil
207
+ }
208
+
209
+ guard let read = readDict.toSwipeActionStyle(), let unread = unreadDict.toSwipeActionStyle() else {
210
+ return nil
211
+ }
212
+
213
+ return CourierStyles.Inbox.ReadingSwipeActionStyle(
214
+ read: read,
215
+ unread: unread
216
+ )
217
+
218
+ }
219
+
220
+ func toArchivingSwipeActionStyle() -> CourierStyles.Inbox.ArchivingSwipeActionStyle? {
221
+
222
+ // TODO: Icon
223
+
224
+ guard let archiveDict = self["archive"] as? NSDictionary else {
225
+ return nil
226
+ }
227
+
228
+ guard let archive = archiveDict.toSwipeActionStyle() else {
229
+ return nil
230
+ }
231
+
232
+ return CourierStyles.Inbox.ArchivingSwipeActionStyle(archive: archive)
233
+
234
+ }
235
+
236
+ func toSwipeActionStyle() -> CourierStyles.Inbox.SwipeActionStyle? {
237
+
238
+ // TODO: Icon
239
+
240
+ guard let colorString = self["color"] as? String else {
241
+ return nil
242
+ }
243
+
244
+ let color = colorString.toColor() ?? .systemBlue
245
+
246
+ return CourierStyles.Inbox.SwipeActionStyle(icon: nil, color: color)
247
+
248
+ }
92
249
 
93
250
  func toUnreadIndicatorStyle() -> CourierStyles.Inbox.UnreadIndicatorStyle {
94
251
 
@@ -137,6 +294,10 @@ internal extension NSDictionary {
137
294
  let defaultTheme = CourierInboxTheme()
138
295
 
139
296
  let brandId = self["brandId"] as? String
297
+ let tabIndicatorColor = self["tabIndicatorColor"] as? String
298
+ let tabStyle = self["tabStyle"] as? NSDictionary
299
+ let readingSwipeActionStyle = self["readingSwipeActionStyle"] as? NSDictionary
300
+ let archivingSwipeActionStyle = self["archivingSwipeActionStyle"] as? NSDictionary
140
301
  let unreadIndicatorStyle = self["unreadIndicatorStyle"] as? NSDictionary
141
302
  let loadingIndicatorColor = self["loadingIndicatorColor"] as? String
142
303
  let titleStyle = self["titleStyle"] as? NSDictionary
@@ -151,6 +312,10 @@ internal extension NSDictionary {
151
312
 
152
313
  return CourierInboxTheme(
153
314
  brandId: brandId,
315
+ tabIndicatorColor: tabIndicatorColor?.toColor(),
316
+ tabStyle: tabStyle?.toTabStyle() ?? CourierInboxView.defaultTabStyle(),
317
+ readingSwipeActionStyle: readingSwipeActionStyle?.toReadingSwipeActionStyle() ?? CourierInboxView.defaultReadingStyle(),
318
+ archivingSwipeActionStyle: archivingSwipeActionStyle?.toArchivingSwipeActionStyle() ?? CourierInboxView.defaultArchivingStyle(),
154
319
  messageAnimationStyle: messageAnimationStyle?.toRowAnimation() ?? .left,
155
320
  loadingIndicatorColor: loadingIndicatorColor?.toColor(),
156
321
  unreadIndicatorStyle: unreadIndicatorStyle?.toUnreadIndicatorStyle() ?? defaultTheme.unreadIndicatorStyle,
@@ -22,7 +22,7 @@ NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNon
22
22
  if (self) {
23
23
 
24
24
  // Set the user agent
25
- Courier.agent = [CourierAgent reactNativeIOS:@"4.1.1"];
25
+ Courier.agent = [CourierAgent reactNativeIOS:@"5.0.2"];
26
26
 
27
27
  // Register for remote notifications
28
28
  UIApplication *app = [UIApplication sharedApplication];
@@ -14,7 +14,7 @@ internal class CourierReactNativeEventEmitter: RCTEventEmitter {
14
14
 
15
15
  // Set the user agent
16
16
  // Used to know the platform performing requests
17
- Courier.agent = CourierAgent.reactNativeIOS("4.1.1")
17
+ Courier.agent = CourierAgent.reactNativeIOS("5.0.2")
18
18
 
19
19
  }
20
20
 
@@ -109,7 +109,13 @@ RCT_EXTERN_METHOD(
109
109
  RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
110
110
  addInboxListener: (NSString*)loadingId
111
111
  withErrorId: (NSString*)errorId
112
- withMessagesId: (NSString*)messagesId
112
+ withUnreadCountId: (NSString*)unreadCountId
113
+ withFeedId: (NSString*)feedId
114
+ withArchiveId: (NSString*)archiveId
115
+ withPageAddedId: (NSString*)pageAddedId
116
+ withMessageChangedId: (NSString*)messageChangedId
117
+ withMessageAddedId: (NSString*)messageAddedId
118
+ withMessageRemovedId: (NSString*)messageRemovedId
113
119
  )
114
120
 
115
121
  RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
@@ -126,7 +132,8 @@ RCT_EXTERN_METHOD(
126
132
  )
127
133
 
128
134
  RCT_EXTERN_METHOD(
129
- fetchNextPageOfMessages: (RCTPromiseResolveBlock)resolve
135
+ fetchNextPageOfMessages: (NSString*)inboxMessageFeed
136
+ withResolver: (RCTPromiseResolveBlock)resolve
130
137
  withRejecter: (RCTPromiseRejectBlock)reject
131
138
  )
132
139