react-native-firework-sdk 1.2.5 → 1.2.8
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/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/fireworksdk/bridge/{reactnative/FWInitializationProvider.kt → FWInitializationProvider.kt} +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModel.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +2 -3
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +1 -0
- package/ios/Components/VideoFeed.swift +61 -22
- package/ios/Components/VideoFeedConfiguration.swift +10 -0
- package/ios/Components/VideoPlayerConfiguration.swift +2 -1
- package/ios/Models/RNToNative/RCTConvert+FireworkSDKModule.swift +22 -2
- package/ios/Modules/Shopping/CartViewController.swift +8 -3
- package/ios/Modules/Shopping/ShoppingModule.m +1 -1
- package/ios/Modules/Shopping/ShoppingModule.swift +12 -2
- package/lib/commonjs/VideoShopping.js +20 -9
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/VideoShopping.js +19 -9
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/VideoShopping.d.ts +10 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +23 -5
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +5 -1
- package/lib/typescript/modules/ShoppingModule.d.ts +1 -0
- package/package.json +1 -1
- package/react-native-firework-sdk.podspec +1 -1
- package/src/VideoShopping.ts +25 -3
- package/src/index.tsx +2 -0
- package/src/models/VideoFeedConfiguration.ts +24 -5
- package/src/models/VideoPlayerConfiguration.ts +5 -1
- package/src/modules/ShoppingModule.ts +1 -0
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
|
13
13
|
/>
|
|
14
14
|
<provider
|
|
15
|
-
android:authorities="
|
|
16
|
-
android:name=".
|
|
15
|
+
android:authorities="${applicationId}.fwBridgeProvider"
|
|
16
|
+
android:name="com.fireworksdk.bridge.FWInitializationProvider"
|
|
17
17
|
android:exported="false"
|
|
18
18
|
/>
|
|
19
19
|
<meta-data
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt
CHANGED
|
@@ -2,7 +2,7 @@ package com.fireworksdk.bridge.reactnative.module
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import com.facebook.react.bridge.*
|
|
5
|
-
import com.fireworksdk.bridge.
|
|
5
|
+
import com.fireworksdk.bridge.FWInitializationProvider
|
|
6
6
|
import com.fireworksdk.bridge.reactnative.models.FWNavigatorInterface
|
|
7
7
|
import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
8
8
|
import com.fireworksdk.bridge.utils.FWLogUtils
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt
CHANGED
|
@@ -11,7 +11,7 @@ import com.fireworksdk.bridge.utils.*
|
|
|
11
11
|
import org.json.JSONObject
|
|
12
12
|
import com.facebook.react.bridge.ReactMethod
|
|
13
13
|
import com.fireworksdk.bridge.models.FWAdBadgeConfigModel
|
|
14
|
-
import com.fireworksdk.bridge.
|
|
14
|
+
import com.fireworksdk.bridge.FWInitializationProvider
|
|
15
15
|
import com.fireworksdk.bridge.reactnative.models.FireworkSDKInterface
|
|
16
16
|
import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
|
|
17
17
|
import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
@@ -5,11 +5,10 @@ import com.facebook.react.bridge.*
|
|
|
5
5
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
6
6
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
7
7
|
import com.fireworksdk.bridge.models.*
|
|
8
|
-
import com.fireworksdk.bridge.
|
|
8
|
+
import com.fireworksdk.bridge.FWInitializationProvider
|
|
9
9
|
import com.fireworksdk.bridge.reactnative.module.FireworkSDKModule
|
|
10
10
|
import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
|
|
11
11
|
import com.fireworksdk.bridge.utils.FWDateUtils
|
|
12
|
-
import com.fireworksdk.bridge.utils.FWJsonUtils
|
|
13
12
|
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
14
13
|
import com.loopnow.fireworklibrary.data.Product
|
|
15
14
|
import java.util.*
|
|
@@ -20,7 +19,7 @@ object FWEventUtils {
|
|
|
20
19
|
FWLogUtils.d { "FWNavigatorModule pushNativeContainer: $props" }
|
|
21
20
|
val activity = FWInitializationProvider.INSTANCE.resumedActivity
|
|
22
21
|
|
|
23
|
-
if (activity == null) {
|
|
22
|
+
if (activity == null || FireworkSDKModule.appComponentName.isNullOrBlank()) {
|
|
24
23
|
promise?.resolve(false)
|
|
25
24
|
return
|
|
26
25
|
}
|
|
@@ -91,6 +91,7 @@ object FWVideoPlayerUtils {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
fun setVideoPlayerConfig(config: FWVideoPlayerConfigModel?) {
|
|
94
|
+
VideoPlayerProperties.branding = config?.showBranding != false
|
|
94
95
|
VideoPlayerProperties.share = config?.showShareButton != false
|
|
95
96
|
VideoPlayerProperties.loop = config?.videoCompleteAction != FWVideoPlayerConstant.FW_VIDEO_COMPLETE_ACTION_ADVANCE_TO_NEXT
|
|
96
97
|
// VideoPlayerProperties.autoPlayOnComplete = config?.videoCompleteAction != FWVideoPlayerConstant.FW_VIDEO_COMPLETE_ACTION_LOOP
|
|
@@ -12,21 +12,6 @@ import FireworkVideo
|
|
|
12
12
|
@objc
|
|
13
13
|
public enum VideoFeedMode: Int {
|
|
14
14
|
case row, colume, grid
|
|
15
|
-
|
|
16
|
-
fileprivate var videoFeedLayout: VideoFeedLayout {
|
|
17
|
-
switch self {
|
|
18
|
-
case .row:
|
|
19
|
-
return VideoFeedHorizontalLayout()
|
|
20
|
-
case .colume:
|
|
21
|
-
let layout = VideoFeedGridLayout()
|
|
22
|
-
layout.numberOfColumns = 1
|
|
23
|
-
return layout
|
|
24
|
-
case .grid:
|
|
25
|
-
let layout = VideoFeedGridLayout()
|
|
26
|
-
layout.numberOfColumns = 2
|
|
27
|
-
return layout
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
15
|
}
|
|
31
16
|
|
|
32
17
|
@objc
|
|
@@ -56,6 +41,7 @@ public class VideoFeed: UIView, VideoFeedViewControllerDelegate {
|
|
|
56
41
|
return
|
|
57
42
|
}
|
|
58
43
|
feedVC.viewConfiguration = convertToVideoFeedConentConfiguration()
|
|
44
|
+
feedVC.layout = videoFeedLayout
|
|
59
45
|
}
|
|
60
46
|
}
|
|
61
47
|
@objc public var playerViewConfig: VideoPlayerConfiguration? {
|
|
@@ -87,6 +73,55 @@ public class VideoFeed: UIView, VideoFeedViewControllerDelegate {
|
|
|
87
73
|
return .dynamicContent(channelID: channel, parameters: parameters ?? [:])
|
|
88
74
|
}
|
|
89
75
|
}
|
|
76
|
+
|
|
77
|
+
private var videoFeedLayout: VideoFeedLayout {
|
|
78
|
+
var resultLayout: VideoFeedLayout?
|
|
79
|
+
switch mode {
|
|
80
|
+
case .row:
|
|
81
|
+
let layout = VideoFeedHorizontalLayout()
|
|
82
|
+
resultLayout = layout
|
|
83
|
+
break
|
|
84
|
+
case .colume:
|
|
85
|
+
let layout = VideoFeedGridLayout()
|
|
86
|
+
layout.numberOfColumns = 1
|
|
87
|
+
resultLayout = layout
|
|
88
|
+
break
|
|
89
|
+
case .grid:
|
|
90
|
+
let layout = VideoFeedGridLayout()
|
|
91
|
+
layout.numberOfColumns = 2
|
|
92
|
+
resultLayout = layout
|
|
93
|
+
break
|
|
94
|
+
}
|
|
95
|
+
if let config = feedViewConfig {
|
|
96
|
+
if let aspectRatio = config.aspectRatio {
|
|
97
|
+
if let horizontalLayout = resultLayout as? VideoFeedHorizontalLayout {
|
|
98
|
+
horizontalLayout.itemWidthRatio = aspectRatio
|
|
99
|
+
} else if let gridLayout = resultLayout as? VideoFeedGridLayout {
|
|
100
|
+
gridLayout.itemWidthRatio = aspectRatio
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if let contentPadding = config.contentPadding {
|
|
104
|
+
if let top = contentPadding.top {
|
|
105
|
+
resultLayout?.contentInsets.top = top
|
|
106
|
+
}
|
|
107
|
+
if let right = contentPadding.right {
|
|
108
|
+
resultLayout?.contentInsets.right = right
|
|
109
|
+
}
|
|
110
|
+
if let bottom = contentPadding.bottom {
|
|
111
|
+
resultLayout?.contentInsets.bottom = bottom
|
|
112
|
+
}
|
|
113
|
+
if let left = contentPadding.left {
|
|
114
|
+
resultLayout?.contentInsets.left = left
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if let itemSpacing = config.itemSpacing {
|
|
119
|
+
resultLayout?.itemSpacing = itemSpacing
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return resultLayout ?? VideoFeedHorizontalLayout()
|
|
124
|
+
}
|
|
90
125
|
|
|
91
126
|
public override func layoutSubviews() {
|
|
92
127
|
super.layoutSubviews()
|
|
@@ -103,7 +138,7 @@ public class VideoFeed: UIView, VideoFeedViewControllerDelegate {
|
|
|
103
138
|
}
|
|
104
139
|
|
|
105
140
|
let feedVC = VideoFeedViewController(
|
|
106
|
-
layout:
|
|
141
|
+
layout: videoFeedLayout,
|
|
107
142
|
source: source
|
|
108
143
|
)
|
|
109
144
|
|
|
@@ -265,13 +300,13 @@ extension VideoFeed {
|
|
|
265
300
|
}
|
|
266
301
|
if let ctaButtonStyle = config.ctaButtonStyle {
|
|
267
302
|
if let backgroundColor = ctaButtonStyle.backgroundColor {
|
|
268
|
-
vpcConfig.ctaButton.backgroundColor = backgroundColor.uicolor()
|
|
303
|
+
vpcConfig.ctaButton.contentConfiguration.backgroundColor = backgroundColor.uicolor()
|
|
269
304
|
}
|
|
270
305
|
if let textcolor = ctaButtonStyle.textColor {
|
|
271
|
-
vpcConfig.ctaButton.textColor = textcolor.uicolor()
|
|
306
|
+
vpcConfig.ctaButton.contentConfiguration.textColor = textcolor.uicolor()
|
|
272
307
|
}
|
|
273
308
|
if let fontSize = ctaButtonStyle.fontSize {
|
|
274
|
-
vpcConfig.ctaButton.font = UIFont.systemFont(ofSize: CGFloat(fontSize))
|
|
309
|
+
vpcConfig.ctaButton.contentConfiguration.font = UIFont.systemFont(ofSize: CGFloat(fontSize))
|
|
275
310
|
}
|
|
276
311
|
}
|
|
277
312
|
if let showPlaybackButton = config.showPlaybackButton {
|
|
@@ -279,9 +314,13 @@ extension VideoFeed {
|
|
|
279
314
|
}
|
|
280
315
|
if let showMuteButton = config.showMuteButton {
|
|
281
316
|
vpcConfig.muteButton.isHidden = !showMuteButton
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
317
|
+
}
|
|
318
|
+
if let launchBehavior = config.launchBehavior {
|
|
319
|
+
vpcConfig.onFirstLaunch = launchBehavior.behavior()
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if let showBranding = config.showBranding {
|
|
323
|
+
vpcConfig.videoDetail.fireworkAttribution.isHidden = !showBranding
|
|
285
324
|
}
|
|
286
325
|
|
|
287
326
|
return vpcConfig
|
|
@@ -16,6 +16,9 @@ public class VideoFeedConfiguration: NSObject, Codable {
|
|
|
16
16
|
var playIcon: VideoFeedPlayIconConfiguration?
|
|
17
17
|
var showSponsored: Bool?
|
|
18
18
|
var showAdBadge: Bool?
|
|
19
|
+
var aspectRatio: Double?
|
|
20
|
+
var contentPadding: VideoFeedContentPadding?;
|
|
21
|
+
var itemSpacing: Double?
|
|
19
22
|
|
|
20
23
|
class VideoFeedTitleConfiguration: NSObject, Codable {
|
|
21
24
|
public var hidden: Bool?
|
|
@@ -27,6 +30,13 @@ public class VideoFeedConfiguration: NSObject, Codable {
|
|
|
27
30
|
public var hidden: Bool?
|
|
28
31
|
public var iconWidth: Int?
|
|
29
32
|
}
|
|
33
|
+
|
|
34
|
+
class VideoFeedContentPadding: NSObject, Codable {
|
|
35
|
+
public var top: Double?
|
|
36
|
+
public var right: Double?
|
|
37
|
+
public var bottom: Double?
|
|
38
|
+
public var left: Double?
|
|
39
|
+
}
|
|
30
40
|
|
|
31
41
|
enum VideoFeedTitlePosition: String, Codable {
|
|
32
42
|
case stacked, nested
|
|
@@ -16,7 +16,8 @@ public class VideoPlayerConfiguration: NSObject, Codable {
|
|
|
16
16
|
var showPlaybackButton: Bool?
|
|
17
17
|
var showMuteButton: Bool?
|
|
18
18
|
var launchBehavior: VideoLaunchBehavior?
|
|
19
|
-
|
|
19
|
+
var showBranding: Bool?
|
|
20
|
+
|
|
20
21
|
public enum VideoPlayerStyle: String, Codable {
|
|
21
22
|
case full, fit
|
|
22
23
|
}
|
|
@@ -16,14 +16,34 @@ extension RCTConvert {
|
|
|
16
16
|
if let style = videoPlayerStyle(config["playerStyle"] as? String) {
|
|
17
17
|
finalConfig.playerStyle = style
|
|
18
18
|
}
|
|
19
|
+
|
|
19
20
|
if let action = videoCompleteAction(config["videoCompleteAction"] as? String) {
|
|
20
21
|
finalConfig.videoCompleteAction = action
|
|
21
22
|
}
|
|
23
|
+
|
|
22
24
|
if let showShareButton = config["showShareButton"] as? Bool {
|
|
23
|
-
finalConfig.shareButton.isHidden = showShareButton
|
|
25
|
+
finalConfig.shareButton.isHidden = !showShareButton
|
|
24
26
|
}
|
|
27
|
+
|
|
25
28
|
if let ctaStyle = ctaButtonStyle(config["ctaButtonStyle"] as? Dictionary) {
|
|
26
|
-
finalConfig.ctaButton = ctaStyle
|
|
29
|
+
finalConfig.ctaButton.contentConfiguration = ctaStyle
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if let showPlaybackButton = config["showPlaybackButton"] as? Bool {
|
|
33
|
+
finalConfig.playbackButton.isHidden = !showPlaybackButton
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if let showMuteButton = config["showMuteButton"] as? Bool {
|
|
37
|
+
finalConfig.muteButton.isHidden = !showMuteButton
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if let launchBehaviorString = config["launchBehavior"] as? String,
|
|
41
|
+
let launchBehavior = VideoPlayerConfiguration.VideoLaunchBehavior(rawValue: launchBehaviorString) {
|
|
42
|
+
finalConfig.onFirstLaunch = launchBehavior.behavior()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if let showBranding = config["showBranding"] as? Bool {
|
|
46
|
+
finalConfig.videoDetail.fireworkAttribution.isHidden = !showBranding
|
|
27
47
|
}
|
|
28
48
|
|
|
29
49
|
return finalConfig
|
|
@@ -81,15 +81,20 @@ class CartViewController: UIViewController, CartViewRepresentable {
|
|
|
81
81
|
indicator.centerYAnchor.constraint(equalTo: view.centerYAnchor)
|
|
82
82
|
])
|
|
83
83
|
|
|
84
|
-
indicator.startAnimating()
|
|
84
|
+
// indicator.startAnimating()
|
|
85
85
|
|
|
86
86
|
self.indicator = indicator
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
private func directShowCustomCartView() {
|
|
90
90
|
indicator?.stopAnimating()
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
guard let appComponentName = gAppComponentName else {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
let rctRootView = RCTRootView.init(
|
|
95
|
+
bridge: RCTBridge.current(),
|
|
96
|
+
moduleName: appComponentName,
|
|
97
|
+
initialProperties: properties)
|
|
93
98
|
view.addSubview(rctRootView)
|
|
94
99
|
rctRootView.translatesAutoresizingMaskIntoConstraints = false
|
|
95
100
|
|
|
@@ -16,5 +16,5 @@ RCT_EXTERN_METHOD(updateVideoProducts:(NSArray *)products cbId:(nonnull NSNumber
|
|
|
16
16
|
RCT_EXTERN_METHOD(updateProductViewConfig:(NSDictionary *)config cbId:(nonnull NSNumber *)cbid)
|
|
17
17
|
RCT_EXTERN_METHOD(updateAddToCartStatus:(NSString *)res tips:(nullable NSString *)tips cbId:(nonnull NSNumber *)cbid)
|
|
18
18
|
RCT_EXTERN_METHOD(jumpToCartPage:(nonnull NSNumber *)cbid props:(NSDictionary *)props)
|
|
19
|
-
|
|
19
|
+
RCT_EXTERN_METHOD(setCustomClickCartIconEnabled:(BOOL)enabled resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
20
20
|
@end
|
|
@@ -19,6 +19,7 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
19
19
|
private var cartViewController: CartViewController?
|
|
20
20
|
private var cartIconVisible = true
|
|
21
21
|
private var itemCounts = 0
|
|
22
|
+
private var customClickCartIconEnabled = false
|
|
22
23
|
|
|
23
24
|
override func supportedEvents() -> [String]! {
|
|
24
25
|
ShoppingEventName.allCases.map { $0.rawValue }
|
|
@@ -124,6 +125,12 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
124
125
|
NotificationCenter.default.post(noti)
|
|
125
126
|
}
|
|
126
127
|
}
|
|
128
|
+
|
|
129
|
+
@objc
|
|
130
|
+
func setCustomClickCartIconEnabled(_ enabled: Bool, resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) {
|
|
131
|
+
customClickCartIconEnabled = enabled
|
|
132
|
+
resolver([:])
|
|
133
|
+
}
|
|
127
134
|
|
|
128
135
|
// MARK: - FireworkVideoShoppingDelegate
|
|
129
136
|
func fireworkShopping(_ fireworkShopping: FireworkVideoShopping, willDisplayProductInfo productInfoViewConfigurator: ProductInfoViewConfigurable, forVideo video: VideoDetails) {
|
|
@@ -152,8 +159,11 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
152
159
|
let callbackId = ShoppingModule.generateCallbackId()
|
|
153
160
|
sendEvent(withName: ShoppingEventName.ClickCartIcon.rawValue, body: ["callbackId": callbackId])
|
|
154
161
|
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
let cartVC = CartViewController(callbackId: callbackId)
|
|
163
|
+
if !customClickCartIconEnabled {
|
|
164
|
+
gCartViewController = cartVC
|
|
165
|
+
}
|
|
166
|
+
return cartVC
|
|
157
167
|
}
|
|
158
168
|
}
|
|
159
169
|
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
8
10
|
var _FWEventName = require("./models/FWEventName");
|
|
9
11
|
|
|
10
12
|
var _ShoppingModule = _interopRequireWildcard(require("./modules/ShoppingModule"));
|
|
@@ -28,20 +30,25 @@ class VideoShopping {
|
|
|
28
30
|
/**
|
|
29
31
|
* This callback is triggered when the user clicks the shopping cart icon.
|
|
30
32
|
*
|
|
31
|
-
* The host app can return
|
|
33
|
+
* The host app can return NewNativeContainerProps object and we will push a new native container with the props.
|
|
32
34
|
*/
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
|
-
* This callback is triggered when the
|
|
37
|
+
* This callback is triggered when the user clicks the shopping cart icon.
|
|
36
38
|
*
|
|
37
|
-
* The host app can
|
|
39
|
+
* The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.
|
|
38
40
|
*/
|
|
41
|
+
get onCustomClickCartIcon() {
|
|
42
|
+
return this._onCustomClickCartIcon;
|
|
43
|
+
}
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
set onCustomClickCartIcon(value) {
|
|
46
|
+
this._onCustomClickCartIcon = value;
|
|
47
|
+
|
|
48
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
49
|
+
_ShoppingModule.default.setCustomClickCartIconEnabled(!!value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
45
52
|
|
|
46
53
|
/**
|
|
47
54
|
* Defaults to true. You can hide the cart icon by setting this property to false.
|
|
@@ -73,6 +80,8 @@ class VideoShopping {
|
|
|
73
80
|
|
|
74
81
|
_defineProperty(this, "onClickCartIcon", void 0);
|
|
75
82
|
|
|
83
|
+
_defineProperty(this, "_onCustomClickCartIcon", void 0);
|
|
84
|
+
|
|
76
85
|
_defineProperty(this, "onUpdateProductDetails", void 0);
|
|
77
86
|
|
|
78
87
|
_defineProperty(this, "onWillDisplayProduct", void 0);
|
|
@@ -115,7 +124,9 @@ class VideoShopping {
|
|
|
115
124
|
}
|
|
116
125
|
|
|
117
126
|
async handleClickCartIconEvent(event) {
|
|
118
|
-
if (this.
|
|
127
|
+
if (this.onCustomClickCartIcon) {
|
|
128
|
+
this.onCustomClickCartIcon();
|
|
129
|
+
} else if (this.onClickCartIcon) {
|
|
119
130
|
const callbackId = event.callbackId;
|
|
120
131
|
delete event.callbackId;
|
|
121
132
|
const props = await this.onClickCartIcon();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VideoShopping.ts"],"names":["VideoShopping","
|
|
1
|
+
{"version":3,"sources":["VideoShopping.ts"],"names":["VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","Platform","OS","ShoppingModule","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","eventEmitter","ShoppingModuleEventEmitter","getInstance","_instance","constructor","addListener","FWEventName","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","setCartItemCount","count","onAddToCart","callbackId","result","updateAddToCartStatus","res","tips","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","updateVideoProducts","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":"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","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport type {\n AddToCartEvent,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport { FWEventName } from './models/FWEventName';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n NewNativeContainerProps | undefined | null\n>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type WillDisplayProductCallback = (\n event: WillDisplayProductEvent\n) => Promise<ProductInfoViewConfiguration | undefined | null>;\n\ntype CallbackInfo = { callbackId?: number | string };\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host app can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\n */\n public onAddToCart?: AddToCartCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can return NewNativeContainerProps object and we will push a new native container with the props.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.\n */\n public get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined {\n return this._onCustomClickCartIcon;\n }\n public set onCustomClickCartIcon(\n value: CustomClickCartIconCallback | undefined\n ) {\n this._onCustomClickCartIcon = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setCustomClickCartIconEnabled(!!value);\n }\n }\n private _onCustomClickCartIcon?: CustomClickCartIconCallback | undefined;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product list to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * This callback is triggered when the product will be shown.\n *\n * The host app can return a ProductInfoViewConfiguration object to configure \"Add to cart\" button style and cart icon style.\n */\n public onWillDisplayProduct?: WillDisplayProductCallback;\n\n /**\n * Defaults to true. You can hide the cart icon by setting this property to false.\n */\n public get cartIconVisible(): boolean {\n return this._cartIconVisible;\n }\n public set cartIconVisible(value: boolean) {\n this._cartIconVisible = value;\n ShoppingModule.setCartIconVisible(value);\n }\n private _cartIconVisible: boolean = true;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\n\n public static getInstance() {\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n this.handleWillDisplayProductEvent(event);\n });\n }\n\n /**\n *\n * @param {number} count The number of items in the host app cart\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {\n if (this.onAddToCart) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId!\n );\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n if (this.onUpdateProductDetails) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n if (productList) {\n ShoppingModule.updateVideoProducts(productList, callbackId!);\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config) {\n ShoppingModule.updateProductViewConfig(config, callbackId!);\n }\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["FireworkSDK"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAQA;;AACA;;AAKA;;AAgBA;;AAEA;;
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["FireworkSDK"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAQA;;AACA;;AAKA;;AAgBA;;AAEA;;AAkBA;;AAcA;;;;eAEeA,oB","sourcesContent":["import type { IVideoFeedProps, VideoFeedMode } from './components/VideoFeed';\nimport VideoFeed from './components/VideoFeed';\nimport type {\n CustomCTAClickCallback,\n CustomCTALinkContentRender,\n SDKInitCallback,\n VideoFeedClickCallback,\n VideoPlaybackCallback,\n} from './FireworkSDK';\nimport FireworkSDK from './FireworkSDK';\nimport FWNavigator from './FWNavigator';\nimport type {\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n} from './LiveStream';\nimport LiveStream from './LiveStream';\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport type { AdBadgeTextType } from './models/AdBadgeConfiguration';\nimport type AddToCartResult from './models/AddToCartResult';\nimport type FeedItemDetails from './models/FeedItemDetails';\nimport type FWError from './models/FWError';\nimport type {\n AddToCartEvent,\n CustomCTAClickEvent,\n LiveStreamChatEvent,\n LiveStreamEvent,\n SDKInitEvent,\n UpdateProductDetailsEvent,\n VideoPlaybackEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport LiveStreamChatEventName from './models/LiveStreamChatEventName';\nimport type LiveStreamEventDetails from './models/LiveStreamEventDetails';\nimport LiveStreamEventName from './models/LiveStreamEventName';\nimport type LiveStreamMessageDetails from './models/LiveStreamMessageDetails';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport type { AddToCartButtonConfiguration } from './models/ProductInfoViewConfiguration';\nimport type ProductUnit from './models/ProductUnit';\nimport type { ProductPrice } from './models/ProductUnit';\nimport type VideoFeedConfiguration from './models/VideoFeedConfiguration';\nimport type {\n VideoFeedContentPadding,\n VideoFeedPlayIconConfiguration,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n} from './models/VideoFeedConfiguration';\nimport type { VideoFeedSource } from './models/VideoFeedSource';\nimport type VideoPlaybackDetails from './models/VideoPlaybackDetails';\nimport type { VideoPlayerSize } from './models/VideoPlaybackDetails';\nimport VideoPlaybackEventName from './models/VideoPlaybackEventName';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport type {\n VideoLaunchBehavior,\n VideoPlayerCompleteAction,\n VideoPlayerCTAStyle,\n VideoPlayerStyle,\n} from './models/VideoPlayerConfiguration';\nimport type {\n AddToCartCallback,\n ClickCartIconCallback,\n UpdateProductDetailsCallback,\n WillDisplayProductCallback,\n} from './VideoShopping';\nimport VideoShopping from './VideoShopping';\n\nexport default FireworkSDK;\n\nexport {\n AdBadgeConfiguration,\n AdBadgeTextType,\n AddToCartButtonConfiguration,\n AddToCartCallback,\n AddToCartEvent,\n AddToCartResult,\n ClickCartIconCallback,\n CustomCTAClickCallback,\n CustomCTAClickEvent,\n CustomCTALinkContentRender,\n FeedItemDetails,\n FWError,\n FWNavigator,\n IVideoFeedProps,\n LiveStream,\n LiveStreamChatEvent,\n LiveStreamChatEventName,\n LiveStreamEvent,\n LiveStreamEventDetails,\n LiveStreamEventName,\n LiveStreamMessageDetails,\n NewNativeContainerProps,\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n Product,\n ProductInfoViewConfiguration,\n ProductPrice,\n ProductUnit,\n SDKInitCallback,\n SDKInitEvent,\n UpdateProductDetailsCallback,\n UpdateProductDetailsEvent,\n VideoFeed,\n VideoFeedClickCallback,\n VideoFeedConfiguration,\n VideoFeedContentPadding,\n VideoFeedMode,\n VideoFeedPlayIconConfiguration,\n VideoFeedSource,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n VideoLaunchBehavior,\n VideoPlaybackCallback,\n VideoPlaybackDetails,\n VideoPlaybackEvent,\n VideoPlaybackEventName,\n VideoPlayerCompleteAction,\n VideoPlayerConfiguration,\n VideoPlayerCTAStyle,\n VideoPlayerSize,\n VideoPlayerStyle,\n VideoShopping,\n WillDisplayProductCallback,\n WillDisplayProductEvent,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ShoppingModule.ts"],"names":["ShoppingModule","NativeModules","Proxy","get","Error","LINKING_ERROR","ShoppingModuleEventEmitter","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA,MAAMA,cAAc,GAAGC,2BAAcD,cAAd,GACnBC,2BAAcD,cADK,GAEnB,IAAIE,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUC,6BAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;
|
|
1
|
+
{"version":3,"sources":["ShoppingModule.ts"],"names":["ShoppingModule","NativeModules","Proxy","get","Error","LINKING_ERROR","ShoppingModuleEventEmitter","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA,MAAMA,cAAc,GAAGC,2BAAcD,cAAd,GACnBC,2BAAcD,cADK,GAEnB,IAAIE,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUC,6BAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAgCA,MAAMC,0BAA0B,GAAG,IAAIC,+BAAJ,CAAuBP,cAAvB,CAAnC;;eAGeA,c","sourcesContent":["import { NativeEventEmitter, NativeModule, NativeModules } from 'react-native';\nimport type Product from '../models/Product';\nimport type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\nimport type { NewNativeContainerProps } from 'src/models/NewNativeContainerProps';\n\nconst ShoppingModule = NativeModules.ShoppingModule\n ? NativeModules.ShoppingModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\ninterface IShoppingModule extends NativeModule {\n init(): void;\n updateVideoProducts(products: Product[], callbackId: number | string): void;\n updateProductViewConfig(\n config: ProductInfoViewConfiguration,\n callbackId: number | string\n ): void;\n updateAddToCartStatus(\n res: string,\n tips: string,\n callbackId: number | string\n ): void;\n jumpToCartPage(\n callbackId: number | string,\n props: NewNativeContainerProps\n ): void;\n setCartIconVisible(visible: boolean): void;\n setCartItemCount(count: number): void;\n setCustomClickCartIconEnabled(enabled: boolean): Promise<void>; // Only supported on iOS\n}\n\nconst ShoppingModuleEventEmitter = new NativeEventEmitter(ShoppingModule);\nexport { ShoppingModuleEventEmitter };\n\nexport default ShoppingModule as IShoppingModule;\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
2
|
|
|
3
|
+
import { Platform } from 'react-native';
|
|
3
4
|
import { FWEventName } from './models/FWEventName';
|
|
4
5
|
import ShoppingModule, { ShoppingModuleEventEmitter } from './modules/ShoppingModule';
|
|
5
6
|
|
|
@@ -16,20 +17,25 @@ class VideoShopping {
|
|
|
16
17
|
/**
|
|
17
18
|
* This callback is triggered when the user clicks the shopping cart icon.
|
|
18
19
|
*
|
|
19
|
-
* The host app can return
|
|
20
|
+
* The host app can return NewNativeContainerProps object and we will push a new native container with the props.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
* This callback is triggered when the
|
|
24
|
+
* This callback is triggered when the user clicks the shopping cart icon.
|
|
24
25
|
*
|
|
25
|
-
* The host app can
|
|
26
|
+
* The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.
|
|
26
27
|
*/
|
|
28
|
+
get onCustomClickCartIcon() {
|
|
29
|
+
return this._onCustomClickCartIcon;
|
|
30
|
+
}
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
set onCustomClickCartIcon(value) {
|
|
33
|
+
this._onCustomClickCartIcon = value;
|
|
34
|
+
|
|
35
|
+
if (Platform.OS === 'ios') {
|
|
36
|
+
ShoppingModule.setCustomClickCartIconEnabled(!!value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
33
39
|
|
|
34
40
|
/**
|
|
35
41
|
* Defaults to true. You can hide the cart icon by setting this property to false.
|
|
@@ -60,6 +66,8 @@ class VideoShopping {
|
|
|
60
66
|
|
|
61
67
|
_defineProperty(this, "onClickCartIcon", void 0);
|
|
62
68
|
|
|
69
|
+
_defineProperty(this, "_onCustomClickCartIcon", void 0);
|
|
70
|
+
|
|
63
71
|
_defineProperty(this, "onUpdateProductDetails", void 0);
|
|
64
72
|
|
|
65
73
|
_defineProperty(this, "onWillDisplayProduct", void 0);
|
|
@@ -102,7 +110,9 @@ class VideoShopping {
|
|
|
102
110
|
}
|
|
103
111
|
|
|
104
112
|
async handleClickCartIconEvent(event) {
|
|
105
|
-
if (this.
|
|
113
|
+
if (this.onCustomClickCartIcon) {
|
|
114
|
+
this.onCustomClickCartIcon();
|
|
115
|
+
} else if (this.onClickCartIcon) {
|
|
106
116
|
const callbackId = event.callbackId;
|
|
107
117
|
delete event.callbackId;
|
|
108
118
|
const props = await this.onClickCartIcon();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VideoShopping.ts"],"names":["FWEventName","ShoppingModule","ShoppingModuleEventEmitter","VideoShopping","
|
|
1
|
+
{"version":3,"sources":["VideoShopping.ts"],"names":["Platform","FWEventName","ShoppingModule","ShoppingModuleEventEmitter","VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","OS","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","eventEmitter","getInstance","_instance","constructor","addListener","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","setCartItemCount","count","onAddToCart","callbackId","result","updateAddToCartStatus","res","tips","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","updateVideoProducts","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":"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","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport type {\n AddToCartEvent,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport { FWEventName } from './models/FWEventName';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n NewNativeContainerProps | undefined | null\n>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type WillDisplayProductCallback = (\n event: WillDisplayProductEvent\n) => Promise<ProductInfoViewConfiguration | undefined | null>;\n\ntype CallbackInfo = { callbackId?: number | string };\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host app can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\n */\n public onAddToCart?: AddToCartCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can return NewNativeContainerProps object and we will push a new native container with the props.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.\n */\n public get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined {\n return this._onCustomClickCartIcon;\n }\n public set onCustomClickCartIcon(\n value: CustomClickCartIconCallback | undefined\n ) {\n this._onCustomClickCartIcon = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setCustomClickCartIconEnabled(!!value);\n }\n }\n private _onCustomClickCartIcon?: CustomClickCartIconCallback | undefined;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product list to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * This callback is triggered when the product will be shown.\n *\n * The host app can return a ProductInfoViewConfiguration object to configure \"Add to cart\" button style and cart icon style.\n */\n public onWillDisplayProduct?: WillDisplayProductCallback;\n\n /**\n * Defaults to true. You can hide the cart icon by setting this property to false.\n */\n public get cartIconVisible(): boolean {\n return this._cartIconVisible;\n }\n public set cartIconVisible(value: boolean) {\n this._cartIconVisible = value;\n ShoppingModule.setCartIconVisible(value);\n }\n private _cartIconVisible: boolean = true;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\n\n public static getInstance() {\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n this.handleWillDisplayProductEvent(event);\n });\n }\n\n /**\n *\n * @param {number} count The number of items in the host app cart\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {\n if (this.onAddToCart) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId!\n );\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n if (this.onUpdateProductDetails) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n if (productList) {\n ShoppingModule.updateVideoProducts(productList, callbackId!);\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config) {\n ShoppingModule.updateProductViewConfig(config, callbackId!);\n }\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["VideoFeed","FireworkSDK","FWNavigator","LiveStream","LiveStreamChatEventName","LiveStreamEventName","VideoPlaybackEventName","VideoShopping"],"mappings":"AACA,OAAOA,SAAP,MAAsB,wBAAtB;AAQA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AAKA,OAAOC,UAAP,MAAuB,cAAvB;AAgBA,OAAOC,uBAAP,MAAoC,kCAApC;AAEA,OAAOC,mBAAP,MAAgC,8BAAhC;
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["VideoFeed","FireworkSDK","FWNavigator","LiveStream","LiveStreamChatEventName","LiveStreamEventName","VideoPlaybackEventName","VideoShopping"],"mappings":"AACA,OAAOA,SAAP,MAAsB,wBAAtB;AAQA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AAKA,OAAOC,UAAP,MAAuB,cAAvB;AAgBA,OAAOC,uBAAP,MAAoC,kCAApC;AAEA,OAAOC,mBAAP,MAAgC,8BAAhC;AAkBA,OAAOC,sBAAP,MAAmC,iCAAnC;AAcA,OAAOC,aAAP,MAA0B,iBAA1B;AAEA,eAAeN,WAAf;AAEA,SAaEC,WAbF,EAeEC,UAfF,EAiBEC,uBAjBF,EAoBEC,mBApBF,EAiCEL,SAjCF,EA8CEM,sBA9CF,EAoDEC,aApDF","sourcesContent":["import type { IVideoFeedProps, VideoFeedMode } from './components/VideoFeed';\nimport VideoFeed from './components/VideoFeed';\nimport type {\n CustomCTAClickCallback,\n CustomCTALinkContentRender,\n SDKInitCallback,\n VideoFeedClickCallback,\n VideoPlaybackCallback,\n} from './FireworkSDK';\nimport FireworkSDK from './FireworkSDK';\nimport FWNavigator from './FWNavigator';\nimport type {\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n} from './LiveStream';\nimport LiveStream from './LiveStream';\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport type { AdBadgeTextType } from './models/AdBadgeConfiguration';\nimport type AddToCartResult from './models/AddToCartResult';\nimport type FeedItemDetails from './models/FeedItemDetails';\nimport type FWError from './models/FWError';\nimport type {\n AddToCartEvent,\n CustomCTAClickEvent,\n LiveStreamChatEvent,\n LiveStreamEvent,\n SDKInitEvent,\n UpdateProductDetailsEvent,\n VideoPlaybackEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport LiveStreamChatEventName from './models/LiveStreamChatEventName';\nimport type LiveStreamEventDetails from './models/LiveStreamEventDetails';\nimport LiveStreamEventName from './models/LiveStreamEventName';\nimport type LiveStreamMessageDetails from './models/LiveStreamMessageDetails';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport type { AddToCartButtonConfiguration } from './models/ProductInfoViewConfiguration';\nimport type ProductUnit from './models/ProductUnit';\nimport type { ProductPrice } from './models/ProductUnit';\nimport type VideoFeedConfiguration from './models/VideoFeedConfiguration';\nimport type {\n VideoFeedContentPadding,\n VideoFeedPlayIconConfiguration,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n} from './models/VideoFeedConfiguration';\nimport type { VideoFeedSource } from './models/VideoFeedSource';\nimport type VideoPlaybackDetails from './models/VideoPlaybackDetails';\nimport type { VideoPlayerSize } from './models/VideoPlaybackDetails';\nimport VideoPlaybackEventName from './models/VideoPlaybackEventName';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport type {\n VideoLaunchBehavior,\n VideoPlayerCompleteAction,\n VideoPlayerCTAStyle,\n VideoPlayerStyle,\n} from './models/VideoPlayerConfiguration';\nimport type {\n AddToCartCallback,\n ClickCartIconCallback,\n UpdateProductDetailsCallback,\n WillDisplayProductCallback,\n} from './VideoShopping';\nimport VideoShopping from './VideoShopping';\n\nexport default FireworkSDK;\n\nexport {\n AdBadgeConfiguration,\n AdBadgeTextType,\n AddToCartButtonConfiguration,\n AddToCartCallback,\n AddToCartEvent,\n AddToCartResult,\n ClickCartIconCallback,\n CustomCTAClickCallback,\n CustomCTAClickEvent,\n CustomCTALinkContentRender,\n FeedItemDetails,\n FWError,\n FWNavigator,\n IVideoFeedProps,\n LiveStream,\n LiveStreamChatEvent,\n LiveStreamChatEventName,\n LiveStreamEvent,\n LiveStreamEventDetails,\n LiveStreamEventName,\n LiveStreamMessageDetails,\n NewNativeContainerProps,\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n Product,\n ProductInfoViewConfiguration,\n ProductPrice,\n ProductUnit,\n SDKInitCallback,\n SDKInitEvent,\n UpdateProductDetailsCallback,\n UpdateProductDetailsEvent,\n VideoFeed,\n VideoFeedClickCallback,\n VideoFeedConfiguration,\n VideoFeedContentPadding,\n VideoFeedMode,\n VideoFeedPlayIconConfiguration,\n VideoFeedSource,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n VideoLaunchBehavior,\n VideoPlaybackCallback,\n VideoPlaybackDetails,\n VideoPlaybackEvent,\n VideoPlaybackEventName,\n VideoPlayerCompleteAction,\n VideoPlayerConfiguration,\n VideoPlayerCTAStyle,\n VideoPlayerSize,\n VideoPlayerStyle,\n VideoShopping,\n WillDisplayProductCallback,\n WillDisplayProductEvent,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ShoppingModule.ts"],"names":["NativeEventEmitter","NativeModules","LINKING_ERROR","ShoppingModule","Proxy","get","Error","ShoppingModuleEventEmitter"],"mappings":"AAAA,SAASA,kBAAT,EAA2CC,aAA3C,QAAgE,cAAhE;AAGA,SAASC,aAAT,QAA8B,6BAA9B;AAGA,MAAMC,cAAc,GAAGF,aAAa,CAACE,cAAd,GACnBF,aAAa,CAACE,cADK,GAEnB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUJ,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;
|
|
1
|
+
{"version":3,"sources":["ShoppingModule.ts"],"names":["NativeEventEmitter","NativeModules","LINKING_ERROR","ShoppingModule","Proxy","get","Error","ShoppingModuleEventEmitter"],"mappings":"AAAA,SAASA,kBAAT,EAA2CC,aAA3C,QAAgE,cAAhE;AAGA,SAASC,aAAT,QAA8B,6BAA9B;AAGA,MAAMC,cAAc,GAAGF,aAAa,CAACE,cAAd,GACnBF,aAAa,CAACE,cADK,GAEnB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUJ,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAgCA,MAAMK,0BAA0B,GAAG,IAAIP,kBAAJ,CAAuBG,cAAvB,CAAnC;AACA,SAASI,0BAAT;AAEA,eAAeJ,cAAf","sourcesContent":["import { NativeEventEmitter, NativeModule, NativeModules } from 'react-native';\nimport type Product from '../models/Product';\nimport type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\nimport type { NewNativeContainerProps } from 'src/models/NewNativeContainerProps';\n\nconst ShoppingModule = NativeModules.ShoppingModule\n ? NativeModules.ShoppingModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\ninterface IShoppingModule extends NativeModule {\n init(): void;\n updateVideoProducts(products: Product[], callbackId: number | string): void;\n updateProductViewConfig(\n config: ProductInfoViewConfiguration,\n callbackId: number | string\n ): void;\n updateAddToCartStatus(\n res: string,\n tips: string,\n callbackId: number | string\n ): void;\n jumpToCartPage(\n callbackId: number | string,\n props: NewNativeContainerProps\n ): void;\n setCartIconVisible(visible: boolean): void;\n setCartItemCount(count: number): void;\n setCustomClickCartIconEnabled(enabled: boolean): Promise<void>; // Only supported on iOS\n}\n\nconst ShoppingModuleEventEmitter = new NativeEventEmitter(ShoppingModule);\nexport { ShoppingModuleEventEmitter };\n\nexport default ShoppingModule as IShoppingModule;\n"]}
|
|
@@ -5,6 +5,7 @@ import type ProductInfoViewConfiguration from './models/ProductInfoViewConfigura
|
|
|
5
5
|
import type { NewNativeContainerProps } from './models/NewNativeContainerProps';
|
|
6
6
|
export declare type AddToCartCallback = (event: AddToCartEvent) => Promise<AddToCartResult | undefined | null>;
|
|
7
7
|
export declare type ClickCartIconCallback = () => Promise<NewNativeContainerProps | undefined | null>;
|
|
8
|
+
export declare type CustomClickCartIconCallback = () => Promise<void>;
|
|
8
9
|
export declare type UpdateProductDetailsCallback = (event: UpdateProductDetailsEvent) => Promise<Product[] | undefined | null>;
|
|
9
10
|
export declare type WillDisplayProductCallback = (event: WillDisplayProductEvent) => Promise<ProductInfoViewConfiguration | undefined | null>;
|
|
10
11
|
/**
|
|
@@ -21,9 +22,17 @@ declare class VideoShopping {
|
|
|
21
22
|
/**
|
|
22
23
|
* This callback is triggered when the user clicks the shopping cart icon.
|
|
23
24
|
*
|
|
24
|
-
* The host app can return
|
|
25
|
+
* The host app can return NewNativeContainerProps object and we will push a new native container with the props.
|
|
25
26
|
*/
|
|
26
27
|
onClickCartIcon?: ClickCartIconCallback;
|
|
28
|
+
/**
|
|
29
|
+
* This callback is triggered when the user clicks the shopping cart icon.
|
|
30
|
+
*
|
|
31
|
+
* The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.
|
|
32
|
+
*/
|
|
33
|
+
get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined;
|
|
34
|
+
set onCustomClickCartIcon(value: CustomClickCartIconCallback | undefined);
|
|
35
|
+
private _onCustomClickCartIcon?;
|
|
27
36
|
/**
|
|
28
37
|
* This callback is triggered when the video will be shown.
|
|
29
38
|
*
|
|
@@ -22,7 +22,7 @@ import type { AddToCartButtonConfiguration } from './models/ProductInfoViewConfi
|
|
|
22
22
|
import type ProductUnit from './models/ProductUnit';
|
|
23
23
|
import type { ProductPrice } from './models/ProductUnit';
|
|
24
24
|
import type VideoFeedConfiguration from './models/VideoFeedConfiguration';
|
|
25
|
-
import type { VideoFeedPlayIconConfiguration, VideoFeedTitleConfiguration, VideoFeedTitlePosition } from './models/VideoFeedConfiguration';
|
|
25
|
+
import type { VideoFeedContentPadding, VideoFeedPlayIconConfiguration, VideoFeedTitleConfiguration, VideoFeedTitlePosition } from './models/VideoFeedConfiguration';
|
|
26
26
|
import type { VideoFeedSource } from './models/VideoFeedSource';
|
|
27
27
|
import type VideoPlaybackDetails from './models/VideoPlaybackDetails';
|
|
28
28
|
import type { VideoPlayerSize } from './models/VideoPlaybackDetails';
|
|
@@ -32,4 +32,4 @@ import type { VideoLaunchBehavior, VideoPlayerCompleteAction, VideoPlayerCTAStyl
|
|
|
32
32
|
import type { AddToCartCallback, ClickCartIconCallback, UpdateProductDetailsCallback, WillDisplayProductCallback } from './VideoShopping';
|
|
33
33
|
import VideoShopping from './VideoShopping';
|
|
34
34
|
export default FireworkSDK;
|
|
35
|
-
export { AdBadgeConfiguration, AdBadgeTextType, AddToCartButtonConfiguration, AddToCartCallback, AddToCartEvent, AddToCartResult, ClickCartIconCallback, CustomCTAClickCallback, CustomCTAClickEvent, CustomCTALinkContentRender, FeedItemDetails, FWError, FWNavigator, IVideoFeedProps, LiveStream, LiveStreamChatEvent, LiveStreamChatEventName, LiveStreamEvent, LiveStreamEventDetails, LiveStreamEventName, LiveStreamMessageDetails, NewNativeContainerProps, onLiveStreamChatEventCallback, onLiveStreamEventCallback, Product, ProductInfoViewConfiguration, ProductPrice, ProductUnit, SDKInitCallback, SDKInitEvent, UpdateProductDetailsCallback, UpdateProductDetailsEvent, VideoFeed, VideoFeedClickCallback, VideoFeedConfiguration, VideoFeedMode, VideoFeedPlayIconConfiguration, VideoFeedSource, VideoFeedTitleConfiguration, VideoFeedTitlePosition, VideoLaunchBehavior, VideoPlaybackCallback, VideoPlaybackDetails, VideoPlaybackEvent, VideoPlaybackEventName, VideoPlayerCompleteAction, VideoPlayerConfiguration, VideoPlayerCTAStyle, VideoPlayerSize, VideoPlayerStyle, VideoShopping, WillDisplayProductCallback, WillDisplayProductEvent, };
|
|
35
|
+
export { AdBadgeConfiguration, AdBadgeTextType, AddToCartButtonConfiguration, AddToCartCallback, AddToCartEvent, AddToCartResult, ClickCartIconCallback, CustomCTAClickCallback, CustomCTAClickEvent, CustomCTALinkContentRender, FeedItemDetails, FWError, FWNavigator, IVideoFeedProps, LiveStream, LiveStreamChatEvent, LiveStreamChatEventName, LiveStreamEvent, LiveStreamEventDetails, LiveStreamEventName, LiveStreamMessageDetails, NewNativeContainerProps, onLiveStreamChatEventCallback, onLiveStreamEventCallback, Product, ProductInfoViewConfiguration, ProductPrice, ProductUnit, SDKInitCallback, SDKInitEvent, UpdateProductDetailsCallback, UpdateProductDetailsEvent, VideoFeed, VideoFeedClickCallback, VideoFeedConfiguration, VideoFeedContentPadding, VideoFeedMode, VideoFeedPlayIconConfiguration, VideoFeedSource, VideoFeedTitleConfiguration, VideoFeedTitlePosition, VideoLaunchBehavior, VideoPlaybackCallback, VideoPlaybackDetails, VideoPlaybackEvent, VideoPlaybackEventName, VideoPlayerCompleteAction, VideoPlayerConfiguration, VideoPlayerCTAStyle, VideoPlayerSize, VideoPlayerStyle, VideoShopping, WillDisplayProductCallback, WillDisplayProductEvent, };
|
|
@@ -8,33 +8,51 @@ export interface VideoFeedPlayIconConfiguration {
|
|
|
8
8
|
iconWidth?: number;
|
|
9
9
|
}
|
|
10
10
|
export declare type VideoFeedTitlePosition = 'stacked' | 'nested';
|
|
11
|
+
export interface VideoFeedContentPadding {
|
|
12
|
+
top?: number;
|
|
13
|
+
right?: number;
|
|
14
|
+
bottom?: number;
|
|
15
|
+
left?: number;
|
|
16
|
+
}
|
|
11
17
|
export default interface VideoFeedConfiguration {
|
|
12
18
|
/**
|
|
13
19
|
* Background color of video feed.
|
|
14
20
|
*/
|
|
15
21
|
backgroundColor?: string;
|
|
16
22
|
/**
|
|
17
|
-
* Corner radius of video feed. Only supported on iOS.
|
|
23
|
+
* Corner radius of video feed item. Only supported on iOS.
|
|
18
24
|
*/
|
|
19
25
|
cornerRadius?: number;
|
|
20
26
|
/**
|
|
21
|
-
* Configuration of video feed title.
|
|
27
|
+
* Configuration of video feed item title.
|
|
22
28
|
*/
|
|
23
29
|
title?: VideoFeedTitleConfiguration;
|
|
24
30
|
/**
|
|
25
|
-
* Title position of video feed.
|
|
31
|
+
* Title position of video feed item.
|
|
26
32
|
*/
|
|
27
33
|
titlePosition?: VideoFeedTitlePosition;
|
|
28
34
|
/**
|
|
29
|
-
* Configuration of video feed play icon. Only supported on iOS.
|
|
35
|
+
* Configuration of video feed item play icon. Only supported on iOS.
|
|
30
36
|
*/
|
|
31
37
|
playIcon?: VideoFeedPlayIconConfiguration;
|
|
32
38
|
/**
|
|
33
|
-
* Indicates if the video feed shows ad badge.
|
|
39
|
+
* Indicates if the video feed item shows ad badge.
|
|
34
40
|
*/
|
|
35
41
|
showAdBadge?: boolean;
|
|
36
42
|
/**
|
|
37
43
|
* Custom layout name for video feed item. Only supported on Android.
|
|
38
44
|
*/
|
|
39
45
|
customLayoutName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The aspect ratio(width / height) for video feed item. Only supported on iOS.
|
|
48
|
+
*/
|
|
49
|
+
aspectRatio?: number;
|
|
50
|
+
/**
|
|
51
|
+
* The content padding for video feed. Only supported on iOS.
|
|
52
|
+
*/
|
|
53
|
+
contentPadding?: VideoFeedContentPadding;
|
|
54
|
+
/**
|
|
55
|
+
* The item spacing for video feed. Only supported on iOS.
|
|
56
|
+
*/
|
|
57
|
+
itemSpacing?: number;
|
|
40
58
|
}
|
|
@@ -32,7 +32,11 @@ export default interface VideoPlayerConfiguration {
|
|
|
32
32
|
*/
|
|
33
33
|
showMuteButton?: boolean;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Specifies the video player launch behavior.
|
|
36
36
|
*/
|
|
37
37
|
launchBehavior?: VideoLaunchBehavior;
|
|
38
|
+
/**
|
|
39
|
+
* Indicates if Firework branding should be showed or not.
|
|
40
|
+
*/
|
|
41
|
+
showBranding?: boolean;
|
|
38
42
|
}
|
|
@@ -10,6 +10,7 @@ interface IShoppingModule extends NativeModule {
|
|
|
10
10
|
jumpToCartPage(callbackId: number | string, props: NewNativeContainerProps): void;
|
|
11
11
|
setCartIconVisible(visible: boolean): void;
|
|
12
12
|
setCartItemCount(count: number): void;
|
|
13
|
+
setCustomClickCartIconEnabled(enabled: boolean): Promise<void>;
|
|
13
14
|
}
|
|
14
15
|
declare const ShoppingModuleEventEmitter: NativeEventEmitter;
|
|
15
16
|
export { ShoppingModuleEventEmitter };
|
package/package.json
CHANGED
package/src/VideoShopping.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NativeEventEmitter, Platform } from 'react-native';
|
|
2
2
|
|
|
3
3
|
import type AddToCartResult from './models/AddToCartResult';
|
|
4
4
|
import type {
|
|
@@ -22,6 +22,8 @@ export type ClickCartIconCallback = () => Promise<
|
|
|
22
22
|
NewNativeContainerProps | undefined | null
|
|
23
23
|
>;
|
|
24
24
|
|
|
25
|
+
export type CustomClickCartIconCallback = () => Promise<void>;
|
|
26
|
+
|
|
25
27
|
export type UpdateProductDetailsCallback = (
|
|
26
28
|
event: UpdateProductDetailsEvent
|
|
27
29
|
) => Promise<Product[] | undefined | null>;
|
|
@@ -48,10 +50,28 @@ class VideoShopping {
|
|
|
48
50
|
/**
|
|
49
51
|
* This callback is triggered when the user clicks the shopping cart icon.
|
|
50
52
|
*
|
|
51
|
-
* The host app can return
|
|
53
|
+
* The host app can return NewNativeContainerProps object and we will push a new native container with the props.
|
|
52
54
|
*/
|
|
53
55
|
public onClickCartIcon?: ClickCartIconCallback;
|
|
54
56
|
|
|
57
|
+
/**
|
|
58
|
+
* This callback is triggered when the user clicks the shopping cart icon.
|
|
59
|
+
*
|
|
60
|
+
* The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.
|
|
61
|
+
*/
|
|
62
|
+
public get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined {
|
|
63
|
+
return this._onCustomClickCartIcon;
|
|
64
|
+
}
|
|
65
|
+
public set onCustomClickCartIcon(
|
|
66
|
+
value: CustomClickCartIconCallback | undefined
|
|
67
|
+
) {
|
|
68
|
+
this._onCustomClickCartIcon = value;
|
|
69
|
+
if (Platform.OS === 'ios') {
|
|
70
|
+
ShoppingModule.setCustomClickCartIconEnabled(!!value);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
private _onCustomClickCartIcon?: CustomClickCartIconCallback | undefined;
|
|
74
|
+
|
|
55
75
|
/**
|
|
56
76
|
* This callback is triggered when the video will be shown.
|
|
57
77
|
*
|
|
@@ -132,7 +152,9 @@ class VideoShopping {
|
|
|
132
152
|
}
|
|
133
153
|
|
|
134
154
|
private async handleClickCartIconEvent(event: CallbackInfo) {
|
|
135
|
-
if (this.
|
|
155
|
+
if (this.onCustomClickCartIcon) {
|
|
156
|
+
this.onCustomClickCartIcon();
|
|
157
|
+
} else if (this.onClickCartIcon) {
|
|
136
158
|
const callbackId = event.callbackId;
|
|
137
159
|
delete event.callbackId;
|
|
138
160
|
const props = await this.onClickCartIcon();
|
package/src/index.tsx
CHANGED
|
@@ -41,6 +41,7 @@ import type ProductUnit from './models/ProductUnit';
|
|
|
41
41
|
import type { ProductPrice } from './models/ProductUnit';
|
|
42
42
|
import type VideoFeedConfiguration from './models/VideoFeedConfiguration';
|
|
43
43
|
import type {
|
|
44
|
+
VideoFeedContentPadding,
|
|
44
45
|
VideoFeedPlayIconConfiguration,
|
|
45
46
|
VideoFeedTitleConfiguration,
|
|
46
47
|
VideoFeedTitlePosition,
|
|
@@ -102,6 +103,7 @@ export {
|
|
|
102
103
|
VideoFeed,
|
|
103
104
|
VideoFeedClickCallback,
|
|
104
105
|
VideoFeedConfiguration,
|
|
106
|
+
VideoFeedContentPadding,
|
|
105
107
|
VideoFeedMode,
|
|
106
108
|
VideoFeedPlayIconConfiguration,
|
|
107
109
|
VideoFeedSource,
|
|
@@ -11,33 +11,52 @@ export interface VideoFeedPlayIconConfiguration {
|
|
|
11
11
|
|
|
12
12
|
export type VideoFeedTitlePosition = 'stacked' | 'nested';
|
|
13
13
|
|
|
14
|
+
export interface VideoFeedContentPadding {
|
|
15
|
+
top?: number;
|
|
16
|
+
right?: number;
|
|
17
|
+
bottom?: number;
|
|
18
|
+
left?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
export default interface VideoFeedConfiguration {
|
|
15
22
|
/**
|
|
16
23
|
* Background color of video feed.
|
|
17
24
|
*/
|
|
18
25
|
backgroundColor?: string;
|
|
19
26
|
/**
|
|
20
|
-
* Corner radius of video feed. Only supported on iOS.
|
|
27
|
+
* Corner radius of video feed item. Only supported on iOS.
|
|
21
28
|
*/
|
|
22
29
|
cornerRadius?: number;
|
|
23
30
|
/**
|
|
24
|
-
* Configuration of video feed title.
|
|
31
|
+
* Configuration of video feed item title.
|
|
25
32
|
*/
|
|
26
33
|
title?: VideoFeedTitleConfiguration;
|
|
27
34
|
/**
|
|
28
|
-
* Title position of video feed.
|
|
35
|
+
* Title position of video feed item.
|
|
29
36
|
*/
|
|
30
37
|
titlePosition?: VideoFeedTitlePosition;
|
|
31
38
|
/**
|
|
32
|
-
* Configuration of video feed play icon. Only supported on iOS.
|
|
39
|
+
* Configuration of video feed item play icon. Only supported on iOS.
|
|
33
40
|
*/
|
|
34
41
|
playIcon?: VideoFeedPlayIconConfiguration;
|
|
35
42
|
/**
|
|
36
|
-
* Indicates if the video feed shows ad badge.
|
|
43
|
+
* Indicates if the video feed item shows ad badge.
|
|
37
44
|
*/
|
|
38
45
|
showAdBadge?: boolean;
|
|
39
46
|
/**
|
|
40
47
|
* Custom layout name for video feed item. Only supported on Android.
|
|
41
48
|
*/
|
|
42
49
|
customLayoutName?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The aspect ratio(width / height) for video feed item. Only supported on iOS.
|
|
52
|
+
*/
|
|
53
|
+
aspectRatio?: number;
|
|
54
|
+
/**
|
|
55
|
+
* The content padding for video feed. Only supported on iOS.
|
|
56
|
+
*/
|
|
57
|
+
contentPadding?: VideoFeedContentPadding;
|
|
58
|
+
/**
|
|
59
|
+
* The item spacing for video feed. Only supported on iOS.
|
|
60
|
+
*/
|
|
61
|
+
itemSpacing?: number;
|
|
43
62
|
}
|
|
@@ -34,7 +34,11 @@ export default interface VideoPlayerConfiguration {
|
|
|
34
34
|
*/
|
|
35
35
|
showMuteButton?: boolean;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Specifies the video player launch behavior.
|
|
38
38
|
*/
|
|
39
39
|
launchBehavior?: VideoLaunchBehavior;
|
|
40
|
+
/**
|
|
41
|
+
* Indicates if Firework branding should be showed or not.
|
|
42
|
+
*/
|
|
43
|
+
showBranding?: boolean;
|
|
40
44
|
}
|
|
@@ -33,6 +33,7 @@ interface IShoppingModule extends NativeModule {
|
|
|
33
33
|
): void;
|
|
34
34
|
setCartIconVisible(visible: boolean): void;
|
|
35
35
|
setCartItemCount(count: number): void;
|
|
36
|
+
setCustomClickCartIconEnabled(enabled: boolean): Promise<void>; // Only supported on iOS
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
const ShoppingModuleEventEmitter = new NativeEventEmitter(ShoppingModule);
|