react-native-firework-sdk 1.0.0-beta
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/README.md +39 -0
- package/android/build.gradle +193 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +5 -0
- package/android/gradlew +185 -0
- package/android/gradlew.bat +89 -0
- package/android/publish.gradle +65 -0
- package/android/src/main/AndroidManifest.xml +16 -0
- package/android/src/main/java/com/reactnativefireworksdk/FireworkSDKPackage.kt +20 -0
- package/android/src/main/java/com/reactnativefireworksdk/components/videofeed/FWVideoFeed.kt +123 -0
- package/android/src/main/java/com/reactnativefireworksdk/constants/FWCommandConstant.kt +6 -0
- package/android/src/main/java/com/reactnativefireworksdk/constants/FWVideoPlayerConstant.kt +20 -0
- package/android/src/main/java/com/reactnativefireworksdk/manager/FWVideoFeedManager.kt +88 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWEventName.kt +35 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedConfigModel.kt +27 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedItemDetailsModel.kt +11 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedMode.kt +7 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedSource.kt +7 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedTitlePosition.kt +7 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoPlaybackDetails.kt +19 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoPlayerConfigModel.kt +20 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoShoppingInterface.kt +13 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoShoppingProduct.kt +34 -0
- package/android/src/main/java/com/reactnativefireworksdk/models/FireworkSDKInterface.kt +12 -0
- package/android/src/main/java/com/reactnativefireworksdk/module/FWVideoShoppingModule.kt +190 -0
- package/android/src/main/java/com/reactnativefireworksdk/module/FireworkSDKModule.kt +248 -0
- package/android/src/main/java/com/reactnativefireworksdk/pages/FWVideoShoppingCartActivity.kt +43 -0
- package/android/src/main/java/com/reactnativefireworksdk/utils/FWEventUtils.kt +127 -0
- package/android/src/main/java/com/reactnativefireworksdk/utils/FWJsonUtils.kt +57 -0
- package/android/src/main/java/com/reactnativefireworksdk/utils/FWLogUtils.kt +147 -0
- package/android/src/main/java/com/reactnativefireworksdk/utils/FWUrlUtils.kt +68 -0
- package/android/src/main/java/com/reactnativefireworksdk/utils/FWVideoPlayerUtils.kt +18 -0
- package/android/src/main/res/layout/fwrn_fragment_shoppingcart.xml +8 -0
- package/android/src/main/res/layout/fwrn_fragment_videofeed.xml +20 -0
- package/android/src/main/res/values/styles.xml +43 -0
- package/ios/Component/VideoFeed.swift +262 -0
- package/ios/Component/VideoFeedConfiguration.swift +32 -0
- package/ios/Component/VideoFeedManager.m +51 -0
- package/ios/Component/VideoFeedManager.swift +40 -0
- package/ios/Component/VideoPlayerConfiguration.swift +30 -0
- package/ios/FireworkSdk-Bridging-Header.h +6 -0
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +291 -0
- package/ios/Models/FireworkJsEvent.swift +34 -0
- package/ios/Models/FireworkSDK+JsModel.swift +62 -0
- package/ios/Models/RCTConvert+FireworkSDKModule.swift +91 -0
- package/ios/Models/RCTConvert+Shopping.swift +49 -0
- package/ios/Models/RCTConvert+VideoFeed.swift +69 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +17 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +74 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +19 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +106 -0
- package/ios/Modules/FireworkSDKModule/MobileADConfiguration.swift +17 -0
- package/ios/Modules/Shopping/CartViewController.swift +98 -0
- package/ios/Modules/Shopping/Product.swift +33 -0
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +24 -0
- package/ios/Modules/Shopping/ShoppingModule.m +19 -0
- package/ios/Modules/Shopping/ShoppingModule.swift +214 -0
- package/ios/Utils/String+Color.swift +38 -0
- package/ios/Utils/UIView+Constraints.swift +91 -0
- package/ios/Utils/UIView+ParentViewController.swift +21 -0
- package/ios/Utils/UIViewController+AttachChild.swift +69 -0
- package/lib/commonjs/FireworkSDK.js +171 -0
- package/lib/commonjs/FireworkSDK.js.map +1 -0
- package/lib/commonjs/VideoShopping.js +146 -0
- package/lib/commonjs/VideoShopping.js.map +1 -0
- package/lib/commonjs/components/CartContainer.js +35 -0
- package/lib/commonjs/components/CartContainer.js.map +1 -0
- package/lib/commonjs/components/FWVideoFeed.js +18 -0
- package/lib/commonjs/components/FWVideoFeed.js.map +1 -0
- package/lib/commonjs/components/VideoFeed.js +82 -0
- package/lib/commonjs/components/VideoFeed.js.map +1 -0
- package/lib/commonjs/constants/FWErrorMessage.js +15 -0
- package/lib/commonjs/constants/FWErrorMessage.js.map +1 -0
- package/lib/commonjs/index.js +44 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/models/ADConfig.js +2 -0
- package/lib/commonjs/models/ADConfig.js.map +1 -0
- package/lib/commonjs/models/AddToCartResult.js +2 -0
- package/lib/commonjs/models/AddToCartResult.js.map +1 -0
- package/lib/commonjs/models/FWError.js +2 -0
- package/lib/commonjs/models/FWError.js.map +1 -0
- package/lib/commonjs/models/FWEvents.js +20 -0
- package/lib/commonjs/models/FWEvents.js.map +1 -0
- package/lib/commonjs/models/FeedItemDetails.js +2 -0
- package/lib/commonjs/models/FeedItemDetails.js.map +1 -0
- package/lib/commonjs/models/Product.js +2 -0
- package/lib/commonjs/models/Product.js.map +1 -0
- package/lib/commonjs/models/ProductInfoViewConfiguration.js +2 -0
- package/lib/commonjs/models/ProductInfoViewConfiguration.js.map +1 -0
- package/lib/commonjs/models/ProductUnit.js +2 -0
- package/lib/commonjs/models/ProductUnit.js.map +1 -0
- package/lib/commonjs/models/VideoFeedConfiguration.js +2 -0
- package/lib/commonjs/models/VideoFeedConfiguration.js.map +1 -0
- package/lib/commonjs/models/VideoPlaybackDetails.js +2 -0
- package/lib/commonjs/models/VideoPlaybackDetails.js.map +1 -0
- package/lib/commonjs/models/VideoPlaybackEventName.js +23 -0
- package/lib/commonjs/models/VideoPlaybackEventName.js.map +1 -0
- package/lib/commonjs/models/VideoPlayerConfiguration.js +2 -0
- package/lib/commonjs/models/VideoPlayerConfiguration.js.map +1 -0
- package/lib/commonjs/modules/FireworkSDKModule.js +20 -0
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -0
- package/lib/commonjs/modules/ShoppingModule.js +20 -0
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -0
- package/lib/module/FireworkSDK.js +153 -0
- package/lib/module/FireworkSDK.js.map +1 -0
- package/lib/module/VideoShopping.js +134 -0
- package/lib/module/VideoShopping.js.map +1 -0
- package/lib/module/components/CartContainer.js +18 -0
- package/lib/module/components/CartContainer.js.map +1 -0
- package/lib/module/components/FWVideoFeed.js +8 -0
- package/lib/module/components/FWVideoFeed.js.map +1 -0
- package/lib/module/components/VideoFeed.js +66 -0
- package/lib/module/components/VideoFeed.js.map +1 -0
- package/lib/module/constants/FWErrorMessage.js +7 -0
- package/lib/module/constants/FWErrorMessage.js.map +1 -0
- package/lib/module/index.js +10 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/models/ADConfig.js +2 -0
- package/lib/module/models/ADConfig.js.map +1 -0
- package/lib/module/models/AddToCartResult.js +2 -0
- package/lib/module/models/AddToCartResult.js.map +1 -0
- package/lib/module/models/FWError.js +2 -0
- package/lib/module/models/FWError.js.map +1 -0
- package/lib/module/models/FWEvents.js +13 -0
- package/lib/module/models/FWEvents.js.map +1 -0
- package/lib/module/models/FeedItemDetails.js +2 -0
- package/lib/module/models/FeedItemDetails.js.map +1 -0
- package/lib/module/models/Product.js +2 -0
- package/lib/module/models/Product.js.map +1 -0
- package/lib/module/models/ProductInfoViewConfiguration.js +2 -0
- package/lib/module/models/ProductInfoViewConfiguration.js.map +1 -0
- package/lib/module/models/ProductUnit.js +2 -0
- package/lib/module/models/ProductUnit.js.map +1 -0
- package/lib/module/models/VideoFeedConfiguration.js +2 -0
- package/lib/module/models/VideoFeedConfiguration.js.map +1 -0
- package/lib/module/models/VideoPlaybackDetails.js +2 -0
- package/lib/module/models/VideoPlaybackDetails.js.map +1 -0
- package/lib/module/models/VideoPlaybackEventName.js +16 -0
- package/lib/module/models/VideoPlaybackEventName.js.map +1 -0
- package/lib/module/models/VideoPlayerConfiguration.js +2 -0
- package/lib/module/models/VideoPlayerConfiguration.js.map +1 -0
- package/lib/module/modules/FireworkSDKModule.js +10 -0
- package/lib/module/modules/FireworkSDKModule.js.map +1 -0
- package/lib/module/modules/ShoppingModule.js +10 -0
- package/lib/module/modules/ShoppingModule.js.map +1 -0
- package/lib/typescript/FireworkSDK.d.ts +74 -0
- package/lib/typescript/VideoShopping.d.ts +54 -0
- package/lib/typescript/components/CartContainer.d.ts +3 -0
- package/lib/typescript/components/FWVideoFeed.d.ts +2 -0
- package/lib/typescript/components/VideoFeed.d.ts +53 -0
- package/lib/typescript/constants/FWErrorMessage.d.ts +2 -0
- package/lib/typescript/index.d.ts +25 -0
- package/lib/typescript/models/ADConfig.d.ts +10 -0
- package/lib/typescript/models/AddToCartResult.d.ts +10 -0
- package/lib/typescript/models/FWError.d.ts +10 -0
- package/lib/typescript/models/FWEvents.d.ts +55 -0
- package/lib/typescript/models/FeedItemDetails.d.ts +14 -0
- package/lib/typescript/models/Product.d.ts +19 -0
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +18 -0
- package/lib/typescript/models/ProductUnit.d.ts +22 -0
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +32 -0
- package/lib/typescript/models/VideoPlaybackDetails.d.ts +31 -0
- package/lib/typescript/models/VideoPlaybackEventName.d.ts +39 -0
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +25 -0
- package/lib/typescript/modules/FireworkSDKModule.d.ts +12 -0
- package/lib/typescript/modules/ShoppingModule.d.ts +13 -0
- package/package.json +147 -0
- package/react-native-firework-sdk.podspec +22 -0
- package/src/FireworkSDK.ts +153 -0
- package/src/VideoShopping.ts +165 -0
- package/src/components/CartContainer.tsx +20 -0
- package/src/components/FWVideoFeed.tsx +10 -0
- package/src/components/VideoFeed.tsx +109 -0
- package/src/constants/FWErrorMessage.ts +11 -0
- package/src/index.tsx +109 -0
- package/src/models/ADConfig.ts +10 -0
- package/src/models/AddToCartResult.ts +10 -0
- package/src/models/FWError.ts +10 -0
- package/src/models/FWEvents.ts +63 -0
- package/src/models/FeedItemDetails.ts +14 -0
- package/src/models/Product.ts +20 -0
- package/src/models/ProductInfoViewConfiguration.ts +20 -0
- package/src/models/ProductUnit.ts +23 -0
- package/src/models/VideoFeedConfiguration.ts +35 -0
- package/src/models/VideoPlaybackDetails.ts +33 -0
- package/src/models/VideoPlaybackEventName.ts +40 -0
- package/src/models/VideoPlayerConfiguration.ts +26 -0
- package/src/modules/FireworkSDKModule.ts +27 -0
- package/src/modules/ShoppingModule.ts +29 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.reactnativefireworksdk.utils
|
|
2
|
+
|
|
3
|
+
import com.loopnow.fireworklibrary.VideoPlayerProperties
|
|
4
|
+
import com.reactnativefireworksdk.constants.FWVideoPlayerConstant
|
|
5
|
+
import com.reactnativefireworksdk.models.FWVideoPlayerConfigModel
|
|
6
|
+
|
|
7
|
+
object FWVideoPlayerUtils {
|
|
8
|
+
|
|
9
|
+
var customCTAClickEnabled: Boolean = false
|
|
10
|
+
var videoPlaybackEventEnabled: Boolean = false
|
|
11
|
+
|
|
12
|
+
fun setVideoPlayerConfig(config: FWVideoPlayerConfigModel?) {
|
|
13
|
+
VideoPlayerProperties.share = config?.showShareButton != false
|
|
14
|
+
VideoPlayerProperties.loop = config?.videoCompleteAction != FWVideoPlayerConstant.FW_VIDEO_COMPLETE_ACTION_ADVANCE_TO_NEXT
|
|
15
|
+
// VideoPlayerProperties.autoPlayOnComplete = config?.videoCompleteAction != FWVideoPlayerConstant.FW_VIDEO_COMPLETE_ACTION_LOOP
|
|
16
|
+
VideoPlayerProperties.fullScreenPlayer = config?.playerStyle == FWVideoPlayerConstant.FW_PLAYER_STYLE_FULL
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
android:id="@+id/shopping_cart_container"
|
|
5
|
+
android:layout_width="match_parent"
|
|
6
|
+
android:layout_height="match_parent">
|
|
7
|
+
|
|
8
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
|
3
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
5
|
+
android:layout_width="match_parent"
|
|
6
|
+
android:layout_height="match_parent">
|
|
7
|
+
|
|
8
|
+
<com.loopnow.fireworklibrary.views.VideoFeedView
|
|
9
|
+
android:id="@+id/fwrn_integrated_videofeed"
|
|
10
|
+
android:layout_width="match_parent"
|
|
11
|
+
android:layout_height="match_parent"
|
|
12
|
+
app:feedLayout="horizontal"
|
|
13
|
+
app:showTitle="true"
|
|
14
|
+
app:titlePosition="alignBottom"
|
|
15
|
+
app:feedType="discover"
|
|
16
|
+
app:imageStyle="@style/FWFeedViewImageStyle"
|
|
17
|
+
app:textStyle="@style/FWFeedViewCaptionStyle"
|
|
18
|
+
/>
|
|
19
|
+
|
|
20
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<resources>
|
|
3
|
+
|
|
4
|
+
<!-- Apply your feed image by "FWFeedViewImageStyle" style.-->
|
|
5
|
+
<style name="FWFeedViewImageStyle" >
|
|
6
|
+
<item name="android:radius">0dp</item>
|
|
7
|
+
</style>
|
|
8
|
+
|
|
9
|
+
<!-- Apply your feed caption by "FWFeedViewCaptionStyle" style.-->
|
|
10
|
+
<style name="FWFeedViewCaptionStyle">
|
|
11
|
+
<item name="android:textColor">#ffffffff</item>
|
|
12
|
+
<item name="android:textSize">14sp</item>
|
|
13
|
+
<item name="android:gravity">top</item>
|
|
14
|
+
<item name="android:paddingLeft">@dimen/fw_padding_8</item>
|
|
15
|
+
<item name="android:paddingRight">@dimen/fw_padding_8</item>
|
|
16
|
+
<item name="android:background">#80000000</item>
|
|
17
|
+
</style>
|
|
18
|
+
|
|
19
|
+
<!-- Apply your play button by "FWPlayButtonStyle" style.-->
|
|
20
|
+
<style name="FWPlayButtonStyle" >
|
|
21
|
+
<item name="android:layout_width">40dp</item>
|
|
22
|
+
<item name="android:layout_height">40dp</item>
|
|
23
|
+
<item name="android:src">@drawable/fw_play_icon</item>
|
|
24
|
+
</style>
|
|
25
|
+
|
|
26
|
+
<!-- Apply your custom CTA button background by "FWCtaButtonBgStyle" style.-->
|
|
27
|
+
<style name="FWCtaButtonBgStyle">
|
|
28
|
+
<item name="android:background">@drawable/fw_cta_bg_primary</item>
|
|
29
|
+
</style>
|
|
30
|
+
|
|
31
|
+
<!-- Apply your custom CTA button title by "FWCtaButtonLabelStyle" style.-->
|
|
32
|
+
<style name="FWCtaButtonLabelStyle">
|
|
33
|
+
<item name="android:textSize">@dimen/fw_font_size_14</item>
|
|
34
|
+
<item name="android:textColor">@color/fw_gnt_white</item>
|
|
35
|
+
</style>
|
|
36
|
+
|
|
37
|
+
<!-- Apply your custom "Add to cart" button by "FWAddToCartButtonStyle" style.-->
|
|
38
|
+
<style name="FWAddToCartButtonStyle">
|
|
39
|
+
<item name="android:background">@drawable/fw_add_to_cart_button</item>
|
|
40
|
+
<item name="android:textColor">@color/fw_gnt_white</item>
|
|
41
|
+
<item name="android:textSize">@dimen/fw_font_size_16</item>
|
|
42
|
+
</style>
|
|
43
|
+
</resources>
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FWVideoFeed.swift
|
|
3
|
+
// react-native-firework-sdk
|
|
4
|
+
//
|
|
5
|
+
// Created by Jeff Zheng on 2021/12/22.
|
|
6
|
+
//
|
|
7
|
+
// FWVideoFeed wrap the VideoFeedViewController class (which need to embed subview throught 'addChildViewController') which can simply embed host view throught 'addSubview'
|
|
8
|
+
|
|
9
|
+
import UIKit
|
|
10
|
+
import FireworkVideo
|
|
11
|
+
|
|
12
|
+
@objc
|
|
13
|
+
public enum VideoFeedMode: Int {
|
|
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
|
+
}
|
|
31
|
+
|
|
32
|
+
@objc
|
|
33
|
+
public enum VideFeedSourceType: Int {
|
|
34
|
+
case discover, channel, playlist
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public protocol VideoFeedViewDelegate: AnyObject {
|
|
38
|
+
/// Called once after a video feed has been successfully loaded
|
|
39
|
+
func videoFeedDidLoadFeed(_ view: VideoFeed)
|
|
40
|
+
/// Called if the video feed failed to load
|
|
41
|
+
func videoFeed(_ view: VideoFeed,
|
|
42
|
+
didFailToLoadFeed error: VideoFeedError)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@objc
|
|
46
|
+
public class VideoFeed: UIView, VideoFeedViewControllerDelegate {
|
|
47
|
+
@objc public var sourceType: VideFeedSourceType = .discover
|
|
48
|
+
@objc public var channel: String = ""
|
|
49
|
+
@objc public var playlist: String = ""
|
|
50
|
+
@objc public var mode: VideoFeedMode = .row
|
|
51
|
+
@objc public var feedViewConfig: VideoFeedConfiguration? {
|
|
52
|
+
didSet {
|
|
53
|
+
guard let feedVC = feedVC else {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
feedVC.viewConfiguration = convertToVideoFeedConentConfiguration()
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
@objc public var playerViewConfig: VideoPlayerConfiguration? {
|
|
60
|
+
didSet {
|
|
61
|
+
guard let feedVC = feedVC else {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
feedVC.viewConfiguration = convertToVideoFeedConentConfiguration()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
@objc var onVideoFeedLoadFinished: RCTBubblingEventBlock?
|
|
68
|
+
// @objc var onVideoFeedClick: RCTBubblingEventBlock?
|
|
69
|
+
|
|
70
|
+
public weak var delegate: VideoFeedViewDelegate?
|
|
71
|
+
|
|
72
|
+
private var feedVC: VideoFeedViewController?
|
|
73
|
+
private var source: VideoFeedContentSource {
|
|
74
|
+
switch sourceType {
|
|
75
|
+
case .discover:
|
|
76
|
+
return .discover
|
|
77
|
+
case .channel:
|
|
78
|
+
return .channel(channelID: channel)
|
|
79
|
+
case .playlist:
|
|
80
|
+
return .channelPlaylist(channelID: channel, playlistID: playlist)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public override func layoutSubviews() {
|
|
85
|
+
super.layoutSubviews()
|
|
86
|
+
|
|
87
|
+
embed()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private func embed() {
|
|
91
|
+
guard let parentVC = parentViewController else {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
guard feedVC == nil else {
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let feedVC = VideoFeedViewController(
|
|
99
|
+
layout: mode.videoFeedLayout,
|
|
100
|
+
source: source
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
feedVC.viewConfiguration = convertToVideoFeedConentConfiguration()
|
|
104
|
+
feedVC.delegate = self
|
|
105
|
+
self.feedVC = feedVC
|
|
106
|
+
|
|
107
|
+
parentVC.attachChild(feedVC, to: self)
|
|
108
|
+
|
|
109
|
+
// parentVC.addChild(feedVC)
|
|
110
|
+
// addSubview(feedVC.view)
|
|
111
|
+
// feedVC.view.frame = bounds
|
|
112
|
+
// feedVC.didMove(toParent: parentVC)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public override func removeFromSuperview() {
|
|
116
|
+
guard let feedVC = feedVC, let parentVC = parentViewController else {
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
parentVC.detachChild(feedVC)
|
|
121
|
+
// feedVC.willMove(toParent: nil)
|
|
122
|
+
// feedVC.removeFromParent()
|
|
123
|
+
// feedVC.view.removeFromSuperview()
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@objc
|
|
127
|
+
public func refresh() {
|
|
128
|
+
guard let feedVC = feedVC else {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
feedVC.refresh()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
//MARK: - VideoFeedViewControllerDelegate
|
|
135
|
+
public func videoFeedDidLoadFeed(_ viewController: VideoFeedViewController) {
|
|
136
|
+
guard let delegate = delegate else {
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
delegate.videoFeedDidLoadFeed(self)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public func videoFeed(_ viewController: VideoFeedViewController, didFailToLoadFeed error: VideoFeedError) {
|
|
143
|
+
guard let delegate = delegate else {
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
delegate.videoFeed(self, didFailToLoadFeed: error)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
extension VideoFeed {
|
|
151
|
+
private func convertToVideoFeedConentConfiguration() -> VideoFeedContentConfiguration {
|
|
152
|
+
var videoConfig = VideoFeedContentConfiguration()
|
|
153
|
+
//set default value so that behavior will the same with Android
|
|
154
|
+
videoConfig.itemView.title.isHidden = false
|
|
155
|
+
videoConfig.itemView.titleLayoutConfiguration.titlePosition = .nested
|
|
156
|
+
|
|
157
|
+
let vfcConfig = VideoFeed.convertToVideoFeedItemConentConfiguration(feedViewConfig)
|
|
158
|
+
let vpcConfig = VideoFeed.convertToVideoPlayerConentConfiguration(playerViewConfig)
|
|
159
|
+
if let vfcConfig = vfcConfig {
|
|
160
|
+
videoConfig.itemView = vfcConfig
|
|
161
|
+
}
|
|
162
|
+
if let vpcConfig = vpcConfig {
|
|
163
|
+
videoConfig.playerView = vpcConfig
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if let backgroundColor = feedViewConfig?.backgroundColor {
|
|
167
|
+
videoConfig.backgroundColor = backgroundColor.uicolor()
|
|
168
|
+
}
|
|
169
|
+
if let shareBaseUrl = gShareBaseURL {
|
|
170
|
+
videoConfig.playerView.shareButton.behavior.baseURL = URL(string:shareBaseUrl)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
//set a value different from default value to compatible with FireworkVideo SDK misalign bug
|
|
174
|
+
videoConfig.itemView.titleLayoutConfiguration.insets = UIEdgeInsets(top: 7, left: 7, bottom: 7, right: 7)
|
|
175
|
+
|
|
176
|
+
return videoConfig
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private static func convertToVideoFeedItemConentConfiguration(_ config: VideoFeedConfiguration?) -> VideoFeedItemContentConfiguration? {
|
|
180
|
+
guard let config = config else {
|
|
181
|
+
return nil
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
var vfcConfig = VideoFeedItemContentConfiguration()
|
|
185
|
+
//set default value so that behavior will the same with Android
|
|
186
|
+
vfcConfig.title.isHidden = false
|
|
187
|
+
vfcConfig.titleLayoutConfiguration.titlePosition = .nested
|
|
188
|
+
|
|
189
|
+
if let cornerRadius = config.cornerRadius {
|
|
190
|
+
vfcConfig.cornerRadius = CGFloat(cornerRadius)
|
|
191
|
+
}
|
|
192
|
+
if let title = config.title {
|
|
193
|
+
if let hidden = title.hidden {
|
|
194
|
+
vfcConfig.title.isHidden = hidden
|
|
195
|
+
}
|
|
196
|
+
if let textcolor = title.textColor {
|
|
197
|
+
vfcConfig.title.textColor = textcolor.uicolor()
|
|
198
|
+
}
|
|
199
|
+
if let fontSize = title.fontSize {
|
|
200
|
+
vfcConfig.title.font = UIFont.systemFont(ofSize: CGFloat(fontSize))
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if let playIcon = config.playIcon {
|
|
204
|
+
if let hidden = playIcon.hidden {
|
|
205
|
+
vfcConfig.playIcon.isHidden = hidden
|
|
206
|
+
}
|
|
207
|
+
if let iconWidth = playIcon.iconWidth {
|
|
208
|
+
vfcConfig.playIcon.iconWidth = CGFloat(iconWidth)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if let position = config.titlePosition {
|
|
212
|
+
switch position {
|
|
213
|
+
case .stacked:
|
|
214
|
+
vfcConfig.titleLayoutConfiguration.titlePosition = .stacked
|
|
215
|
+
default:
|
|
216
|
+
vfcConfig.titleLayoutConfiguration.titlePosition = .nested
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return vfcConfig
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private static func convertToVideoPlayerConentConfiguration(_ config: VideoPlayerConfiguration?) -> VideoPlayerContentConfiguration? {
|
|
224
|
+
guard let config = config else {
|
|
225
|
+
return nil
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var vpcConfig = VideoPlayerContentConfiguration()
|
|
229
|
+
if let playerStyle = config.playerStyle {
|
|
230
|
+
switch playerStyle {
|
|
231
|
+
case .full:
|
|
232
|
+
vpcConfig.playerStyle = .fullBleed
|
|
233
|
+
default:
|
|
234
|
+
vpcConfig.playerStyle = .fit
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if let videoCompleteAction = config.videoCompleteAction {
|
|
238
|
+
switch videoCompleteAction {
|
|
239
|
+
case .loop:
|
|
240
|
+
vpcConfig.videoCompleteAction = .loop
|
|
241
|
+
default:
|
|
242
|
+
vpcConfig.videoCompleteAction = .advanceToNext
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if let showShareButton = config.showShareButton {
|
|
246
|
+
vpcConfig.shareButton.isHidden = !showShareButton
|
|
247
|
+
}
|
|
248
|
+
if let ctaButtonStyle = config.ctaButtonStyle {
|
|
249
|
+
if let backgroundColor = ctaButtonStyle.backgroundColor {
|
|
250
|
+
vpcConfig.ctaButton.backgroundColor = backgroundColor.uicolor()
|
|
251
|
+
}
|
|
252
|
+
if let textcolor = ctaButtonStyle.textColor {
|
|
253
|
+
vpcConfig.ctaButton.textColor = textcolor.uicolor()
|
|
254
|
+
}
|
|
255
|
+
if let fontSize = ctaButtonStyle.fontSize {
|
|
256
|
+
vpcConfig.ctaButton.font = UIFont.systemFont(ofSize: CGFloat(fontSize))
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return vpcConfig
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VideoFeedConfiguration.swift
|
|
3
|
+
// react-native-firework-sdk
|
|
4
|
+
//
|
|
5
|
+
// Created by Jeff Zheng on 2021/12/28.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
@objc
|
|
11
|
+
public class VideoFeedConfiguration: NSObject, Codable {
|
|
12
|
+
var backgroundColor: String?
|
|
13
|
+
var cornerRadius: Int?
|
|
14
|
+
var title: VideoFeedTitleConfiguration?
|
|
15
|
+
var titlePosition: VideoFeedTitlePosition?
|
|
16
|
+
var playIcon: VideoFeedPlayIconConfiguration?
|
|
17
|
+
|
|
18
|
+
class VideoFeedTitleConfiguration: NSObject, Codable {
|
|
19
|
+
public var hidden: Bool?
|
|
20
|
+
public var textColor: String?
|
|
21
|
+
public var fontSize: Int?
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class VideoFeedPlayIconConfiguration: NSObject, Codable {
|
|
25
|
+
public var hidden: Bool?
|
|
26
|
+
public var iconWidth: Int?
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
enum VideoFeedTitlePosition: String, Codable {
|
|
30
|
+
case stacked, nested
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VideoFeedManager.m
|
|
3
|
+
// react-native-firework-sdk
|
|
4
|
+
//
|
|
5
|
+
// Created by Jeff Zheng on 2021/12/22.
|
|
6
|
+
//
|
|
7
|
+
// The FWVideoFeedManager exposes instances of Objective-C (native) classes to JavaScript (JS) as JS objects
|
|
8
|
+
|
|
9
|
+
#import <React/RCTBridgeModule.h>
|
|
10
|
+
#import <React/RCTViewManager.h>
|
|
11
|
+
#import <react_native_firework_sdk/react_native_firework_sdk-Swift.h>
|
|
12
|
+
|
|
13
|
+
@interface RCT_EXTERN_REMAP_MODULE(FWVideoFeed, VideoFeedManager, NSObject)
|
|
14
|
+
|
|
15
|
+
RCT_CUSTOM_VIEW_PROPERTY(source, VideFeedSourceType, VideoFeed) {
|
|
16
|
+
if (json) {
|
|
17
|
+
VideFeedSourceType sourceType = [RCTConvert videoFeedSourceType:json];
|
|
18
|
+
view.sourceType = sourceType;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
RCT_EXPORT_VIEW_PROPERTY(channel, NSString)
|
|
22
|
+
RCT_EXPORT_VIEW_PROPERTY(playlist, NSString)
|
|
23
|
+
RCT_CUSTOM_VIEW_PROPERTY(mode, VideoFeedMode, VideoFeed) {
|
|
24
|
+
if (json) {
|
|
25
|
+
VideoFeedMode mode = [RCTConvert videoFeedMode:json];
|
|
26
|
+
view.mode = mode;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
RCT_CUSTOM_VIEW_PROPERTY(videoFeedConfiguration, VideoFeedConfiguration, VideoFeed) {
|
|
30
|
+
VideoFeedConfiguration *config = [RCTConvert videoFeedConfiguration:json];
|
|
31
|
+
view.feedViewConfig = config;
|
|
32
|
+
}
|
|
33
|
+
RCT_CUSTOM_VIEW_PROPERTY(videoPlayerConfiguration, VideoPlayerConfiguration, VideoFeed) {
|
|
34
|
+
VideoPlayerConfiguration *config = [RCTConvert videoPlayerConfiguration:json];
|
|
35
|
+
view.playerViewConfig = config;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
RCT_EXPORT_VIEW_PROPERTY(onVideoFeedLoadFinished, RCTBubblingEventBlock)
|
|
39
|
+
//RCT_EXPORT_VIEW_PROPERTY(onVideoFeedClick, RCTBubblingEventBlock)
|
|
40
|
+
|
|
41
|
+
RCT_EXPORT_METHOD(refresh:(nonnull NSNumber *)reactTag) {
|
|
42
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
43
|
+
VideoFeed *view = (VideoFeed *)(viewRegistry[reactTag]);
|
|
44
|
+
if (!view || ![view isKindOfClass:[VideoFeed class]]) {
|
|
45
|
+
RCTLogError(@"Cannot find NativeView with tag #%@", reactTag);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
[view refresh];
|
|
49
|
+
}];
|
|
50
|
+
}
|
|
51
|
+
@end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VideoFeedManager.swift
|
|
3
|
+
// react-native-firework-sdk
|
|
4
|
+
//
|
|
5
|
+
// Created by Jeff Zheng on 2021/12/22.
|
|
6
|
+
//
|
|
7
|
+
// The FWVideoFeedManager manipulate FWVideoFeed view,need expose to JavaScript in Objective-C
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
import FireworkVideo
|
|
11
|
+
|
|
12
|
+
@objc(VideoFeedManager)
|
|
13
|
+
class VideoFeedManager: RCTViewManager, VideoFeedViewDelegate {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
override func view() -> UIView! {
|
|
17
|
+
let videFeed = VideoFeed()
|
|
18
|
+
videFeed.delegate = self
|
|
19
|
+
|
|
20
|
+
return videFeed
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override class func requiresMainQueueSetup() -> Bool {
|
|
24
|
+
return true
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// MARK: - FWVideoFeedViewDelegate
|
|
28
|
+
func videoFeedDidLoadFeed(_ view: VideoFeed) {
|
|
29
|
+
view.onVideoFeedLoadFinished?(nil)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func videoFeed(_ view: VideoFeed, didFailToLoadFeed error: VideoFeedError) {
|
|
33
|
+
view.onVideoFeedLoadFinished?(error.jsObject)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// // MARK: - FireworkVideoFeedDelegate
|
|
37
|
+
// func fireworkVideoDidTapVideoThumbnail(_ eventDetails: FeedEventDetails) {
|
|
38
|
+
// view.onVideoFeedClick?(eventDetails.jsObject)
|
|
39
|
+
// }
|
|
40
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VideoPlayerConfiguration.swift
|
|
3
|
+
// react-native-firework-sdk
|
|
4
|
+
//
|
|
5
|
+
// Created by Jeff Zheng on 2021/12/28.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
@objc
|
|
11
|
+
public class VideoPlayerConfiguration: NSObject, Codable {
|
|
12
|
+
var playerStyle: VideoPlayerStyle?
|
|
13
|
+
var videoCompleteAction: VideoPlayerCompleteAction?
|
|
14
|
+
var showShareButton: Bool?
|
|
15
|
+
var ctaButtonStyle: VideoPlayerCTAStyle?
|
|
16
|
+
|
|
17
|
+
public enum VideoPlayerStyle: String, Codable {
|
|
18
|
+
case full, fit
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public enum VideoPlayerCompleteAction: String, Codable {
|
|
22
|
+
case loop, advanceToNext
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public class VideoPlayerCTAStyle: NSObject, Codable {
|
|
26
|
+
var backgroundColor: String?
|
|
27
|
+
var textColor: String?
|
|
28
|
+
var fontSize: Int?
|
|
29
|
+
}
|
|
30
|
+
}
|