react-native-firework-sdk 2.4.1-beta.1 → 2.4.2-beta.1
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/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/FireworkVideoUI +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Info.plist +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/FireworkVideoUI +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Info.plist +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/_CodeSignature/CodeResources +1 -1
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWStoryBlockManager.kt +4 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWNavigatorInterface.kt +2 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +41 -13
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWContainerActivity.kt +67 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWConfigUtil.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWGlobalDataUtil.kt +0 -2
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWStoryBlockUtil.kt +30 -0
- package/android/src/main/res/layout/fw_bridge_fragment_container.xml +8 -0
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +12 -0
- package/ios/Models/RNToNative/RCTConvert+FWNavigatorModule.swift +21 -0
- package/ios/Models/RNToNative/RCTConvert+FireworkSDKModule.swift +3 -30
- package/ios/Models/RNToNative/RCTConvert+StoryBlock.swift +2 -2
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +5 -5
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.m +2 -2
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +59 -4
- package/ios/Modules/FWNavigatorModule/FWRNContainerViewController.swift +33 -0
- package/ios/Modules/FWNavigatorModule/PushRNContainerParams.swift +14 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +36 -17
- package/lib/commonjs/FWNavigator.js +21 -0
- package/lib/commonjs/FWNavigator.js.map +1 -1
- package/lib/commonjs/FireworkSDK.js +10 -4
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/PushRNContainerParams.js +2 -0
- package/lib/commonjs/models/PushRNContainerParams.js.map +1 -0
- package/lib/commonjs/modules/FWNavigatorModule.js.map +1 -1
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/FWNavigator.js +21 -0
- package/lib/module/FWNavigator.js.map +1 -1
- package/lib/module/FireworkSDK.js +10 -4
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/PushRNContainerParams.js +2 -0
- package/lib/module/models/PushRNContainerParams.js.map +1 -0
- package/lib/module/modules/FWNavigatorModule.js +1 -2
- package/lib/module/modules/FWNavigatorModule.js.map +1 -1
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/typescript/FWNavigator.d.ts +14 -0
- package/lib/typescript/FireworkSDK.d.ts +3 -3
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/models/PushRNContainerParams.d.ts +8 -0
- package/lib/typescript/modules/FWNavigatorModule.d.ts +3 -0
- package/lib/typescript/modules/FireworkSDKModule.d.ts +1 -1
- package/package.json +1 -1
- package/src/FWNavigator.ts +20 -0
- package/src/FireworkSDK.ts +15 -4
- package/src/index.ts +4 -0
- package/src/models/PushRNContainerParams.ts +9 -0
- package/src/modules/FWNavigatorModule.ts +5 -2
- package/src/modules/FireworkSDKModule.ts +4 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Info.plist
CHANGED
|
Binary file
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWStoryBlockManager.kt
CHANGED
|
@@ -20,6 +20,7 @@ import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
|
20
20
|
import com.fireworksdk.bridge.utils.FWFragmentUtil
|
|
21
21
|
import com.fireworksdk.bridge.utils.FWGlobalDataUtil
|
|
22
22
|
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
23
|
+
import com.fireworksdk.bridge.utils.FWStoryBlockUtil
|
|
23
24
|
import org.json.JSONObject
|
|
24
25
|
|
|
25
26
|
|
|
@@ -189,7 +190,9 @@ class FWStoryBlockManager : ViewGroupManager<StoryBlockFrameLayout>() {
|
|
|
189
190
|
|
|
190
191
|
fragment.setOnFullScreenStateChangedListener { isFullScreen ->
|
|
191
192
|
if (isFullScreen) {
|
|
192
|
-
|
|
193
|
+
FWStoryBlockUtil.addFullScreenStoryBlockFragment(fragment)
|
|
194
|
+
} else {
|
|
195
|
+
FWStoryBlockUtil.removeFullScreenStoryBlockFragment(fragment)
|
|
193
196
|
}
|
|
194
197
|
FWEventUtils.receiveStoryBlockFullScreenStateChangedEvent(
|
|
195
198
|
reactContext,
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWNavigatorInterface.kt
CHANGED
|
@@ -5,6 +5,8 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
5
5
|
|
|
6
6
|
interface FWNavigatorInterface {
|
|
7
7
|
|
|
8
|
+
fun pushRNContainer(props: ReadableMap?, promise: Promise)
|
|
9
|
+
fun popRNContainer(promise: Promise)
|
|
8
10
|
fun popNativeContainer(promise: Promise)
|
|
9
11
|
fun canPopNativeContainer(promise: Promise)
|
|
10
12
|
fun startFloatingPlayer(promise: Promise)
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt
CHANGED
|
@@ -5,14 +5,40 @@ import com.facebook.react.bridge.*
|
|
|
5
5
|
import com.firework.sdk.FireworkSdk
|
|
6
6
|
import com.fireworksdk.bridge.FWInitializationProvider
|
|
7
7
|
import com.fireworksdk.bridge.reactnative.models.FWNavigatorInterface
|
|
8
|
-
import com.fireworksdk.bridge.
|
|
8
|
+
import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
|
|
9
9
|
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
10
|
+
import com.fireworksdk.bridge.utils.FWStoryBlockUtil
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class FWNavigatorModule(
|
|
13
14
|
reactContext: ReactApplicationContext
|
|
14
15
|
) : ReactContextBaseJavaModule(reactContext), FWNavigatorInterface {
|
|
15
16
|
|
|
17
|
+
@ReactMethod
|
|
18
|
+
override fun pushRNContainer(props: ReadableMap?, promise: Promise) {
|
|
19
|
+
val activity = FWInitializationProvider.INSTANCE.resumedActivity
|
|
20
|
+
if (activity == null) {
|
|
21
|
+
promise.resolve(false)
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
UiThreadUtil.runOnUiThread {
|
|
26
|
+
activity.startActivity(FWContainerActivity.createIntent(activity, props?.toHashMap()))
|
|
27
|
+
}
|
|
28
|
+
promise.resolve(true)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ReactMethod
|
|
32
|
+
override fun popRNContainer(promise: Promise) {
|
|
33
|
+
val activity = FWInitializationProvider.INSTANCE.resumedActivity
|
|
34
|
+
if (activity is FWContainerActivity) {
|
|
35
|
+
activity.finish()
|
|
36
|
+
promise.resolve(true)
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
promise.resolve(false)
|
|
40
|
+
}
|
|
41
|
+
|
|
16
42
|
@ReactMethod
|
|
17
43
|
override fun popNativeContainer(promise: Promise) {
|
|
18
44
|
FWLogUtils.d { "FWNavigatorModule popNativeContainer" }
|
|
@@ -23,23 +49,25 @@ class FWNavigatorModule(
|
|
|
23
49
|
return
|
|
24
50
|
}
|
|
25
51
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
promise.resolve(true)
|
|
32
|
-
return
|
|
52
|
+
val currentStoryBlockFragment = FWStoryBlockUtil.getCurrentFullScreenStoryBlockFragment()
|
|
53
|
+
if (currentStoryBlockFragment?.activity == activity) {
|
|
54
|
+
UiThreadUtil.runOnUiThread {
|
|
55
|
+
currentStoryBlockFragment.toggleFullScreen()
|
|
33
56
|
}
|
|
34
|
-
|
|
35
|
-
promise.resolve(false)
|
|
57
|
+
promise.resolve(true)
|
|
36
58
|
return
|
|
37
59
|
}
|
|
38
60
|
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
if (activity.javaClass.name.equals("com.firework.player.pager.PlayerActivity")) {
|
|
62
|
+
UiThreadUtil.runOnUiThread {
|
|
63
|
+
activity.finish()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
promise.resolve(true)
|
|
67
|
+
return
|
|
41
68
|
}
|
|
42
|
-
|
|
69
|
+
|
|
70
|
+
promise.resolve(false)
|
|
43
71
|
}
|
|
44
72
|
|
|
45
73
|
@ReactMethod
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt
CHANGED
|
@@ -201,7 +201,7 @@ class FWVideoShoppingModule(
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
if (!resultModel.tips.isNullOrBlank()) {
|
|
204
|
-
Toast.makeText(
|
|
204
|
+
Toast.makeText(reactApplicationContext, resultModel.tips, Toast.LENGTH_LONG).show()
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
package com.fireworksdk.bridge.reactnative.pages
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.content.Intent
|
|
6
|
+
import android.os.Bundle
|
|
7
|
+
import com.facebook.react.ReactActivity
|
|
8
|
+
import com.facebook.react.ReactActivityDelegate
|
|
9
|
+
import com.fireworksdk.bridge.reactnative.FWReactNativeSDK.updateBaseContextLocale
|
|
10
|
+
import com.fireworksdk.bridge.utils.FWBundleUtils
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class FWContainerActivity : ReactActivity() {
|
|
14
|
+
|
|
15
|
+
override fun attachBaseContext(newBase: Context) {
|
|
16
|
+
super.attachBaseContext(updateBaseContextLocale(newBase))
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getMainComponentName(): String {
|
|
20
|
+
return ""
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun createReactActivityDelegate(): ReactActivityDelegate {
|
|
24
|
+
return FWContainerActivityDelegate(this, mainComponentName)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// https://cmichel.io/how-to-set-initial-props-in-react-native
|
|
28
|
+
class FWContainerActivityDelegate(
|
|
29
|
+
private val mActivity: ReactActivity,
|
|
30
|
+
mainComponentName: String?
|
|
31
|
+
) :
|
|
32
|
+
ReactActivityDelegate(mActivity, mainComponentName) {
|
|
33
|
+
private var mInitialProps: Bundle? = null
|
|
34
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
35
|
+
|
|
36
|
+
val params = mActivity.intent.getSerializableExtra(KEY_PARAMS) as HashMap<String, Any?>?
|
|
37
|
+
mInitialProps = FWBundleUtils.mapToBundle(params)
|
|
38
|
+
|
|
39
|
+
super.onCreate(savedInstanceState)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override fun getMainComponentName(): String? {
|
|
43
|
+
val bundle = mActivity.intent.extras
|
|
44
|
+
return bundle?.getString(KEY_COMPONENT_NAME)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override fun getLaunchOptions(): Bundle? {
|
|
48
|
+
return mInitialProps
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
companion object {
|
|
53
|
+
|
|
54
|
+
private const val KEY_PARAMS = "params"
|
|
55
|
+
private const val KEY_COMPONENT_NAME = "componentName"
|
|
56
|
+
|
|
57
|
+
@Suppress("UNCHECKED_CAST")
|
|
58
|
+
fun createIntent(activity: Activity, params: HashMap<String, Any?>?): Intent {
|
|
59
|
+
val intent = Intent(activity, FWContainerActivity::class.java)
|
|
60
|
+
intent.putExtra(KEY_COMPONENT_NAME, params?.get("appKey") as String?)
|
|
61
|
+
intent.putExtra(KEY_PARAMS, params?.get("appProps") as HashMap<String, Any?>)
|
|
62
|
+
intent.flags = Intent.FLAG_ACTIVITY_NO_ANIMATION
|
|
63
|
+
activity.overridePendingTransition(0, 0)
|
|
64
|
+
return intent
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package com.fireworksdk.bridge.utils
|
|
2
|
+
|
|
3
|
+
import com.fireworksdk.bridge.components.storyblock.StoryBlockFragment
|
|
4
|
+
|
|
5
|
+
object FWStoryBlockUtil {
|
|
6
|
+
|
|
7
|
+
private val list = ArrayList<StoryBlockFragment>()
|
|
8
|
+
|
|
9
|
+
fun getCurrentFullScreenStoryBlockFragment(): StoryBlockFragment? {
|
|
10
|
+
while (list.size > 0) {
|
|
11
|
+
val fragment = list.last()
|
|
12
|
+
if (!fragment.isFullScreen()) {
|
|
13
|
+
list.removeLast()
|
|
14
|
+
} else {
|
|
15
|
+
return fragment
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fun addFullScreenStoryBlockFragment(fragment: StoryBlockFragment?) {
|
|
22
|
+
fragment ?: return
|
|
23
|
+
list.add(fragment)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fun removeFullScreenStoryBlockFragment(fragment: StoryBlockFragment?) {
|
|
27
|
+
fragment ?: return
|
|
28
|
+
list.remove(fragment)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
+
891F4AF62A67E12800A9E8DA /* FWRNContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891F4AF52A67E12800A9E8DA /* FWRNContainerViewController.swift */; };
|
|
11
|
+
891F4AF82A68DEDF00A9E8DA /* PushRNContainerParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891F4AF72A68DEDF00A9E8DA /* PushRNContainerParams.swift */; };
|
|
12
|
+
891F4AFA2A68DF2B00A9E8DA /* RCTConvert+FWNavigatorModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891F4AF92A68DF2B00A9E8DA /* RCTConvert+FWNavigatorModule.swift */; };
|
|
10
13
|
897523872817DEF80070EBB6 /* (null) in Sources */ = {isa = PBXBuildFile; };
|
|
11
14
|
897523882817DEF80070EBB6 /* (null) in Sources */ = {isa = PBXBuildFile; };
|
|
12
15
|
897523892817DEF80070EBB6 /* (null) in Sources */ = {isa = PBXBuildFile; };
|
|
@@ -89,6 +92,9 @@
|
|
|
89
92
|
|
|
90
93
|
/* Begin PBXFileReference section */
|
|
91
94
|
1F6F718A2771B48100224AF3 /* FireworkSdk-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FireworkSdk-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
95
|
+
891F4AF52A67E12800A9E8DA /* FWRNContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FWRNContainerViewController.swift; sourceTree = "<group>"; };
|
|
96
|
+
891F4AF72A68DEDF00A9E8DA /* PushRNContainerParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PushRNContainerParams.swift; sourceTree = "<group>"; };
|
|
97
|
+
891F4AF92A68DF2B00A9E8DA /* RCTConvert+FWNavigatorModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RCTConvert+FWNavigatorModule.swift"; sourceTree = "<group>"; };
|
|
92
98
|
894FADB229BAD571000FB51A /* libFireworkSdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libFireworkSdk.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
93
99
|
897523632817DEF80070EBB6 /* react_native_firework_sdk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = react_native_firework_sdk.h; sourceTree = "<group>"; };
|
|
94
100
|
898873132A0A8E7E0089CD1C /* UIViewController+AttachChild.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewController+AttachChild.swift"; sourceTree = "<group>"; };
|
|
@@ -187,6 +193,8 @@
|
|
|
187
193
|
children = (
|
|
188
194
|
8988731D2A0A8E7E0089CD1C /* FWNavigatorModule.swift */,
|
|
189
195
|
8988731E2A0A8E7E0089CD1C /* FWNavigatorModule.m */,
|
|
196
|
+
891F4AF52A67E12800A9E8DA /* FWRNContainerViewController.swift */,
|
|
197
|
+
891F4AF72A68DEDF00A9E8DA /* PushRNContainerParams.swift */,
|
|
190
198
|
);
|
|
191
199
|
path = FWNavigatorModule;
|
|
192
200
|
sourceTree = "<group>";
|
|
@@ -251,6 +259,7 @@
|
|
|
251
259
|
898873362A0A8E7E0089CD1C /* RCTConvert+FireworkSDKModule.swift */,
|
|
252
260
|
898873372A0A8E7E0089CD1C /* RCTConvert+Shopping.swift */,
|
|
253
261
|
898873382A0A8E7E0089CD1C /* RCTConvert+VideoFeed.swift */,
|
|
262
|
+
891F4AF92A68DF2B00A9E8DA /* RCTConvert+FWNavigatorModule.swift */,
|
|
254
263
|
);
|
|
255
264
|
path = RNToNative;
|
|
256
265
|
sourceTree = "<group>";
|
|
@@ -377,6 +386,7 @@
|
|
|
377
386
|
897523902817DEF80070EBB6 /* (null) in Sources */,
|
|
378
387
|
8988736D2A0A8E7E0089CD1C /* VideoFeedManager.m in Sources */,
|
|
379
388
|
8988735A2A0A8E7E0089CD1C /* FireworkSDKModule+CTA.swift in Sources */,
|
|
389
|
+
891F4AFA2A68DF2B00A9E8DA /* RCTConvert+FWNavigatorModule.swift in Sources */,
|
|
380
390
|
898873472A0A8E7E0089CD1C /* UIView+Constraints.swift in Sources */,
|
|
381
391
|
897523882817DEF80070EBB6 /* (null) in Sources */,
|
|
382
392
|
897523982817DEF80070EBB6 /* (null) in Sources */,
|
|
@@ -394,10 +404,12 @@
|
|
|
394
404
|
8975238D2817DEF80070EBB6 /* (null) in Sources */,
|
|
395
405
|
8975238C2817DEF80070EBB6 /* (null) in Sources */,
|
|
396
406
|
8988736B2A0A8E7E0089CD1C /* VideoFeed.swift in Sources */,
|
|
407
|
+
891F4AF62A67E12800A9E8DA /* FWRNContainerViewController.swift in Sources */,
|
|
397
408
|
898873522A0A8E7E0089CD1C /* ShoppingCTAResult.swift in Sources */,
|
|
398
409
|
8975239D2817DEF80070EBB6 /* (null) in Sources */,
|
|
399
410
|
898873562A0A8E7E0089CD1C /* SDKInitOptions.swift in Sources */,
|
|
400
411
|
89DF27DE28A53A77003F3CCB /* (null) in Sources */,
|
|
412
|
+
891F4AF82A68DEDF00A9E8DA /* PushRNContainerParams.swift in Sources */,
|
|
401
413
|
897523892817DEF80070EBB6 /* (null) in Sources */,
|
|
402
414
|
897523912817DEF80070EBB6 /* (null) in Sources */,
|
|
403
415
|
8975238F2817DEF80070EBB6 /* (null) in Sources */,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RCTConvert+FWNavigatorModule.swift
|
|
3
|
+
// FireworkSdk
|
|
4
|
+
//
|
|
5
|
+
// Created by linjie jiang on 7/20/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
extension RCTConvert {
|
|
11
|
+
static func pushRNContainerParams(_ json: [String: Any]) -> PushRNContainerParams? {
|
|
12
|
+
if let appKey = json["appKey"] as? String {
|
|
13
|
+
let params = PushRNContainerParams()
|
|
14
|
+
params.appKey = appKey
|
|
15
|
+
params.appProps = json["appProps"] as? [String: Any]
|
|
16
|
+
|
|
17
|
+
return params
|
|
18
|
+
}
|
|
19
|
+
return nil
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -10,15 +10,6 @@ import Foundation
|
|
|
10
10
|
import UIKit
|
|
11
11
|
|
|
12
12
|
extension RCTConvert {
|
|
13
|
-
static func videoPlayerContentConfiguration(_ config: [String: AnyObject])
|
|
14
|
-
-> VideoPlayerContentConfiguration? {
|
|
15
|
-
let videoPlayerConfig = RCTConvert.videoPlayerConfiguration(config)
|
|
16
|
-
|
|
17
|
-
let finalConfig = VideoFeed.convertToVideoPlayerContentConfiguration(videoPlayerConfig)
|
|
18
|
-
|
|
19
|
-
return finalConfig
|
|
20
|
-
}
|
|
21
|
-
|
|
22
13
|
static func videoPlayerStyle(_ style: String?) -> VideoPlayerContentConfiguration
|
|
23
14
|
.VideoPlayerStyle? {
|
|
24
15
|
guard let rStyle = style else {
|
|
@@ -43,25 +34,7 @@ extension RCTConvert {
|
|
|
43
34
|
}
|
|
44
35
|
}
|
|
45
36
|
|
|
46
|
-
static func
|
|
47
|
-
guard let rStyle = style else {
|
|
48
|
-
return nil
|
|
49
|
-
}
|
|
50
|
-
var btnContentConfig = ButtonContentConfiguration()
|
|
51
|
-
if let backgroundColor = rStyle["backgroundColor"] as? String {
|
|
52
|
-
btnContentConfig.backgroundColor = backgroundColor.uicolor()
|
|
53
|
-
}
|
|
54
|
-
if let textColor = rStyle["textColor"] as? String {
|
|
55
|
-
btnContentConfig.textColor = textColor.uicolor()
|
|
56
|
-
}
|
|
57
|
-
if let fontSize = rStyle["fontSize"] as? Double {
|
|
58
|
-
btnContentConfig.font = UIFont.systemFont(ofSize: fontSize)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return btnContentConfig
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
static func adBadgeConfiguration(_ config: [String: AnyObject]?) -> AdBadgeConfiguration? {
|
|
37
|
+
static func adBadgeConfiguration(_ config: [String: Any]?) -> AdBadgeConfiguration? {
|
|
65
38
|
guard let rConfig = config else {
|
|
66
39
|
return nil
|
|
67
40
|
}
|
|
@@ -81,7 +54,7 @@ extension RCTConvert {
|
|
|
81
54
|
return result
|
|
82
55
|
}
|
|
83
56
|
|
|
84
|
-
static func trackPurchaseParameters(_ parameters: [String:
|
|
57
|
+
static func trackPurchaseParameters(_ parameters: [String: Any]?)
|
|
85
58
|
-> TrackPurchaseParameters? {
|
|
86
59
|
guard let rParameters = parameters else {
|
|
87
60
|
return nil
|
|
@@ -103,7 +76,7 @@ extension RCTConvert {
|
|
|
103
76
|
return result
|
|
104
77
|
}
|
|
105
78
|
|
|
106
|
-
static func sdkInitOptions(_ options: [String:
|
|
79
|
+
static func sdkInitOptions(_ options: [String: Any]?) -> SDKInitOptions? {
|
|
107
80
|
guard let rOptions = options else {
|
|
108
81
|
return nil
|
|
109
82
|
}
|
|
@@ -30,9 +30,9 @@ extension RCTConvert {
|
|
|
30
30
|
return StoryBlockSourceType.sourceTypeMapper[rType] ?? .discover
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
public static func storyBlockConfiguration(_ config:
|
|
33
|
+
public static func storyBlockConfiguration(_ config: NSDictionary?)
|
|
34
34
|
-> StoryBlockConfiguration? {
|
|
35
|
-
|
|
35
|
+
guard let rConfig = config as? [String: Any] else {
|
|
36
36
|
return nil
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -50,9 +50,9 @@ extension RCTConvert {
|
|
|
50
50
|
return VideoFeedMode.feedModeMapper[rType] ?? .row
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
public static func videoFeedConfiguration(_ config:
|
|
53
|
+
public static func videoFeedConfiguration(_ config: NSDictionary?)
|
|
54
54
|
-> VideoFeedConfiguration? {
|
|
55
|
-
|
|
55
|
+
guard let rConfig = config as? [String: Any] else {
|
|
56
56
|
return nil
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -64,7 +64,7 @@ extension RCTConvert {
|
|
|
64
64
|
return try? JSONDecoder().decode(VideoFeedConfiguration.self, from: rJsonData)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
public static func videoPlayerConfiguration(_ config: [String:
|
|
67
|
+
public static func videoPlayerConfiguration(_ config: [String: Any]?)
|
|
68
68
|
-> VideoPlayerConfiguration? {
|
|
69
69
|
guard let rConfig = config else {
|
|
70
70
|
return nil
|
|
@@ -78,8 +78,8 @@ extension RCTConvert {
|
|
|
78
78
|
return try? JSONDecoder().decode(VideoPlayerConfiguration.self, from: rJsonData)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
public static func adConfiguration(_ config:
|
|
82
|
-
guard let rConfig = config else {
|
|
81
|
+
public static func adConfiguration(_ config: NSDictionary?) -> AdConfiguration? {
|
|
82
|
+
guard let rConfig = config as? [String: Any] else {
|
|
83
83
|
return nil
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
@interface RCT_EXTERN_REMAP_MODULE(FWNavigatorModule, FWNavigatorModule, NSObject)
|
|
13
13
|
|
|
14
|
-
RCT_EXTERN_METHOD(
|
|
14
|
+
RCT_EXTERN_METHOD(pushRNContainer:(NSDictionary *)params resolver:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
15
|
+
RCT_EXTERN_METHOD(popRNContainer:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
15
16
|
RCT_EXTERN_METHOD(popNativeContainer:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
16
|
-
RCT_EXTERN_METHOD(canPopNativeContainer:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
17
17
|
RCT_EXTERN_METHOD(startFloatingPlayer:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
18
18
|
RCT_EXTERN_METHOD(stopFloatingPlayer:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
19
19
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// Created by Big Bear Xiong on 2022/4/21.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
+
import UIKit
|
|
8
9
|
import FireworkVideo
|
|
9
10
|
|
|
10
11
|
private struct PlayerExitButtonInfo {
|
|
@@ -29,6 +30,61 @@ class FWNavigatorModule: RCTEventEmitter {
|
|
|
29
30
|
return DispatchQueue.main
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
@objc(pushRNContainer:resolver:rejecter:)
|
|
34
|
+
func pushRNContainer(
|
|
35
|
+
_ params: NSDictionary?,
|
|
36
|
+
resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock
|
|
37
|
+
) {
|
|
38
|
+
guard let presentedVC = RCTPresentedViewController() else {
|
|
39
|
+
resolver(false)
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
guard let params = params as? [String: Any] else {
|
|
44
|
+
resolver(false)
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
guard let pushRNContainerParams = RCTConvert.pushRNContainerParams(params) else {
|
|
49
|
+
resolver(false)
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
guard let appKey = pushRNContainerParams.appKey, appKey.count > 0 else {
|
|
54
|
+
resolver(false)
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let containerViewController = FWRNContainerViewController()
|
|
59
|
+
containerViewController.appKey = appKey
|
|
60
|
+
containerViewController.appProps = pushRNContainerParams.appProps ?? [:]
|
|
61
|
+
containerViewController.modalPresentationStyle = .fullScreen
|
|
62
|
+
|
|
63
|
+
// if presentedVC.modalPresentationStyle == .custom,
|
|
64
|
+
// let presentingVC = presentedVC.presentingViewController,
|
|
65
|
+
// presentingVC is FireworkVideo.PlayerViewController {
|
|
66
|
+
// containerViewController.modalPresentationStyle = .overFullScreen
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
presentedVC.present(containerViewController, animated: true) {
|
|
70
|
+
resolver(true)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@objc(popRNContainer:rejecter:)
|
|
75
|
+
func popRNContainer(
|
|
76
|
+
_ resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock
|
|
77
|
+
) {
|
|
78
|
+
if let containerVC = RCTPresentedViewController() as? FWRNContainerViewController,
|
|
79
|
+
containerVC.presentingViewController != nil {
|
|
80
|
+
containerVC.dismiss(animated: true) {
|
|
81
|
+
resolver(true)
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
resolver(false)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
32
88
|
@objc(popNativeContainer:rejecter:)
|
|
33
89
|
func popNativeContainer(
|
|
34
90
|
_ resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock
|
|
@@ -54,9 +110,9 @@ class FWNavigatorModule: RCTEventEmitter {
|
|
|
54
110
|
}
|
|
55
111
|
}
|
|
56
112
|
}
|
|
57
|
-
} else if let
|
|
58
|
-
|
|
59
|
-
|
|
113
|
+
} else if let presentedVC = RCTPresentedViewController(),
|
|
114
|
+
FWNavigatorModule.isIOSSDKViewController(presentedVC),
|
|
115
|
+
presentedVC.presentingViewController == RCTKeyWindow()?.rootViewController {
|
|
60
116
|
if let buttonInfo = FWNavigatorModule.getPlayerExitButtonInfo(view: presentedVC.view) {
|
|
61
117
|
if buttonInfo.type == .close {
|
|
62
118
|
buttonInfo.button.sendActions(for: .touchUpInside)
|
|
@@ -121,7 +177,6 @@ extension FWNavigatorModule {
|
|
|
121
177
|
|
|
122
178
|
private static func getPlayerExitButtonInfo(view: UIView) -> PlayerExitButtonInfo? {
|
|
123
179
|
if let button = view as? UIButton, let image = button.image(for: .normal) {
|
|
124
|
-
let iOSSDKBundle = Bundle(for: FireworkVideoSDK.self)
|
|
125
180
|
if isTargetIOSSDKImage(image, targetImageName: "closeX") {
|
|
126
181
|
return PlayerExitButtonInfo(button: button, type: .close)
|
|
127
182
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FWRNContainerViewController.swift
|
|
3
|
+
// FireworkSdk
|
|
4
|
+
//
|
|
5
|
+
// Created by linjie jiang on 7/19/23.
|
|
6
|
+
// Copyright © 2023 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import UIKit
|
|
10
|
+
|
|
11
|
+
class FWRNContainerViewController: UIViewController {
|
|
12
|
+
var appKey: String = ""
|
|
13
|
+
var appProps: [String: Any] = [:]
|
|
14
|
+
|
|
15
|
+
override func viewDidLoad() {
|
|
16
|
+
super.viewDidLoad()
|
|
17
|
+
loadContent()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private func loadContent() {
|
|
21
|
+
let rctRootView = RCTRootView.init(
|
|
22
|
+
bridge: RCTBridge.current(), moduleName: appKey, initialProperties: appProps)
|
|
23
|
+
view.addSubview(rctRootView)
|
|
24
|
+
rctRootView.translatesAutoresizingMaskIntoConstraints = false
|
|
25
|
+
|
|
26
|
+
NSLayoutConstraint.activate([
|
|
27
|
+
rctRootView.leftAnchor.constraint(equalTo: view.leftAnchor),
|
|
28
|
+
rctRootView.topAnchor.constraint(equalTo: view.topAnchor),
|
|
29
|
+
rctRootView.rightAnchor.constraint(equalTo: view.rightAnchor),
|
|
30
|
+
rctRootView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
|
31
|
+
])
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PushRNContainerParams.swift
|
|
3
|
+
// FireworkSdk
|
|
4
|
+
//
|
|
5
|
+
// Created by linjie jiang on 7/20/23.
|
|
6
|
+
// Copyright © 2023 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
|
|
11
|
+
class PushRNContainerParams {
|
|
12
|
+
var appKey: String?
|
|
13
|
+
var appProps: [String: Any]?
|
|
14
|
+
}
|
|
@@ -18,6 +18,6 @@ RCT_EXTERN_METHOD(setShareBaseURL:(NSString *)url resolver: (RCTPromiseResolveBl
|
|
|
18
18
|
RCT_EXTERN_METHOD(setVideoPlaybackEventEnabled:(BOOL)enabled)
|
|
19
19
|
RCT_EXTERN_METHOD(setAdBadgeConfiguration:(NSDictionary *)config resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
20
20
|
RCT_EXTERN_METHOD(trackPurchase:(NSDictionary *)parameters)
|
|
21
|
-
RCT_EXTERN_METHOD(changeAppLanguage:(NSString * __nullable)language resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
21
|
+
RCT_EXTERN_METHOD(changeAppLanguage:(NSString * __nullable)language enableAutoHorizontalFlip:(BOOL)enableAutoHorizontalFlip resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
22
22
|
|
|
23
23
|
@end
|