react-native-firework-sdk 2.0.0-beta.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWFontInfoModel.kt +10 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWFontInfoModelDeserializer.kt +21 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWSDKInitOptionsModel.kt +11 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWSDKInitOptionsModelDeserializer.kt +24 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWSystemTypeface.kt +9 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModel.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModelDeserializer.kt +4 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +24 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FireworkSDKInterface.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +29 -12
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWConfigUtil.kt +33 -6
- package/ios/Components/VideoFeed.swift +12 -23
- package/ios/Components/VideoPlayerConfiguration.swift +0 -5
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +4 -0
- package/ios/Models/NativeToRN/FireworkEventName.swift +1 -0
- package/ios/Models/RNToNative/RCTConvert+FireworkSDKModule.swift +20 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +30 -5
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +13 -3
- package/ios/Modules/FireworkSDKModule/SDKInitOptions.swift +29 -0
- package/lib/commonjs/FireworkSDK.js +42 -26
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/StoryBlock.js +40 -13
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +42 -27
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/AndroidFontInfo.js +2 -0
- package/lib/commonjs/models/AndroidFontInfo.js.map +1 -0
- package/lib/commonjs/models/FWEventName.js +1 -0
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/SDKInitOptions.js +2 -0
- package/lib/commonjs/models/SDKInitOptions.js.map +1 -0
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/FireworkSDK.js +43 -25
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/StoryBlock.js +43 -13
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +46 -26
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/AndroidFontInfo.js +2 -0
- package/lib/module/models/AndroidFontInfo.js.map +1 -0
- package/lib/module/models/FWEventName.js +1 -0
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/SDKInitOptions.js +2 -0
- package/lib/module/models/SDKInitOptions.js.map +1 -0
- package/lib/module/modules/FireworkSDKModule.js +1 -2
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/typescript/FireworkSDK.d.ts +23 -14
- package/lib/typescript/LiveStream.d.ts +2 -2
- package/lib/typescript/VideoShopping.d.ts +4 -4
- package/lib/typescript/components/StoryBlock.d.ts +18 -5
- package/lib/typescript/components/VideoFeed.d.ts +24 -8
- package/lib/typescript/index.d.ts +7 -3
- package/lib/typescript/models/AdBadgeConfiguration.d.ts +1 -1
- package/lib/typescript/models/AndroidFontInfo.d.ts +14 -0
- package/lib/typescript/models/FWEventName.d.ts +1 -0
- package/lib/typescript/models/IOSFontInfo.d.ts +2 -2
- package/lib/typescript/models/SDKInitOptions.d.ts +6 -0
- package/lib/typescript/models/StoryBlockSource.d.ts +1 -1
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +9 -12
- package/lib/typescript/models/VideoFeedSource.d.ts +1 -1
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +4 -9
- package/lib/typescript/modules/FireworkSDKModule.d.ts +4 -3
- package/package.json +9 -5
- package/src/FireworkSDK.ts +42 -24
- package/src/VideoShopping.ts +3 -7
- package/src/components/StoryBlock.tsx +40 -12
- package/src/components/VideoFeed.tsx +44 -22
- package/src/index.ts +10 -1
- package/src/models/AndroidFontInfo.ts +14 -0
- package/src/models/FWEventName.ts +1 -0
- package/src/models/SDKInitOptions.ts +7 -0
- package/src/models/VideoFeedConfiguration.ts +8 -11
- package/src/models/VideoPlayerConfiguration.ts +1 -7
- package/src/modules/FireworkSDKModule.ts +6 -6
package/README.md
CHANGED
package/android/build.gradle
CHANGED
|
@@ -151,7 +151,7 @@ dependencies {
|
|
|
151
151
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
152
152
|
|
|
153
153
|
|
|
154
|
-
def fireworkSdkVersion = "6.0.0
|
|
154
|
+
def fireworkSdkVersion = "6.0.0"
|
|
155
155
|
implementation "com.firework:sdk:$fireworkSdkVersion"
|
|
156
156
|
implementation "com.firework.external.imageloading:glide:$fireworkSdkVersion"
|
|
157
157
|
implementation "com.firework.external.livestream:singleHostPlayer:$fireworkSdkVersion"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.fireworksdk.bridge.models
|
|
2
|
+
|
|
3
|
+
import org.json.JSONObject
|
|
4
|
+
|
|
5
|
+
object FWFontInfoModelDeserializer {
|
|
6
|
+
|
|
7
|
+
private const val IS_CUSTOM_KEY = "isCustom"
|
|
8
|
+
private const val TYPEFACE_NAME_KEY = "typefaceName"
|
|
9
|
+
|
|
10
|
+
fun deserialize(responseJson: JSONObject?): FWFontInfoModel? {
|
|
11
|
+
responseJson ?: return null
|
|
12
|
+
|
|
13
|
+
val isCustom = responseJson.optBoolean(IS_CUSTOM_KEY, false)
|
|
14
|
+
val typefaceName = responseJson.optString(TYPEFACE_NAME_KEY)
|
|
15
|
+
|
|
16
|
+
return FWFontInfoModel(
|
|
17
|
+
isCustom = isCustom,
|
|
18
|
+
typefaceName = typefaceName,
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package com.fireworksdk.bridge.models
|
|
2
|
+
|
|
3
|
+
import android.os.Parcelable
|
|
4
|
+
import kotlinx.android.parcel.Parcelize
|
|
5
|
+
|
|
6
|
+
@Parcelize
|
|
7
|
+
data class FWSDKInitOptionsModel(
|
|
8
|
+
val userId: String? = null,
|
|
9
|
+
val shareBaseURL: String? = null,
|
|
10
|
+
val videoLaunchBehavior: String? = null,
|
|
11
|
+
) : Parcelable
|
package/android/src/main/java/com/fireworksdk/bridge/models/FWSDKInitOptionsModelDeserializer.kt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.fireworksdk.bridge.models
|
|
2
|
+
|
|
3
|
+
import org.json.JSONObject
|
|
4
|
+
|
|
5
|
+
object FWSDKInitOptionsModelDeserializer {
|
|
6
|
+
|
|
7
|
+
private const val USER_ID_KEY = "userId"
|
|
8
|
+
private const val SHARE_BASE_URL_KEY = "shareBaseURL"
|
|
9
|
+
private const val VIDEO_LAUNCH_BEHAVIOR_KEY = "videoLaunchBehavior"
|
|
10
|
+
|
|
11
|
+
fun deserialize(responseJson: JSONObject?): FWSDKInitOptionsModel? {
|
|
12
|
+
responseJson?: return null
|
|
13
|
+
|
|
14
|
+
val userId = responseJson.optString(USER_ID_KEY)
|
|
15
|
+
val shareBaseURL = responseJson.optString(SHARE_BASE_URL_KEY)
|
|
16
|
+
val videoLaunchBehavior = responseJson.optString(VIDEO_LAUNCH_BEHAVIOR_KEY)
|
|
17
|
+
|
|
18
|
+
return FWSDKInitOptionsModel(
|
|
19
|
+
userId = userId,
|
|
20
|
+
shareBaseURL = shareBaseURL,
|
|
21
|
+
videoLaunchBehavior = videoLaunchBehavior,
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
}
|
package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModelDeserializer.kt
CHANGED
|
@@ -16,6 +16,7 @@ object FWVideoFeedConfigModelDeserializer {
|
|
|
16
16
|
private const val HIDDEN_KEY = "hidden"
|
|
17
17
|
private const val TEXT_COLOR_KEY = "textColor"
|
|
18
18
|
private const val FONT_SIZE_KEY = "fontSize"
|
|
19
|
+
private const val FONT_INFO_KEY = "androidFontInfo"
|
|
19
20
|
|
|
20
21
|
private const val ICON_WIDTH_KEY = "iconWidth"
|
|
21
22
|
|
|
@@ -47,11 +48,13 @@ object FWVideoFeedConfigModelDeserializer {
|
|
|
47
48
|
val hidden = titleJson?.optBoolean(HIDDEN_KEY)
|
|
48
49
|
val textColor = titleJson?.optString(TEXT_COLOR_KEY)
|
|
49
50
|
val fontSize = titleJson?.optInt(FONT_SIZE_KEY)
|
|
51
|
+
val fontInfo = FWFontInfoModelDeserializer.deserialize(titleJson?.optJSONObject(FONT_INFO_KEY))
|
|
50
52
|
|
|
51
53
|
return FWVideoFeedConfigModel.FWTitleModel(
|
|
52
54
|
hidden = hidden,
|
|
53
55
|
textColor = textColor,
|
|
54
|
-
fontSize = fontSize
|
|
56
|
+
fontSize = fontSize,
|
|
57
|
+
fontInfo = fontInfo
|
|
55
58
|
)
|
|
56
59
|
}
|
|
57
60
|
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt
CHANGED
|
@@ -10,6 +10,7 @@ import com.facebook.react.uimanager.annotations.ReactProp
|
|
|
10
10
|
import com.fireworksdk.bridge.constants.FWCommandConstant
|
|
11
11
|
import com.facebook.react.common.MapBuilder
|
|
12
12
|
import com.firework.videofeed.FeedItemClickListener
|
|
13
|
+
import com.firework.videofeed.FeedViewState
|
|
13
14
|
import com.fireworksdk.bridge.components.videofeed.FWVideoFeed
|
|
14
15
|
import com.fireworksdk.bridge.models.FWFeedViewEventName
|
|
15
16
|
import com.fireworksdk.bridge.models.FWVideoFeedConfigModelDeserializer
|
|
@@ -32,6 +33,7 @@ class FWVideoFeedManager : SimpleViewManager<FWVideoFeed>() {
|
|
|
32
33
|
override fun createViewInstance(reactContext: ThemedReactContext): FWVideoFeed {
|
|
33
34
|
this.reactContext = reactContext
|
|
34
35
|
videoFeed = FWVideoFeed(reactContext.currentActivity as Activity)
|
|
36
|
+
addVideoFeedListener(reactContext, videoFeed)
|
|
35
37
|
return videoFeed
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -43,7 +45,6 @@ class FWVideoFeedManager : SimpleViewManager<FWVideoFeed>() {
|
|
|
43
45
|
override fun onAfterUpdateTransaction(view: FWVideoFeed) {
|
|
44
46
|
super.onAfterUpdateTransaction(view)
|
|
45
47
|
view.afterUpdateTransaction()
|
|
46
|
-
addVideoFeedListener(reactContext, view)
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
@ReactProp(name = "source")
|
|
@@ -120,6 +121,28 @@ class FWVideoFeedManager : SimpleViewManager<FWVideoFeed>() {
|
|
|
120
121
|
)
|
|
121
122
|
FWEventUtils.sendVideoFeedClickEvent(reactContext, fwVideoFeedItemDetailsModel)
|
|
122
123
|
})
|
|
124
|
+
|
|
125
|
+
videoFeedView.setOnFeedViewStateListener { feedViewState ->
|
|
126
|
+
when (feedViewState) {
|
|
127
|
+
is FeedViewState.Loading -> {
|
|
128
|
+
FWLogUtils.d { "FeedViewState.Loading" }
|
|
129
|
+
}
|
|
130
|
+
is FeedViewState.LoadData -> {
|
|
131
|
+
FWLogUtils.d { "FeedViewState.LoadData" }
|
|
132
|
+
FWEventUtils.receiveVideoFeedLoadFinishedSuccessEvent(reactContext, videoFeed.id)
|
|
133
|
+
}
|
|
134
|
+
is FeedViewState.ScrollToPosition -> {
|
|
135
|
+
FWLogUtils.d { "FeedViewState.ScrollToPosition" }
|
|
136
|
+
}
|
|
137
|
+
is FeedViewState.OpenFeedElementAtIndex -> {
|
|
138
|
+
FWLogUtils.d { "FeedViewState.OpenFeedElementAtIndex" }
|
|
139
|
+
}
|
|
140
|
+
is FeedViewState.Error -> {
|
|
141
|
+
FWLogUtils.d { "FeedViewState.Error" }
|
|
142
|
+
FWEventUtils.receiveVideoFeedLoadFinishedFailedEvent(reactContext, videoFeed.id, feedViewState.message, feedViewState.message)
|
|
143
|
+
}
|
|
144
|
+
else -> {}
|
|
145
|
+
}}
|
|
123
146
|
}
|
|
124
147
|
|
|
125
148
|
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FireworkSDKInterface.kt
CHANGED
|
@@ -5,7 +5,7 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
5
5
|
|
|
6
6
|
interface FireworkSDKInterface {
|
|
7
7
|
|
|
8
|
-
fun init(
|
|
8
|
+
fun init(config: ReadableMap?, promise: Promise)
|
|
9
9
|
fun openVideoPlayer(url: String, config: ReadableMap?)
|
|
10
10
|
fun setShareBaseURL(url: String?, promise: Promise)
|
|
11
11
|
fun setAdBadgeConfiguration(config: ReadableMap?, promise: Promise)
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt
CHANGED
|
@@ -19,10 +19,8 @@ import com.firework.player.lifecycle.PlaybackLifecycleObserver
|
|
|
19
19
|
import com.firework.sdk.FireworkSdk
|
|
20
20
|
import com.firework.sdk.FireworkSdkConfig
|
|
21
21
|
import com.fireworksdk.bridge.FWInitializationProvider
|
|
22
|
-
import com.fireworksdk.bridge.
|
|
23
|
-
import com.fireworksdk.bridge.models
|
|
24
|
-
import com.fireworksdk.bridge.models.FWVideoFeedPropsModel
|
|
25
|
-
import com.fireworksdk.bridge.models.FWVideoPlayerConfigModelDeserializer
|
|
22
|
+
import com.fireworksdk.bridge.constants.FWVideoPlayerConstant
|
|
23
|
+
import com.fireworksdk.bridge.models.*
|
|
26
24
|
import com.fireworksdk.bridge.reactnative.models.FireworkSDKInterface
|
|
27
25
|
import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
|
|
28
26
|
import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
@@ -48,14 +46,19 @@ class FireworkSDKModule(
|
|
|
48
46
|
* It is recommended that you initialize FW SDK when application created. FW SDK must be initialized
|
|
49
47
|
* before using any of the features.
|
|
50
48
|
*
|
|
51
|
-
* @param userId
|
|
49
|
+
* @param config.userId an id to uniquely identify device or user. If you don't have a unique id
|
|
52
50
|
* We will use hashed Android_ID as it is
|
|
53
51
|
* If id passed is not unique, it will affect the quality of content recommended to the user.
|
|
54
52
|
*/
|
|
55
53
|
@ReactMethod
|
|
56
|
-
override fun init(
|
|
57
|
-
|
|
54
|
+
override fun init(config: ReadableMap?, promise: Promise) {
|
|
55
|
+
val configMap = config?.toHashMap() ?: hashMapOf()
|
|
56
|
+
val jsonObject = JSONObject(configMap)
|
|
57
|
+
val sdkInitOptionsModel = FWSDKInitOptionsModelDeserializer.deserialize(jsonObject)
|
|
58
|
+
|
|
59
|
+
initSdk(sdkInitOptionsModel)
|
|
58
60
|
handleCustomCTAClick()
|
|
61
|
+
promise.resolve(Arguments.createMap())
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
/**
|
|
@@ -117,7 +120,7 @@ class FireworkSDKModule(
|
|
|
117
120
|
handleVideoPlaybackEvent()
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
private fun initSdk(
|
|
123
|
+
private fun initSdk(sdkInitOptions: FWSDKInitOptionsModel?) {
|
|
121
124
|
val clientId = getAppid()
|
|
122
125
|
if (clientId.isNullOrBlank()) {
|
|
123
126
|
val errorMsg = "The appid is invalid"
|
|
@@ -125,10 +128,13 @@ class FireworkSDKModule(
|
|
|
125
128
|
FWEventUtils.sendInitFailedEvent(reactApplicationContext, errorMsg)
|
|
126
129
|
return
|
|
127
130
|
}
|
|
131
|
+
val userId = sdkInitOptions?.userId
|
|
128
132
|
|
|
129
133
|
val uid = if (userId.isNullOrBlank()) { getHashedAndroidId() } else userId
|
|
134
|
+
val shareBaseURL = sdkInitOptions?.shareBaseURL
|
|
135
|
+
val videoLaunchBehavior = sdkInitOptions?.videoLaunchBehavior
|
|
130
136
|
|
|
131
|
-
val
|
|
137
|
+
val configBuilder = FireworkSdkConfig.Builder(reactApplicationContext)
|
|
132
138
|
.checksumRequired(false)
|
|
133
139
|
.clientId(clientId)
|
|
134
140
|
.userId(uid)
|
|
@@ -136,9 +142,20 @@ class FireworkSDKModule(
|
|
|
136
142
|
.addLivestreamPlayerInitializer(LivestreamPlayerInitializer())
|
|
137
143
|
.addLivestreamPlayerInitializer(MultihostLivestreamPlayerInitializer())
|
|
138
144
|
.enableCache(true)
|
|
139
|
-
.shareBaseUrl("https://www.mytest.com")
|
|
140
|
-
.muteOnLaunch(true)
|
|
141
|
-
|
|
145
|
+
// .shareBaseUrl("https://www.mytest.com")
|
|
146
|
+
// .muteOnLaunch(true)
|
|
147
|
+
shareBaseURL?.let {
|
|
148
|
+
configBuilder.shareBaseUrl(it)
|
|
149
|
+
}
|
|
150
|
+
when (videoLaunchBehavior) {
|
|
151
|
+
FWVideoPlayerConstant.FW_PLAYER_LAUNCH_BEHAVIOR_DEFAULT -> {}
|
|
152
|
+
FWVideoPlayerConstant.FW_PLAYER_LAUNCH_BEHAVIOR_MUTE_ON_FIRST_LAUNCH -> {
|
|
153
|
+
configBuilder.muteOnLaunch(true)
|
|
154
|
+
}
|
|
155
|
+
else -> {}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
val config = configBuilder.build()
|
|
142
159
|
|
|
143
160
|
FireworkSdk.init(
|
|
144
161
|
config,
|
|
@@ -10,13 +10,10 @@ import com.firework.common.cta.CtaDelayUnit
|
|
|
10
10
|
import com.firework.common.feed.FeedLayout
|
|
11
11
|
import com.firework.common.feed.FeedResource
|
|
12
12
|
import com.firework.common.feed.FeedTitlePosition
|
|
13
|
-
import com.firework.
|
|
13
|
+
import com.firework.viewoptions.*
|
|
14
14
|
import com.fireworksdk.bridge.FWInitializationProvider
|
|
15
15
|
import com.fireworksdk.bridge.constants.FWVideoPlayerConstant
|
|
16
|
-
import com.fireworksdk.bridge.models
|
|
17
|
-
import com.fireworksdk.bridge.models.FWVideoFeedPropsModel
|
|
18
|
-
import com.fireworksdk.bridge.models.FWVideoFeedSource
|
|
19
|
-
import com.fireworksdk.bridge.models.FWVideoFeedTitlePosition
|
|
16
|
+
import com.fireworksdk.bridge.models.*
|
|
20
17
|
|
|
21
18
|
object FWConfigUtil {
|
|
22
19
|
|
|
@@ -86,6 +83,7 @@ object FWConfigUtil {
|
|
|
86
83
|
val hidden = title.hidden
|
|
87
84
|
val textColor = title.textColor
|
|
88
85
|
val fontSize = title.fontSize
|
|
86
|
+
val fontInfo = title.fontInfo
|
|
89
87
|
if (hidden != null) {
|
|
90
88
|
titleOptionBuilder.showFeedTitle(!hidden)
|
|
91
89
|
}
|
|
@@ -95,6 +93,35 @@ object FWConfigUtil {
|
|
|
95
93
|
if (fontSize != null && fontSize > 0) {
|
|
96
94
|
titleOptionBuilder.feedTitleTextSize(FWCommonUtil.spToPx(fontSize.toFloat(), context))
|
|
97
95
|
}
|
|
96
|
+
fontInfo?.let { font ->
|
|
97
|
+
font.typefaceName?.let {
|
|
98
|
+
var typeface = Typeface.DEFAULT
|
|
99
|
+
if (font.isCustom == true) {
|
|
100
|
+
typeface = Typeface.createFromAsset(context.assets, it)
|
|
101
|
+
} else {
|
|
102
|
+
when (it) {
|
|
103
|
+
FWSystemTypeface.DefaultBold.rawValue -> {
|
|
104
|
+
typeface = Typeface.DEFAULT_BOLD
|
|
105
|
+
titleOptionBuilder.feedTitleTextTypeface(typeface)
|
|
106
|
+
}
|
|
107
|
+
FWSystemTypeface.SansSerif.rawValue -> {
|
|
108
|
+
typeface = Typeface.SANS_SERIF
|
|
109
|
+
titleOptionBuilder.feedTitleTextTypeface(typeface)
|
|
110
|
+
}
|
|
111
|
+
FWSystemTypeface.Serif.rawValue -> {
|
|
112
|
+
typeface = Typeface.SERIF
|
|
113
|
+
titleOptionBuilder.feedTitleTextTypeface(typeface)
|
|
114
|
+
}
|
|
115
|
+
FWSystemTypeface.Monospace.rawValue -> {
|
|
116
|
+
typeface = Typeface.MONOSPACE
|
|
117
|
+
titleOptionBuilder.feedTitleTextTypeface(typeface)
|
|
118
|
+
}
|
|
119
|
+
else -> {}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
titleOptionBuilder.feedTitleTextTypeface(typeface)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
98
125
|
}
|
|
99
126
|
|
|
100
127
|
when (videoFeedPropsModel.videoFeedConfiguration?.titlePosition) {
|
|
@@ -297,7 +324,7 @@ object FWConfigUtil {
|
|
|
297
324
|
|
|
298
325
|
return AdBadgeOption.Builder()
|
|
299
326
|
// .adBadgeBackColor(Color.parseColor("#FF6200EE"))
|
|
300
|
-
|
|
327
|
+
.adBadgeTextColor(Color.parseColor("#FFFFFFFF"))
|
|
301
328
|
.adBadgeLabel(AdBadgeTextType.SPONSORED)
|
|
302
329
|
.adBadgeIsHidden(false)
|
|
303
330
|
.adBadgeShowOnThumbnails(false)
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// Created by Jeff Zheng on 2021/12/22.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
+
// swiftlint:disable file_length
|
|
9
|
+
|
|
8
10
|
import FireworkVideo
|
|
9
11
|
import UIKit
|
|
10
12
|
|
|
@@ -180,15 +182,15 @@ public class VideoFeed: UIView, VideoFeedViewControllerDelegate {
|
|
|
180
182
|
return
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
if let subView = feedVC.view.subviews.first {
|
|
184
|
-
let constraints = feedVC.view.constraints
|
|
185
|
-
for constraint in constraints {
|
|
186
|
-
if (constraint.firstItem as? NSObject) == subView || (constraint.secondItem as? NSObject) == subView {
|
|
187
|
-
constraint.isActive = false
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
NSLayoutConstraint.activate(subView.constraints(equalTo: feedVC.view))
|
|
191
|
-
}
|
|
185
|
+
// if let subView = feedVC.view.subviews.first {
|
|
186
|
+
// let constraints = feedVC.view.constraints
|
|
187
|
+
// for constraint in constraints {
|
|
188
|
+
// if (constraint.firstItem as? NSObject) == subView || (constraint.secondItem as? NSObject) == subView {
|
|
189
|
+
// constraint.isActive = false
|
|
190
|
+
// }
|
|
191
|
+
// }
|
|
192
|
+
// NSLayoutConstraint.activate(subView.constraints(equalTo: feedVC.view))
|
|
193
|
+
// }
|
|
192
194
|
|
|
193
195
|
var viewConfiguration = convertToVideoFeedContentConfiguration()
|
|
194
196
|
if viewConfiguration.itemView.autoplay.isEnabled {
|
|
@@ -357,7 +359,7 @@ extension VideoFeed {
|
|
|
357
359
|
if let showMuteButton = config.showMuteButton {
|
|
358
360
|
vpcConfig.muteButton.isHidden = !showMuteButton
|
|
359
361
|
}
|
|
360
|
-
if let launchBehavior =
|
|
362
|
+
if let launchBehavior = gVideoLaunchBehavior {
|
|
361
363
|
vpcConfig.onFirstLaunch = launchBehavior.behavior()
|
|
362
364
|
}
|
|
363
365
|
|
|
@@ -424,16 +426,3 @@ extension VideoFeed {
|
|
|
424
426
|
return videoConfig
|
|
425
427
|
}
|
|
426
428
|
}
|
|
427
|
-
|
|
428
|
-
// swiftlint:disable file_length
|
|
429
|
-
|
|
430
|
-
extension VideoPlayerConfiguration.VideoLaunchBehavior {
|
|
431
|
-
func behavior() -> VideoPlayerContentConfiguration.VideoLaunchBehavior {
|
|
432
|
-
switch self {
|
|
433
|
-
case .muteOnFirstLaunch:
|
|
434
|
-
return .muteOnFirstLaunch
|
|
435
|
-
default:
|
|
436
|
-
return .`default`
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
@@ -15,7 +15,6 @@ public class VideoPlayerConfiguration: NSObject, Codable {
|
|
|
15
15
|
var ctaButtonStyle: VideoPlayerCTAStyle?
|
|
16
16
|
var showPlaybackButton: Bool?
|
|
17
17
|
var showMuteButton: Bool?
|
|
18
|
-
var launchBehavior: VideoLaunchBehavior?
|
|
19
18
|
var showBranding: Bool?
|
|
20
19
|
var ctaDelay: VideoPlayerCTADelay?
|
|
21
20
|
var ctaHighlightDelay: VideoPlayerCTADelay?
|
|
@@ -35,10 +34,6 @@ public class VideoPlayerConfiguration: NSObject, Codable {
|
|
|
35
34
|
var iOSFontInfo: FontInfo?
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
public enum VideoLaunchBehavior: String, Codable {
|
|
39
|
-
case `default`, muteOnFirstLaunch
|
|
40
|
-
}
|
|
41
|
-
|
|
42
37
|
public enum VideoPlayerCTADelayType: String, Codable {
|
|
43
38
|
case constant, percentage
|
|
44
39
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
+
892C397229B82757003BDD99 /* SDKInitOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 892C397129B82757003BDD99 /* SDKInitOptions.swift */; };
|
|
10
11
|
89335CA628E29D3A00B84BC7 /* TrackPurchaseParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89335CA528E29D3A00B84BC7 /* TrackPurchaseParameters.swift */; };
|
|
11
12
|
8953CF5E2993E0D200F7413E /* UINavigationController+FWSwizzle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8953CF5D2993E0D200F7413E /* UINavigationController+FWSwizzle.swift */; };
|
|
12
13
|
8953CF602993E3B200F7413E /* FWSwizzleUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8953CF5F2993E3B200F7413E /* FWSwizzleUtil.swift */; };
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
/* Begin PBXFileReference section */
|
|
66
67
|
134814201AA4EA6300B7C361 /* libFireworkSdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libFireworkSdk.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
67
68
|
1F6F718A2771B48100224AF3 /* FireworkSdk-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FireworkSdk-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
69
|
+
892C397129B82757003BDD99 /* SDKInitOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDKInitOptions.swift; sourceTree = "<group>"; };
|
|
68
70
|
89335CA528E29D3A00B84BC7 /* TrackPurchaseParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackPurchaseParameters.swift; sourceTree = "<group>"; };
|
|
69
71
|
8953CF5D2993E0D200F7413E /* UINavigationController+FWSwizzle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+FWSwizzle.swift"; sourceTree = "<group>"; };
|
|
70
72
|
8953CF5F2993E3B200F7413E /* FWSwizzleUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FWSwizzleUtil.swift; sourceTree = "<group>"; };
|
|
@@ -247,6 +249,7 @@
|
|
|
247
249
|
897523812817DEF80070EBB6 /* AdBadgeConfiguration.swift */,
|
|
248
250
|
897523822817DEF80070EBB6 /* FireworkSDKModule+CTA.swift */,
|
|
249
251
|
897523832817DEF80070EBB6 /* FireworkSDKModule.m */,
|
|
252
|
+
892C397129B82757003BDD99 /* SDKInitOptions.swift */,
|
|
250
253
|
);
|
|
251
254
|
path = FireworkSDKModule;
|
|
252
255
|
sourceTree = "<group>";
|
|
@@ -346,6 +349,7 @@
|
|
|
346
349
|
897523902817DEF80070EBB6 /* FWNavigatorProtocol.swift in Sources */,
|
|
347
350
|
897523882817DEF80070EBB6 /* UIView+Constraints.swift in Sources */,
|
|
348
351
|
897523982817DEF80070EBB6 /* ShoppingModule.swift in Sources */,
|
|
352
|
+
892C397229B82757003BDD99 /* SDKInitOptions.swift in Sources */,
|
|
349
353
|
896A8EB928E3DCCA007E51F8 /* AdConfiguration.swift in Sources */,
|
|
350
354
|
8975239C2817DEF80070EBB6 /* AdBadgeConfiguration.swift in Sources */,
|
|
351
355
|
897523942817DEF80070EBB6 /* FWCartViewController.swift in Sources */,
|
|
@@ -14,6 +14,7 @@ enum FWEventName: String, CaseIterable {
|
|
|
14
14
|
case videoPlayback = "fw:video-playback"
|
|
15
15
|
case videoFeedClick = "fw:video-feed-click"
|
|
16
16
|
case shareBaseURLUpdated = "fw:share-base-url-updated" // emitted in JS side
|
|
17
|
+
case videoLaunchBehaviorUpdated = "fw:video-launch-behavior-updated" // emitted in JS side
|
|
17
18
|
case adBadgeConfigurationUpdated = "fw:ad-badge-configuration-updated" // emitted in JS side
|
|
18
19
|
case logMessage = "fw:log-message"
|
|
19
20
|
}
|
|
@@ -101,4 +101,24 @@ extension RCTConvert {
|
|
|
101
101
|
|
|
102
102
|
return result
|
|
103
103
|
}
|
|
104
|
+
|
|
105
|
+
static func sdkInitOptions(_ options: [String: AnyObject]?) -> SDKInitOptions? {
|
|
106
|
+
guard let rOptions = options else {
|
|
107
|
+
return nil
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let jsonData = try? JSONSerialization.data(withJSONObject: rOptions, options: .prettyPrinted)
|
|
111
|
+
guard let rJsonData = jsonData else {
|
|
112
|
+
return nil
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
var result: SDKInitOptions?
|
|
116
|
+
do {
|
|
117
|
+
result = try JSONDecoder().decode(SDKInitOptions.self, from: rJsonData)
|
|
118
|
+
} catch let error {
|
|
119
|
+
print(error.localizedDescription)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return result
|
|
123
|
+
}
|
|
104
124
|
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// Created by Big Bear Xiong on 2022/4/21.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
+
// swiftlint:disable file_length
|
|
9
|
+
|
|
8
10
|
import FireworkVideo
|
|
9
11
|
|
|
10
12
|
private struct PlayerInfo {
|
|
@@ -187,7 +189,7 @@ class FWNavigatorModule: RCTEventEmitter, FWNavigator {
|
|
|
187
189
|
as? FWNavigatorContainerViewController,
|
|
188
190
|
navigatorContainerVC.presentingViewController != nil {
|
|
189
191
|
resolver(true)
|
|
190
|
-
} else if
|
|
192
|
+
} else if gCartViewController != nil {
|
|
191
193
|
resolver(true)
|
|
192
194
|
} else if let presentedVC = RCTPresentedViewController(),
|
|
193
195
|
FWNavigatorModule.isIOSSDKViewController(presentedVC),
|
|
@@ -252,14 +254,37 @@ class FWNavigatorModule: RCTEventEmitter, FWNavigator {
|
|
|
252
254
|
}
|
|
253
255
|
|
|
254
256
|
extension FWNavigatorModule {
|
|
257
|
+
private static func isTargetIOSSDKImage(_ image: UIImage, targetImageName: String) -> Bool {
|
|
258
|
+
let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
|
|
259
|
+
let targetImage = UIImage(named: targetImageName, in: iOSSDKBundle, compatibleWith: nil)
|
|
260
|
+
|
|
261
|
+
if image.isEqual(targetImage) {
|
|
262
|
+
return true
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if let cgImage = image.cgImage,
|
|
266
|
+
let targetCgImage = targetImage?.cgImage,
|
|
267
|
+
cgImage == targetCgImage {
|
|
268
|
+
return true
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if let ciImage = image.ciImage,
|
|
272
|
+
let targetCiImage = targetImage?.ciImage,
|
|
273
|
+
ciImage == targetCiImage {
|
|
274
|
+
return true
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return false
|
|
278
|
+
}
|
|
279
|
+
|
|
255
280
|
private static func getPlayerExitButtonInfo(view: UIView) -> PlayerExitButtonInfo? {
|
|
256
|
-
if let button = view as? UIButton, let
|
|
281
|
+
if let button = view as? UIButton, let image = button.image(for: .normal) {
|
|
257
282
|
let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
|
|
258
|
-
if
|
|
283
|
+
if isTargetIOSSDKImage(image, targetImageName: "closeX") {
|
|
259
284
|
return PlayerExitButtonInfo(button: button, type: .close)
|
|
260
285
|
}
|
|
261
|
-
|
|
262
|
-
if
|
|
286
|
+
|
|
287
|
+
if isTargetIOSSDKImage(image, targetImageName: "down-arrow-light") {
|
|
263
288
|
return PlayerExitButtonInfo(button: button, type: .floating)
|
|
264
289
|
}
|
|
265
290
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
@interface RCT_EXTERN_REMAP_MODULE(FireworkSDK, FireworkSDKModule, NSObject)
|
|
12
12
|
|
|
13
|
-
_RCT_EXTERN_REMAP_METHOD(init, initializeSDK:(
|
|
13
|
+
_RCT_EXTERN_REMAP_METHOD(init, initializeSDK:(NSDictionary * __nullable)options resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter, NO)
|
|
14
14
|
RCT_EXTERN_METHOD(openVideoPlayer:(NSString *)url config:(NSDictionary *)config)
|
|
15
15
|
RCT_EXTERN_METHOD(setCustomCTAClickEnabled:(BOOL)enabled)
|
|
16
16
|
RCT_EXTERN_METHOD(setCustomCTALinkContentPageRouteName:(NSString *)name resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
@@ -11,6 +11,7 @@ import FireworkVideo
|
|
|
11
11
|
var gShareBaseURL: String?
|
|
12
12
|
var gAdBadgeConfiguration: AdBadgeConfiguration?
|
|
13
13
|
var gAppComponentName: String?
|
|
14
|
+
var gVideoLaunchBehavior: VideoLaunchBehavior?
|
|
14
15
|
|
|
15
16
|
@objc(FireworkSDKModule)
|
|
16
17
|
class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
|
|
@@ -34,8 +35,12 @@ class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
|
|
|
34
35
|
return DispatchQueue.main
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
@objc(initializeSDK:)
|
|
38
|
-
func initializeSDK(
|
|
38
|
+
@objc(initializeSDK:resolver:rejecter:)
|
|
39
|
+
func initializeSDK(
|
|
40
|
+
_ options: [String: AnyObject]? = nil,
|
|
41
|
+
resolver: RCTPromiseResolveBlock,
|
|
42
|
+
rejecter: RCTPromiseRejectBlock
|
|
43
|
+
) {
|
|
39
44
|
#if DEBUG
|
|
40
45
|
let formatter = DateFormatter()
|
|
41
46
|
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
@@ -45,11 +50,16 @@ class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
|
|
|
45
50
|
|
|
46
51
|
sendEvent(withName: FWEventName.logMessage.rawValue, body: ["message": message])
|
|
47
52
|
#endif
|
|
53
|
+
let sdkInitOptions = RCTConvert.sdkInitOptions(options)
|
|
54
|
+
gVideoLaunchBehavior = sdkInitOptions?.videoLaunchBehavior
|
|
55
|
+
gShareBaseURL = sdkInitOptions?.shareBaseURL
|
|
48
56
|
|
|
49
|
-
FireworkVideoSDK.initializeSDK(delegate: self, userID: userId)
|
|
57
|
+
FireworkVideoSDK.initializeSDK(delegate: self, userID: sdkInitOptions?.userId)
|
|
50
58
|
FireworkVideoSDK.ctaDelegate = self
|
|
51
59
|
FireworkVideoSDK.eventTracking.videoPlaybackDelegate = self
|
|
52
60
|
FireworkVideoSDK.eventTracking.feedDelegate = self
|
|
61
|
+
|
|
62
|
+
resolver([:])
|
|
53
63
|
}
|
|
54
64
|
|
|
55
65
|
@objc(openVideoPlayer:config:)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// SDKInitOptions.swift
|
|
3
|
+
//
|
|
4
|
+
// Created by linjie jiang on 2023/3/8.
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Foundation
|
|
8
|
+
import FireworkVideo
|
|
9
|
+
|
|
10
|
+
struct SDKInitOptions: Codable {
|
|
11
|
+
var userId: String?
|
|
12
|
+
var shareBaseURL: String?
|
|
13
|
+
var videoLaunchBehavior: VideoLaunchBehavior?
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public enum VideoLaunchBehavior: String, Codable {
|
|
17
|
+
case `default`, muteOnFirstLaunch
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
extension VideoLaunchBehavior {
|
|
21
|
+
func behavior() -> VideoPlayerContentConfiguration.VideoLaunchBehavior {
|
|
22
|
+
switch self {
|
|
23
|
+
case .muteOnFirstLaunch:
|
|
24
|
+
return .muteOnFirstLaunch
|
|
25
|
+
default:
|
|
26
|
+
return .`default`
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|