react-native-moengage-cards 5.1.0 → 6.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/ReactNativeMoEngageCards.podspec +2 -2
- package/android/build.gradle +7 -5
- package/android/src/main/java/com/moengage/react/cards/MoEngageCardsBridgeHandler.kt +4 -9
- package/package.json +1 -1
- package/src/internal/MoEngageCardHandler.ts +3 -3
- package/src/internal/utils/JsonToModelMapper.ts +21 -3
- package/src/internal/utils/ModelToJsonMapper.ts +15 -3
- package/src/model/CardInfo.ts +11 -1
- package/src/model/CardsData.ts +12 -1
- package/src/model/Widget.ts +11 -1
- package/src/model/enums/StaticImageType.ts +23 -0
|
@@ -14,12 +14,12 @@ Pod::Spec.new do |s|
|
|
|
14
14
|
s.homepage = "https://www.moengage.com"
|
|
15
15
|
s.license = package['license']
|
|
16
16
|
s.authors = "MoEngage Inc."
|
|
17
|
-
s.platforms = { :ios => "
|
|
17
|
+
s.platforms = { :ios => "13.0" }
|
|
18
18
|
s.source = {:file => './' }
|
|
19
19
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
20
20
|
s.public_header_files = 'ios/**/*.h'
|
|
21
21
|
s.dependency 'React'
|
|
22
|
-
s.dependency 'MoEngagePluginCards','
|
|
22
|
+
s.dependency 'MoEngagePluginCards','3.3.1'
|
|
23
23
|
s.dependency 'ReactNativeMoEngage'
|
|
24
24
|
s.module_map = false
|
|
25
25
|
|
package/android/build.gradle
CHANGED
|
@@ -16,9 +16,10 @@ buildscript {
|
|
|
16
16
|
|
|
17
17
|
ext {
|
|
18
18
|
//dependency version
|
|
19
|
-
moengageCoreVersion = "
|
|
20
|
-
moengageCardsCoreVersion = "
|
|
21
|
-
pluginBaseCardVersion = "
|
|
19
|
+
moengageCoreVersion = "14.03.00"
|
|
20
|
+
moengageCardsCoreVersion = "3.1.0"
|
|
21
|
+
pluginBaseCardVersion = "4.0.0"
|
|
22
|
+
pluginBaseVersion = "5.1.0"
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
apply plugin: 'com.android.library'
|
|
@@ -27,10 +28,10 @@ apply plugin: "org.jlleitschuh.gradle.ktlint"
|
|
|
27
28
|
apply plugin: 'com.facebook.react'
|
|
28
29
|
|
|
29
30
|
android {
|
|
30
|
-
compileSdk
|
|
31
|
+
compileSdk 35
|
|
31
32
|
namespace "com.moengage.react.cards"
|
|
32
33
|
defaultConfig {
|
|
33
|
-
minSdk
|
|
34
|
+
minSdk 23
|
|
34
35
|
versionCode 1
|
|
35
36
|
versionName "1.0"
|
|
36
37
|
|
|
@@ -80,6 +81,7 @@ dependencies {
|
|
|
80
81
|
compileOnly("com.moengage:moe-android-sdk:$moengageCoreVersion")
|
|
81
82
|
api("com.moengage:cards-core:$moengageCardsCoreVersion")
|
|
82
83
|
implementation("com.moengage:plugin-base-cards:$pluginBaseCardVersion")
|
|
84
|
+
compileOnly("com.moengage:plugin-base:$pluginBaseVersion")
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
def isNewArchitectureEnabled() {
|
|
@@ -19,7 +19,8 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
19
19
|
import com.moengage.core.LogLevel
|
|
20
20
|
import com.moengage.core.internal.logger.Logger
|
|
21
21
|
import com.moengage.plugin.base.cards.CardsPluginHelper
|
|
22
|
-
import com.moengage.plugin.base.cards.internal.
|
|
22
|
+
import com.moengage.plugin.base.cards.internal.cardDataToJson
|
|
23
|
+
import com.moengage.plugin.base.internal.instanceMetaFromJson
|
|
23
24
|
import com.moengage.plugin.base.cards.internal.setCardsEventEmitter
|
|
24
25
|
import org.json.JSONObject
|
|
25
26
|
|
|
@@ -181,14 +182,8 @@ internal class MoEngageCardsBridgeHandler(private val reactContext: ReactApplica
|
|
|
181
182
|
try {
|
|
182
183
|
Logger.print { "$tag fetchCards() : $payload" }
|
|
183
184
|
val accountMetaPayload = JSONObject(payload)
|
|
184
|
-
cardsPluginHelper.fetchCards(context, payload) {
|
|
185
|
-
|
|
186
|
-
response.put(ARGUMENT_ACCOUNT_META, accountMetaPayload)
|
|
187
|
-
val cardData = JSONObject()
|
|
188
|
-
cardData.put(ARGUMENT_CARDS, cardListToJson(cardsData?.cards ?: emptyList()))
|
|
189
|
-
response.put(ARGUMENT_DATA, cardData)
|
|
190
|
-
|
|
191
|
-
promise.resolve(response.toString())
|
|
185
|
+
cardsPluginHelper.fetchCards(context, payload) { cardData ->
|
|
186
|
+
promise.resolve(cardDataToJson(cardData, instanceMetaFromJson(JSONObject(payload))).toString())
|
|
192
187
|
}
|
|
193
188
|
} catch (t: Throwable) {
|
|
194
189
|
Logger.print(LogLevel.ERROR, t) { "$tag fetchCards() : " }
|
package/package.json
CHANGED
|
@@ -120,7 +120,7 @@ class MoEngageCardHandler {
|
|
|
120
120
|
return cardInfo;
|
|
121
121
|
} catch (error) {
|
|
122
122
|
MoEngageLogger.error(`${this.TAG} getCardsInfo() `, error);
|
|
123
|
-
return new CardInfo(false, [], []);
|
|
123
|
+
return new CardInfo(false, [], [], null);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -161,7 +161,7 @@ class MoEngageCardHandler {
|
|
|
161
161
|
return cardsData;
|
|
162
162
|
} catch (error) {
|
|
163
163
|
MoEngageLogger.error(`${this.TAG} getCardsForCategory() `, error);
|
|
164
|
-
return new CardsData(category, []);
|
|
164
|
+
return new CardsData(category, [], null);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -175,7 +175,7 @@ class MoEngageCardHandler {
|
|
|
175
175
|
return cardsData;
|
|
176
176
|
} catch (error) {
|
|
177
177
|
MoEngageLogger.error(`${this.TAG} fetchCards() `, error);
|
|
178
|
-
return new CardsData("", []);
|
|
178
|
+
return new CardsData("", [], null);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -81,6 +81,8 @@ import {
|
|
|
81
81
|
keyWidgets
|
|
82
82
|
} from "../Constants";
|
|
83
83
|
import { assertUnsupportedError, getEnumByName } from "../utils/Util";
|
|
84
|
+
import StaticImageType from "../../model/enums/StaticImageType";
|
|
85
|
+
import { MoEAccessibilityData, KEY_ACCESSIBILITY } from "react-native-moengage";
|
|
84
86
|
|
|
85
87
|
export function actionFromJson(json: { [k: string]: any }): Action {
|
|
86
88
|
const navigationType: ActionType = getEnumByName(ActionType, json[keyActionType] ?? "");
|
|
@@ -171,7 +173,8 @@ export function cardInfoFromJson(json: { [k: string]: any }): CardInfo {
|
|
|
171
173
|
Array.from((json[keyCards] ?? []) as Iterable<{ [k: string]: any }>)
|
|
172
174
|
.map((cardJson) => {
|
|
173
175
|
return cardFromJson(cardJson);
|
|
174
|
-
})
|
|
176
|
+
}),
|
|
177
|
+
staticImageFromJson(json[KEY_ACCESSIBILITY] ?? null),
|
|
175
178
|
);
|
|
176
179
|
}
|
|
177
180
|
|
|
@@ -181,7 +184,8 @@ export function cardsDataFromJson(json: { [k: string]: any }): CardsData {
|
|
|
181
184
|
Array.from((json[keyCards] ?? []) as Iterable<{ [k: string]: any }>)
|
|
182
185
|
.map((cardObject) => {
|
|
183
186
|
return cardFromJson(cardObject);
|
|
184
|
-
})
|
|
187
|
+
}),
|
|
188
|
+
staticImageFromJson(json[KEY_ACCESSIBILITY] ?? null),
|
|
185
189
|
);
|
|
186
190
|
}
|
|
187
191
|
|
|
@@ -262,6 +266,20 @@ export function widgetFromJson(json: { [k: string]: any }): Widget {
|
|
|
262
266
|
Array.from((json[keyActions] ?? []) as Iterable<{ [k: string]: any }>)
|
|
263
267
|
.map((action) => {
|
|
264
268
|
return actionFromJson(action);
|
|
265
|
-
})
|
|
269
|
+
}),
|
|
270
|
+
json[KEY_ACCESSIBILITY] != null ? MoEAccessibilityData.fromJson(json[KEY_ACCESSIBILITY]) : null,
|
|
266
271
|
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export function staticImageFromJson(json: { [k: string]: any } | null): { [key in StaticImageType]: MoEAccessibilityData } | null {
|
|
275
|
+
if (!json || Object.keys(json).length === 0) {
|
|
276
|
+
return null
|
|
277
|
+
}
|
|
278
|
+
const result: { [key in StaticImageType]?: MoEAccessibilityData } = {};
|
|
279
|
+
for (const type of Object.values(StaticImageType)) {
|
|
280
|
+
if (json[type]) {
|
|
281
|
+
result[type as StaticImageType] = MoEAccessibilityData.fromJson(json[type]);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return result as { [key in StaticImageType]: MoEAccessibilityData };
|
|
267
285
|
}
|
|
@@ -75,6 +75,8 @@ import {
|
|
|
75
75
|
keyWidgets
|
|
76
76
|
} from "../Constants";
|
|
77
77
|
import { assertUnsupportedError } from "../utils/Util";
|
|
78
|
+
import { KEY_ACCESSIBILITY, MoEAccessibilityData } from "react-native-moengage";
|
|
79
|
+
import StaticImageType from "../../model/enums/StaticImageType";
|
|
78
80
|
|
|
79
81
|
export function actionToJson(action: Action): { [k: string]: any } {
|
|
80
82
|
if (action instanceof NavigationAction) {
|
|
@@ -161,7 +163,8 @@ export function cardInfoToJson(cardInfo: CardInfo): { [k: string]: any } {
|
|
|
161
163
|
[keyCategories]: cardInfo.categories,
|
|
162
164
|
[keyCards]: cardInfo.cards.map((card) => {
|
|
163
165
|
return cardToJson(card);
|
|
164
|
-
})
|
|
166
|
+
}),
|
|
167
|
+
[KEY_ACCESSIBILITY]: staticImageAccessibilityDataToJson(cardInfo.staticImageAccessibilityData)
|
|
165
168
|
};
|
|
166
169
|
}
|
|
167
170
|
|
|
@@ -170,7 +173,8 @@ export function cardsDataToJson(cardsData: CardsData): { [k: string]: any } {
|
|
|
170
173
|
[keyCategory]: cardsData.category,
|
|
171
174
|
[keyCards]: cardsData.cards.map((card) => {
|
|
172
175
|
return cardToJson(card);
|
|
173
|
-
})
|
|
176
|
+
}),
|
|
177
|
+
[KEY_ACCESSIBILITY]: staticImageAccessibilityDataToJson(cardsData.staticImageAccessibilityData)
|
|
174
178
|
};
|
|
175
179
|
}
|
|
176
180
|
|
|
@@ -245,6 +249,14 @@ export function widgetToJson(widget: Widget): { [k: string]: any } {
|
|
|
245
249
|
[keyWidgetStyle]: widgetStyleToJson(widget.style),
|
|
246
250
|
[keyActions]: widget.actionList.map((action) => {
|
|
247
251
|
return actionToJson(action);
|
|
248
|
-
})
|
|
252
|
+
}),
|
|
253
|
+
[KEY_ACCESSIBILITY]: widget.accessibilityData?.toJson()
|
|
249
254
|
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export function staticImageAccessibilityDataToJson(staticImageAccessibilityData: { [key in StaticImageType]: MoEAccessibilityData } | null): { [key: string]: any } | null {
|
|
258
|
+
return staticImageAccessibilityData ?
|
|
259
|
+
Object.fromEntries(
|
|
260
|
+
Object.entries(staticImageAccessibilityData).map(([key, value]) => [key, value.toJson()])
|
|
261
|
+
) : null;
|
|
250
262
|
}
|
package/src/model/CardInfo.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import Card from "./Card";
|
|
2
|
+
import StaticImageType from "./enums/StaticImageType";
|
|
3
|
+
import { MoEAccessibilityData } from "react-native-moengage";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* All data for cards.
|
|
@@ -26,10 +28,18 @@ class CardInfo {
|
|
|
26
28
|
*/
|
|
27
29
|
cards: Array<Card>;
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Accessibility data for static images used in cards.
|
|
33
|
+
*
|
|
34
|
+
* @since 6.0.0
|
|
35
|
+
*/
|
|
36
|
+
staticImageAccessibilityData: { [key in StaticImageType]: MoEAccessibilityData } | null;
|
|
37
|
+
|
|
38
|
+
constructor(shouldShowAllTab: boolean, categories: Array<string>, cards: Array<Card>, staticImageAccessibilityData: { [key in StaticImageType]: MoEAccessibilityData } | null) {
|
|
30
39
|
this.shouldShowAllTab = shouldShowAllTab;
|
|
31
40
|
this.categories = categories;
|
|
32
41
|
this.cards = cards;
|
|
42
|
+
this.staticImageAccessibilityData = staticImageAccessibilityData;
|
|
33
43
|
}
|
|
34
44
|
}
|
|
35
45
|
|
package/src/model/CardsData.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import Card from "./Card";
|
|
2
|
+
import StaticImageType from "./enums/StaticImageType";
|
|
3
|
+
import { MoEAccessibilityData } from "react-native-moengage";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Data for cards
|
|
@@ -20,9 +22,18 @@ class CardsData {
|
|
|
20
22
|
*/
|
|
21
23
|
cards: Array<Card>;
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Accessibility data for static images used in cards.
|
|
27
|
+
*
|
|
28
|
+
* @since 6.0.0
|
|
29
|
+
*/
|
|
30
|
+
staticImageAccessibilityData: { [key in StaticImageType]: MoEAccessibilityData } | null;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
constructor(category: string, cards: Array<Card>, staticImageAccessibilityData: { [key in StaticImageType]: MoEAccessibilityData } | null) {
|
|
24
34
|
this.category = category;
|
|
25
35
|
this.cards = cards;
|
|
36
|
+
this.staticImageAccessibilityData = staticImageAccessibilityData;
|
|
26
37
|
}
|
|
27
38
|
}
|
|
28
39
|
|
package/src/model/Widget.ts
CHANGED
|
@@ -2,6 +2,7 @@ import Action from "./action/Action";
|
|
|
2
2
|
import WidgetType from "./enums/WidgetType";
|
|
3
3
|
import WidgetStyle from "./styles/WidgetStyle";
|
|
4
4
|
|
|
5
|
+
import { MoEAccessibilityData } from "react-native-moengage";
|
|
5
6
|
/**
|
|
6
7
|
* UI element in a card.
|
|
7
8
|
*
|
|
@@ -40,18 +41,27 @@ class Widget {
|
|
|
40
41
|
*/
|
|
41
42
|
actionList: Array<Action>;
|
|
42
43
|
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Accessibility data for the widget
|
|
47
|
+
* @since 6.0.0
|
|
48
|
+
*/
|
|
49
|
+
accessibilityData: MoEAccessibilityData | null;
|
|
50
|
+
|
|
43
51
|
constructor(
|
|
44
52
|
id: number,
|
|
45
53
|
widgetType: WidgetType,
|
|
46
54
|
content: string,
|
|
47
55
|
style: WidgetStyle | undefined,
|
|
48
|
-
actionList: Array<Action
|
|
56
|
+
actionList: Array<Action>,
|
|
57
|
+
accessibilityData: MoEAccessibilityData | null
|
|
49
58
|
) {
|
|
50
59
|
this.id = id;
|
|
51
60
|
this.widgetType = widgetType;
|
|
52
61
|
this.content = content;
|
|
53
62
|
this.style = style;
|
|
54
63
|
this.actionList = actionList;
|
|
64
|
+
this.accessibilityData = accessibilityData;
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
67
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing different types of static images used in the application.
|
|
3
|
+
*
|
|
4
|
+
* @since 6.0.0
|
|
5
|
+
*/
|
|
6
|
+
enum StaticImageType {
|
|
7
|
+
/**
|
|
8
|
+
* Image for No cards/Empty State
|
|
9
|
+
*/
|
|
10
|
+
EMPTY_STATE = "no_cards",
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Pin Card image
|
|
14
|
+
*/
|
|
15
|
+
PIN_CARD = "pinned_card",
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Place Holder image for card loading
|
|
19
|
+
*/
|
|
20
|
+
LOADING_PLACE_HOLDER = "place_holder",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default StaticImageType;
|