@trycourier/courier-react-native 2.1.0 → 2.2.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 +2 -2
- package/android/src/main/java/com/courierreactnative/CourierReactNativeActivity.kt +0 -3
- package/android/src/main/java/com/courierreactnative/CourierReactNativeModule.kt +51 -22
- package/android/src/main/java/com/courierreactnative/CourierReactNativeViewManager.kt +84 -18
- package/courier-react-native.podspec +1 -1
- package/ios/CourierReactNativeModule.m +5 -9
- package/ios/CourierReactNativeModule.swift +8 -11
- package/ios/CourierReactNativeViewManager.swift +122 -41
- package/lib/commonjs/index.js +54 -34
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierPushProvider.js +16 -0
- package/lib/commonjs/models/CourierPushProvider.js.map +1 -0
- package/lib/module/index.js +13 -17
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierPushProvider.js +9 -0
- package/lib/module/models/CourierPushProvider.js.map +1 -0
- package/lib/typescript/index.d.ts +16 -8
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/CourierInboxTheme.d.ts +24 -8
- package/lib/typescript/models/CourierInboxTheme.d.ts.map +1 -1
- package/lib/typescript/models/CourierPushProvider.d.ts +8 -0
- package/lib/typescript/models/CourierPushProvider.d.ts.map +1 -0
- package/lib/typescript/views/CourierInboxView.d.ts +1 -1
- package/lib/typescript/views/CourierInboxView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +16 -20
- package/src/models/CourierInboxTheme.tsx +28 -8
- package/src/models/CourierPushProvider.tsx +7 -0
- package/src/views/CourierInboxView.tsx +1 -1
- package/lib/commonjs/hooks/CourierProvider.js +0 -254
- package/lib/commonjs/hooks/CourierProvider.js.map +0 -1
- package/lib/module/hooks/CourierProvider.js +0 -241
- package/lib/module/hooks/CourierProvider.js.map +0 -1
- package/lib/typescript/hooks/CourierProvider.d.ts +0 -57
- package/lib/typescript/hooks/CourierProvider.d.ts.map +0 -1
- package/src/hooks/CourierProvider.tsx +0 -356
package/android/build.gradle
CHANGED
|
@@ -101,8 +101,8 @@ dependencies {
|
|
|
101
101
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
102
102
|
|
|
103
103
|
// Courier Core SDK
|
|
104
|
-
api 'com.github.trycourier:courier-android:2.
|
|
105
|
-
api 'androidx.recyclerview:recyclerview:1.3.
|
|
104
|
+
api 'com.github.trycourier:courier-android:2.3.0'
|
|
105
|
+
api 'androidx.recyclerview:recyclerview:1.3.2'
|
|
106
106
|
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -6,10 +6,7 @@ import com.courier.android.Courier
|
|
|
6
6
|
import com.courier.android.utils.getLastDeliveredMessage
|
|
7
7
|
import com.courier.android.utils.pushNotification
|
|
8
8
|
import com.courier.android.utils.trackPushNotificationClick
|
|
9
|
-
//import com.courier.android.pushNotification
|
|
10
|
-
//import com.courier.android.trackPushNotificationClick
|
|
11
9
|
import com.facebook.react.ReactActivity
|
|
12
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
13
10
|
import com.google.firebase.messaging.RemoteMessage
|
|
14
11
|
import org.json.JSONObject
|
|
15
12
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
package com.courierreactnative
|
|
2
2
|
|
|
3
|
+
import android.Manifest
|
|
3
4
|
import android.content.Intent
|
|
5
|
+
import android.content.pm.PackageManager
|
|
6
|
+
import android.os.Build
|
|
7
|
+
import androidx.core.app.ActivityCompat
|
|
8
|
+
import androidx.core.content.ContextCompat
|
|
4
9
|
import com.courier.android.Courier
|
|
5
10
|
import com.courier.android.models.*
|
|
6
11
|
import com.courier.android.modules.*
|
|
7
|
-
import com.courier.android.utils.isPushPermissionGranted
|
|
8
12
|
import com.courier.android.utils.pushNotification
|
|
9
|
-
import com.courier.android.utils.requestNotificationPermission
|
|
10
13
|
import com.courier.android.utils.trackPushNotificationClick
|
|
11
14
|
import com.facebook.react.ReactActivity
|
|
12
15
|
import com.facebook.react.bridge.*
|
|
@@ -72,16 +75,48 @@ class CourierReactNativeModule(reactContext: ReactApplicationContext) : ReactCon
|
|
|
72
75
|
)
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
@ReactMethod
|
|
78
|
+
@ReactMethod
|
|
76
79
|
fun requestNotificationPermission(promise: Promise) {
|
|
77
|
-
|
|
80
|
+
|
|
81
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
|
82
|
+
promise.resolve("unknown")
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Request the push permission
|
|
87
|
+
reactActivity?.let { context ->
|
|
88
|
+
|
|
89
|
+
val permissionState: Int = ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS)
|
|
90
|
+
|
|
91
|
+
if (permissionState == PackageManager.PERMISSION_DENIED) {
|
|
92
|
+
ActivityCompat.requestPermissions(context, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 1)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
promise.resolve("unknown")
|
|
98
|
+
|
|
78
99
|
}
|
|
79
100
|
|
|
80
|
-
@ReactMethod
|
|
101
|
+
@ReactMethod
|
|
81
102
|
fun getNotificationPermissionStatus(promise: Promise) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
103
|
+
|
|
104
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
|
105
|
+
promise.resolve("unknown")
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
reactActivity?.let { context ->
|
|
110
|
+
|
|
111
|
+
val permissionState: Int = ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS)
|
|
112
|
+
val status = if (permissionState == PackageManager.PERMISSION_GRANTED) "authorized" else "denied"
|
|
113
|
+
promise.resolve(status)
|
|
114
|
+
return
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
promise.resolve("unknown")
|
|
119
|
+
|
|
85
120
|
}
|
|
86
121
|
|
|
87
122
|
@ReactMethod
|
|
@@ -147,9 +182,15 @@ class CourierReactNativeModule(reactContext: ReactApplicationContext) : ReactCon
|
|
|
147
182
|
|
|
148
183
|
}
|
|
149
184
|
|
|
185
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
186
|
+
fun getToken(key: String): String? {
|
|
187
|
+
return Courier.shared.getToken(key)
|
|
188
|
+
}
|
|
189
|
+
|
|
150
190
|
@ReactMethod
|
|
151
|
-
fun
|
|
152
|
-
Courier.shared.
|
|
191
|
+
fun setToken(key: String, token: String, promise: Promise) {
|
|
192
|
+
Courier.shared.setToken(
|
|
193
|
+
provider = key,
|
|
153
194
|
token = token,
|
|
154
195
|
onSuccess = {
|
|
155
196
|
promise.resolve(null)
|
|
@@ -160,18 +201,6 @@ class CourierReactNativeModule(reactContext: ReactApplicationContext) : ReactCon
|
|
|
160
201
|
)
|
|
161
202
|
}
|
|
162
203
|
|
|
163
|
-
@ReactMethod
|
|
164
|
-
fun getFcmToken(promise: Promise) {
|
|
165
|
-
Courier.shared.getFCMToken(
|
|
166
|
-
onSuccess = { token ->
|
|
167
|
-
promise.resolve(token)
|
|
168
|
-
},
|
|
169
|
-
onFailure = { e ->
|
|
170
|
-
promise.reject(CourierEvents.COURIER_ERROR_TAG, e)
|
|
171
|
-
}
|
|
172
|
-
)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
204
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
176
205
|
fun readMessage(messageId: String): String {
|
|
177
206
|
Courier.shared.readMessage(messageId)
|
|
@@ -5,10 +5,7 @@ import android.graphics.Color
|
|
|
5
5
|
import android.graphics.Typeface
|
|
6
6
|
import android.view.View
|
|
7
7
|
import androidx.recyclerview.widget.DividerItemDecoration
|
|
8
|
-
import com.courier.android.inbox
|
|
9
|
-
import com.courier.android.inbox.CourierInboxButtonStyles
|
|
10
|
-
import com.courier.android.inbox.CourierInboxFont
|
|
11
|
-
import com.courier.android.inbox.CourierInboxTheme
|
|
8
|
+
import com.courier.android.inbox.*
|
|
12
9
|
import com.facebook.react.bridge.Arguments
|
|
13
10
|
import com.facebook.react.bridge.ReadableMap
|
|
14
11
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
@@ -90,26 +87,41 @@ class CourierReactNativeViewManager : SimpleViewManager<CourierInbox>() {
|
|
|
90
87
|
val android = getMap("android")
|
|
91
88
|
val dividerItemDecoration = android?.getString("dividerItemDecoration")
|
|
92
89
|
|
|
93
|
-
val
|
|
90
|
+
val unreadIndicatorStyle = getMap("unreadIndicatorStyle")
|
|
94
91
|
val loadingIndicatorColor = getString("loadingIndicatorColor")
|
|
95
92
|
|
|
96
|
-
val
|
|
97
|
-
val
|
|
98
|
-
val
|
|
99
|
-
val
|
|
93
|
+
val titleStyle = getMap("titleStyle")
|
|
94
|
+
val timeStyle = getMap("timeStyle")
|
|
95
|
+
val bodyStyle = getMap("bodyStyle")
|
|
96
|
+
val infoViewStyle = getMap("infoViewStyle")
|
|
100
97
|
val buttonStyles = getMap("buttonStyles")
|
|
101
98
|
|
|
102
99
|
val context = view.context
|
|
103
100
|
|
|
104
101
|
return CourierInboxTheme(
|
|
105
|
-
|
|
106
|
-
unreadIndicatorBarColor = unreadIndicatorBarColor?.toColor(),
|
|
102
|
+
unreadIndicatorStyle = unreadIndicatorStyle?.toUnreadIndicatorStyle() ?: CourierInboxUnreadIndicatorStyle(),
|
|
107
103
|
loadingIndicatorColor = loadingIndicatorColor?.toColor(),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
titleStyle = titleStyle?.toTextStyle(context) ?: CourierInboxTextStyle(
|
|
105
|
+
unread = CourierInboxFont(),
|
|
106
|
+
read = CourierInboxFont(),
|
|
107
|
+
),
|
|
108
|
+
timeStyle = timeStyle?.toTextStyle(context) ?: CourierInboxTextStyle(
|
|
109
|
+
unread = CourierInboxFont(),
|
|
110
|
+
read = CourierInboxFont(),
|
|
111
|
+
),
|
|
112
|
+
bodyStyle = bodyStyle?.toTextStyle(context) ?: CourierInboxTextStyle(
|
|
113
|
+
unread = CourierInboxFont(),
|
|
114
|
+
read = CourierInboxFont(),
|
|
115
|
+
),
|
|
116
|
+
buttonStyle = buttonStyles?.toButtonStyle(context) ?: CourierInboxButtonStyle(
|
|
117
|
+
unread = CourierInboxButton(),
|
|
118
|
+
read = CourierInboxButton(),
|
|
119
|
+
),
|
|
120
|
+
infoViewStyle = infoViewStyle?.toInfoStyle(context) ?: CourierInboxInfoViewStyle(
|
|
121
|
+
font = CourierInboxFont(),
|
|
122
|
+
button = CourierInboxButton(),
|
|
123
|
+
),
|
|
124
|
+
dividerItemDecoration = dividerItemDecoration?.toDivider(context),
|
|
113
125
|
)
|
|
114
126
|
|
|
115
127
|
}
|
|
@@ -142,13 +154,43 @@ class CourierReactNativeViewManager : SimpleViewManager<CourierInbox>() {
|
|
|
142
154
|
|
|
143
155
|
}
|
|
144
156
|
|
|
145
|
-
private fun ReadableMap.
|
|
157
|
+
private fun ReadableMap.toTextStyle(context: Context): CourierInboxTextStyle {
|
|
158
|
+
|
|
159
|
+
val unread = getMap("unread")
|
|
160
|
+
val read = getMap("read")
|
|
161
|
+
|
|
162
|
+
return CourierInboxTextStyle(
|
|
163
|
+
unread = unread?.toFont(context) ?: CourierInboxFont(),
|
|
164
|
+
read = read?.toFont(context) ?: CourierInboxFont(),
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private fun ReadableMap.toUnreadIndicatorStyle(): CourierInboxUnreadIndicatorStyle {
|
|
170
|
+
|
|
171
|
+
val indicator = getString("indicator")
|
|
172
|
+
val color = getString("color")
|
|
173
|
+
|
|
174
|
+
var style = CourierInboxUnreadIndicator.LINE
|
|
175
|
+
|
|
176
|
+
if (indicator == "dot") {
|
|
177
|
+
style = CourierInboxUnreadIndicator.DOT
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return CourierInboxUnreadIndicatorStyle(
|
|
181
|
+
indicator = style,
|
|
182
|
+
color = color?.toColor(),
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private fun ReadableMap.toButton(context: Context): CourierInboxButton {
|
|
146
188
|
|
|
147
189
|
val font = getMap("font")
|
|
148
190
|
val backgroundColor = getString("backgroundColor")
|
|
149
191
|
val cornerRadius = if (isNull("cornerRadius")) null else getDouble("cornerRadius")
|
|
150
192
|
|
|
151
|
-
return
|
|
193
|
+
return CourierInboxButton(
|
|
152
194
|
font = font?.toFont(context),
|
|
153
195
|
backgroundColor = backgroundColor?.toColor(),
|
|
154
196
|
cornerRadiusInDp = cornerRadius?.toInt()
|
|
@@ -156,4 +198,28 @@ class CourierReactNativeViewManager : SimpleViewManager<CourierInbox>() {
|
|
|
156
198
|
|
|
157
199
|
}
|
|
158
200
|
|
|
201
|
+
private fun ReadableMap.toButtonStyle(context: Context): CourierInboxButtonStyle {
|
|
202
|
+
|
|
203
|
+
val unread = getMap("unread")
|
|
204
|
+
val read = getMap("read")
|
|
205
|
+
|
|
206
|
+
return CourierInboxButtonStyle(
|
|
207
|
+
unread = unread?.toButton(context) ?: CourierInboxButton(),
|
|
208
|
+
read = read?.toButton(context) ?: CourierInboxButton()
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private fun ReadableMap.toInfoStyle(context: Context): CourierInboxInfoViewStyle {
|
|
214
|
+
|
|
215
|
+
val font = getMap("font")
|
|
216
|
+
val button = getMap("button")
|
|
217
|
+
|
|
218
|
+
return CourierInboxInfoViewStyle(
|
|
219
|
+
font = font?.toFont(context) ?: CourierInboxFont(),
|
|
220
|
+
button = button?.toButton(context) ?: CourierInboxButton()
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
159
225
|
}
|
|
@@ -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", "2.
|
|
20
|
+
s.dependency "Courier_iOS", "2.7.2"
|
|
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.
|
|
@@ -45,19 +45,15 @@ RCT_EXTERN_METHOD(
|
|
|
45
45
|
withRejecter: (RCTPromiseRejectBlock)reject
|
|
46
46
|
)
|
|
47
47
|
|
|
48
|
-
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
|
|
49
|
-
getApnsToken
|
|
50
|
-
)
|
|
51
|
-
|
|
52
48
|
RCT_EXTERN_METHOD(
|
|
53
|
-
|
|
49
|
+
setToken: (NSString*)key
|
|
50
|
+
withToken: (NSString*)token
|
|
51
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
54
52
|
withRejecter: (RCTPromiseRejectBlock)reject
|
|
55
53
|
)
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
withResolver: (RCTPromiseResolveBlock)resolve
|
|
60
|
-
withRejecter: (RCTPromiseRejectBlock)reject
|
|
55
|
+
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
|
|
56
|
+
getToken: (NSString*)key
|
|
61
57
|
)
|
|
62
58
|
|
|
63
59
|
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
|
|
@@ -226,11 +226,12 @@ class CourierReactNativeModule: RCTEventEmitter {
|
|
|
226
226
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
@objc(
|
|
230
|
-
func
|
|
229
|
+
@objc(setToken: withToken: withResolver: withRejecter:)
|
|
230
|
+
func setToken(key: NSString, token: NSString, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
231
231
|
|
|
232
|
-
Courier.shared.
|
|
233
|
-
|
|
232
|
+
Courier.shared.setToken(
|
|
233
|
+
providerKey: key as String,
|
|
234
|
+
token: token as String,
|
|
234
235
|
onSuccess: {
|
|
235
236
|
resolve(nil)
|
|
236
237
|
},
|
|
@@ -241,13 +242,9 @@ class CourierReactNativeModule: RCTEventEmitter {
|
|
|
241
242
|
|
|
242
243
|
}
|
|
243
244
|
|
|
244
|
-
@objc(
|
|
245
|
-
func
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
@objc func getApnsToken() -> String? {
|
|
250
|
-
return Courier.shared.apnsToken
|
|
245
|
+
@objc(getToken:)
|
|
246
|
+
func getToken(key: NSString) -> String? {
|
|
247
|
+
return Courier.shared.getToken(providerKey: key as String)
|
|
251
248
|
}
|
|
252
249
|
|
|
253
250
|
@objc(iOSForegroundPresentationOptions:)
|
|
@@ -96,56 +96,58 @@ class CourierReactNativeView : UIView {
|
|
|
96
96
|
let cellStyles = iOS?["cellStyles"] as? [String : Any]
|
|
97
97
|
|
|
98
98
|
// Unread
|
|
99
|
-
let
|
|
99
|
+
let unreadIndicatorStyle = dict["unreadIndicatorStyle"] as? [String : Any]
|
|
100
100
|
|
|
101
101
|
// Loading
|
|
102
102
|
let loadingIndicatorColor = dict["loadingIndicatorColor"] as? String
|
|
103
103
|
|
|
104
104
|
// Title
|
|
105
|
-
let
|
|
105
|
+
let titleStyle = dict["titleStyle"] as? [String : Any]
|
|
106
106
|
|
|
107
107
|
// Time
|
|
108
|
-
let
|
|
108
|
+
let timeStyle = dict["timeStyle"] as? [String : Any]
|
|
109
109
|
|
|
110
110
|
// Body
|
|
111
|
-
let
|
|
111
|
+
let bodyStyle = dict["bodyStyle"] as? [String : Any]
|
|
112
112
|
|
|
113
|
-
//
|
|
114
|
-
let
|
|
113
|
+
// Info View
|
|
114
|
+
let infoViewStyle = dict["infoViewStyle"] as? [String : Any]
|
|
115
115
|
|
|
116
|
-
//
|
|
117
|
-
let
|
|
116
|
+
// Button
|
|
117
|
+
let buttonStyle = dict["buttonStyle"] as? [String : Any]
|
|
118
118
|
|
|
119
119
|
return CourierInboxTheme(
|
|
120
120
|
messageAnimationStyle: messageAnimationStyle?.toRowAnimation() ?? .left,
|
|
121
|
-
unreadIndicatorBarColor: unreadIndicatorBarColor?.toColor(),
|
|
122
121
|
loadingIndicatorColor: loadingIndicatorColor?.toColor(),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
),
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
122
|
+
unreadIndicatorStyle: dictionaryToUnreadStyle(dictionary: unreadIndicatorStyle),
|
|
123
|
+
titleStyle: dictionaryToTextStyle(dictionary: titleStyle),
|
|
124
|
+
timeStyle: dictionaryToTextStyle(dictionary: timeStyle),
|
|
125
|
+
bodyStyle: dictionaryToTextStyle(dictionary: bodyStyle),
|
|
126
|
+
buttonStyle: dictionaryToButtonStyle(dictionary: buttonStyle),
|
|
127
|
+
cellStyle: dictionaryToCellStyles(dictionary: cellStyles),
|
|
128
|
+
infoViewStyle: dictionaryToInfoViewStyle(dictionary: infoViewStyle)
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
func dictionaryToUnreadStyle(dictionary: [String : Any]?) -> CourierInboxUnreadIndicatorStyle {
|
|
134
|
+
|
|
135
|
+
guard let dict = dictionary else {
|
|
136
|
+
return CourierInboxUnreadIndicatorStyle()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let indicator = dict["indicator"] as? String
|
|
140
|
+
let color = dict["color"] as? String
|
|
141
|
+
|
|
142
|
+
var style: CourierInboxUnreadIndicator = .line
|
|
143
|
+
|
|
144
|
+
if (indicator == "dot") {
|
|
145
|
+
style = .dot
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return CourierInboxUnreadIndicatorStyle(
|
|
149
|
+
indicator: style,
|
|
150
|
+
color: color?.toColor()
|
|
149
151
|
)
|
|
150
152
|
|
|
151
153
|
}
|
|
@@ -170,17 +172,22 @@ class CourierReactNativeView : UIView {
|
|
|
170
172
|
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
func
|
|
175
|
+
func dictionaryToButton(dictionary: [String : Any]?) -> CourierInboxButton {
|
|
174
176
|
|
|
175
177
|
guard let dict = dictionary else {
|
|
176
|
-
return
|
|
178
|
+
return CourierInboxButton(
|
|
179
|
+
font: CourierInboxFont(
|
|
180
|
+
font: UIFont.systemFont(ofSize: UIFont.labelFontSize),
|
|
181
|
+
color: .white
|
|
182
|
+
)
|
|
183
|
+
)
|
|
177
184
|
}
|
|
178
185
|
|
|
179
186
|
let font = dict["font"] as? [String : Any]
|
|
180
187
|
let backgroundColor = dict["backgroundColor"] as? String
|
|
181
188
|
let cornerRadius = dict["cornerRadius"] as? CGFloat
|
|
182
189
|
|
|
183
|
-
return
|
|
190
|
+
return CourierInboxButton(
|
|
184
191
|
font: dictionaryToFont(
|
|
185
192
|
dictionary: font,
|
|
186
193
|
defaultFont: UIFont.systemFont(ofSize: UIFont.labelFontSize),
|
|
@@ -192,10 +199,84 @@ class CourierReactNativeView : UIView {
|
|
|
192
199
|
|
|
193
200
|
}
|
|
194
201
|
|
|
195
|
-
func
|
|
202
|
+
func dictionaryToButtonStyle(dictionary: [String : Any]?) -> CourierInboxButtonStyle {
|
|
203
|
+
|
|
204
|
+
guard let dict = dictionary else {
|
|
205
|
+
return CourierInboxButtonStyle()
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let unread = dict["unread"] as? [String : Any]
|
|
209
|
+
let read = dict["read"] as? [String : Any]
|
|
210
|
+
|
|
211
|
+
return CourierInboxButtonStyle(
|
|
212
|
+
unread: dictionaryToButton(dictionary: unread),
|
|
213
|
+
read: dictionaryToButton(dictionary: read)
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
func dictionaryToInfoViewStyle(dictionary: [String : Any]?) -> CourierInboxInfoViewStyle {
|
|
219
|
+
|
|
220
|
+
let defaultColor: UIColor = .label
|
|
221
|
+
let defaultFont: UIFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
|
|
222
|
+
|
|
223
|
+
let defaultInboxFont = CourierInboxFont(
|
|
224
|
+
font: defaultFont,
|
|
225
|
+
color: defaultColor
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
guard let dict = dictionary else {
|
|
229
|
+
return CourierInboxInfoViewStyle(
|
|
230
|
+
font: defaultInboxFont,
|
|
231
|
+
button: CourierInboxButton(
|
|
232
|
+
font: defaultInboxFont
|
|
233
|
+
)
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
let font = dict["font"] as? [String : Any]
|
|
238
|
+
let button = dict["button"] as? [String : Any]
|
|
239
|
+
|
|
240
|
+
return CourierInboxInfoViewStyle(
|
|
241
|
+
font: dictionaryToFont(dictionary: font, defaultFont: defaultFont, defaultColor: defaultColor),
|
|
242
|
+
button: dictionaryToButton(dictionary: button)
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
func dictionaryToTextStyle(dictionary: [String : Any]?) -> CourierInboxTextStyle {
|
|
248
|
+
|
|
249
|
+
let defaultColor: UIColor = .label
|
|
250
|
+
let defaultFont: UIFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
|
|
251
|
+
|
|
252
|
+
let defaultInboxFont = CourierInboxFont(
|
|
253
|
+
font: defaultFont,
|
|
254
|
+
color: defaultColor
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
let defaultText = CourierInboxTextStyle(
|
|
258
|
+
unread: defaultInboxFont,
|
|
259
|
+
read: defaultInboxFont
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
guard let dict = dictionary else {
|
|
263
|
+
return defaultText
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let unread = dict["unread"] as? [String : Any]
|
|
267
|
+
let read = dict["read"] as? [String : Any]
|
|
268
|
+
|
|
269
|
+
return CourierInboxTextStyle(
|
|
270
|
+
unread: dictionaryToFont(dictionary: unread, defaultFont: defaultFont, defaultColor: defaultColor),
|
|
271
|
+
read: dictionaryToFont(dictionary: read, defaultFont: defaultFont, defaultColor: defaultColor)
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
func dictionaryToCellStyles(dictionary: [String : Any]?) -> CourierInboxCellStyle {
|
|
196
277
|
|
|
197
278
|
guard let dict = dictionary else {
|
|
198
|
-
return
|
|
279
|
+
return CourierInboxCellStyle()
|
|
199
280
|
}
|
|
200
281
|
|
|
201
282
|
let separatorStyle = dict["separatorStyle"] as? String
|
|
@@ -209,7 +290,7 @@ class CourierReactNativeView : UIView {
|
|
|
209
290
|
let bottom = insets?["bottom"] as? CGFloat
|
|
210
291
|
let separatorInsets = UIEdgeInsets(top: top ?? 0, left: left ?? 0, bottom: bottom ?? 0, right: right ?? 0)
|
|
211
292
|
|
|
212
|
-
return
|
|
293
|
+
return CourierInboxCellStyle(
|
|
213
294
|
separatorStyle: separatorStyle?.toSeparatorStyle() ?? .singleLine,
|
|
214
295
|
separatorInsets: separatorInsets,
|
|
215
296
|
separatorColor: separatorColor?.toColor(),
|