react-native-firework-sdk 1.0.4 → 1.1.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.
Files changed (186) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +2 -40
  3. package/android/build.gradle +6 -3
  4. package/android/gradle.properties +2 -1
  5. package/android/proguard-rules.pro +22 -0
  6. package/android/publish.gradle +4 -3
  7. package/android/settings.gradle +1 -0
  8. package/android/src/main/AndroidManifest.xml +5 -2
  9. package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +226 -0
  10. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/constants/FWCommandConstant.kt +1 -1
  11. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/constants/FWVideoPlayerConstant.kt +13 -1
  12. package/android/src/main/java/com/fireworksdk/bridge/models/FWAdBadgeConfigModel.kt +9 -0
  13. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/models/FWEventName.kt +10 -1
  14. package/android/src/main/java/com/fireworksdk/bridge/models/FWLiveStreamEventDetailsModel.kt +9 -0
  15. package/android/src/main/java/com/fireworksdk/bridge/models/FWLiveStreamMessageDetailsModel.kt +11 -0
  16. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModel.kt +28 -0
  17. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/models/FWVideoFeedItemDetailsModel.kt +2 -1
  18. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedModel.kt +7 -0
  19. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModel.kt +18 -0
  20. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/models/FWVideoFeedSource.kt +2 -1
  21. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/models/FWVideoFeedTitlePosition.kt +1 -1
  22. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/models/FWVideoPlaybackDetails.kt +1 -1
  23. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModel.kt +23 -0
  24. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/models/FWVideoShoppingProduct.kt +1 -1
  25. package/android/src/main/java/com/fireworksdk/bridge/models/WeakProperty.kt +19 -0
  26. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge/reactnative}/FireworkSDKPackage.kt +10 -5
  27. package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +175 -0
  28. package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWLiveStreamInterface.kt +5 -0
  29. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge/reactnative}/models/FWVideoShoppingInterface.kt +3 -2
  30. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge/reactnative}/models/FireworkSDKInterface.kt +4 -2
  31. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWLiveStreamModule.kt +88 -0
  32. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge/reactnative}/module/FWVideoShoppingModule.kt +53 -39
  33. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge/reactnative}/module/FireworkSDKModule.kt +23 -22
  34. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge/reactnative}/pages/FWVideoShoppingCartActivity.kt +4 -4
  35. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge/reactnative}/utils/FWEventUtils.kt +61 -7
  36. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/utils/FWJsonUtils.kt +29 -1
  37. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/utils/FWLogUtils.kt +2 -2
  38. package/android/src/main/java/com/{reactnativefireworksdk → fireworksdk/bridge}/utils/FWUrlUtils.kt +1 -1
  39. package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +94 -0
  40. package/android/src/main/res/layout/fw_bridge_fragment_playlistfeed.xml +18 -0
  41. package/android/src/main/res/layout/{fwrn_fragment_shoppingcart.xml → fw_bridge_fragment_shoppingcart.xml} +1 -1
  42. package/android/src/main/res/layout/{fwrn_fragment_videofeed.xml → fw_bridge_fragment_videofeed.xml} +2 -1
  43. package/android/src/main/res/values/colors.xml +4 -0
  44. package/ios/{Component → Components}/VideoFeed.swift +60 -3
  45. package/ios/{Component → Components}/VideoFeedConfiguration.swift +2 -0
  46. package/ios/{Component → Components}/VideoFeedManager.m +2 -0
  47. package/ios/{Component → Components}/VideoFeedManager.swift +0 -0
  48. package/ios/{Component → Components}/VideoPlayerConfiguration.swift +7 -0
  49. package/ios/Models/{FireworkJsEvent.swift → NativeToRN/FireworkEventName.swift} +20 -0
  50. package/ios/Models/{FireworkSDK+JsModel.swift → NativeToRN/FireworkSDK+Json.swift} +33 -3
  51. package/ios/Models/{RCTConvert+FireworkSDKModule.swift → RNToNative/RCTConvert+FireworkSDKModule.swift} +20 -0
  52. package/ios/Models/{RCTConvert+Shopping.swift → RNToNative/RCTConvert+Shopping.swift} +15 -0
  53. package/ios/Models/{RCTConvert+VideoFeed.swift → RNToNative/RCTConvert+VideoFeed.swift} +2 -1
  54. package/ios/Modules/FireworkSDKModule/AdBadgeConfiguration.swift +18 -0
  55. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +1 -1
  56. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +10 -14
  57. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +2 -1
  58. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +16 -4
  59. package/ios/Modules/LiveStream/LiveStreamModule.m +14 -0
  60. package/ios/Modules/LiveStream/LiveStreamModule.swift +43 -0
  61. package/ios/Modules/Shopping/ShoppingModule.m +1 -1
  62. package/ios/Modules/Shopping/ShoppingModule.swift +10 -9
  63. package/lib/commonjs/FireworkSDK.js +61 -38
  64. package/lib/commonjs/FireworkSDK.js.map +1 -1
  65. package/lib/commonjs/LiveStream.js +60 -0
  66. package/lib/commonjs/LiveStream.js.map +1 -0
  67. package/lib/commonjs/VideoShopping.js +20 -18
  68. package/lib/commonjs/VideoShopping.js.map +1 -1
  69. package/lib/commonjs/components/VideoFeed.js +47 -2
  70. package/lib/commonjs/components/VideoFeed.js.map +1 -1
  71. package/lib/commonjs/index.js +24 -0
  72. package/lib/commonjs/index.js.map +1 -1
  73. package/lib/commonjs/models/AdBadgeConfiguration.js +2 -0
  74. package/lib/commonjs/models/{ADConfig.js.map → AdBadgeConfiguration.js.map} +0 -0
  75. package/lib/commonjs/models/AdConfig.js +2 -0
  76. package/lib/{module/models/ADConfig.js.map → commonjs/models/AdConfig.js.map} +0 -0
  77. package/lib/commonjs/models/FWEventName.js +24 -0
  78. package/lib/commonjs/models/FWEventName.js.map +1 -0
  79. package/lib/commonjs/models/FWEvents.js +0 -14
  80. package/lib/commonjs/models/FWEvents.js.map +1 -1
  81. package/lib/commonjs/models/LiveStreamChatEventName.js +15 -0
  82. package/lib/commonjs/models/LiveStreamChatEventName.js.map +1 -0
  83. package/lib/commonjs/models/LiveStreamEventDetails.js +2 -0
  84. package/lib/commonjs/models/LiveStreamEventDetails.js.map +1 -0
  85. package/lib/commonjs/models/LiveStreamEventName.js +17 -0
  86. package/lib/commonjs/models/LiveStreamEventName.js.map +1 -0
  87. package/lib/commonjs/models/LiveStreamMessageDetails.js +2 -0
  88. package/lib/commonjs/models/LiveStreamMessageDetails.js.map +1 -0
  89. package/lib/commonjs/models/VideoFeedSource.js +6 -0
  90. package/lib/commonjs/models/VideoFeedSource.js.map +1 -0
  91. package/lib/commonjs/models/VideoPlaybackEventName.js.map +1 -1
  92. package/lib/commonjs/modules/FireworkSDKModule.js +3 -1
  93. package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
  94. package/lib/commonjs/modules/LiveStreamModule.js +22 -0
  95. package/lib/commonjs/modules/LiveStreamModule.js.map +1 -0
  96. package/lib/commonjs/modules/ShoppingModule.js +3 -1
  97. package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
  98. package/lib/module/FireworkSDK.js +50 -34
  99. package/lib/module/FireworkSDK.js.map +1 -1
  100. package/lib/module/LiveStream.js +51 -0
  101. package/lib/module/LiveStream.js.map +1 -0
  102. package/lib/module/VideoShopping.js +14 -13
  103. package/lib/module/VideoShopping.js.map +1 -1
  104. package/lib/module/components/VideoFeed.js +42 -3
  105. package/lib/module/components/VideoFeed.js.map +1 -1
  106. package/lib/module/index.js +4 -1
  107. package/lib/module/index.js.map +1 -1
  108. package/lib/module/models/AdBadgeConfiguration.js +2 -0
  109. package/lib/module/models/AdBadgeConfiguration.js.map +1 -0
  110. package/lib/module/models/AdConfig.js +2 -0
  111. package/lib/module/models/AdConfig.js.map +1 -0
  112. package/lib/module/models/FWEventName.js +17 -0
  113. package/lib/module/models/FWEventName.js.map +1 -0
  114. package/lib/module/models/FWEvents.js +1 -12
  115. package/lib/module/models/FWEvents.js.map +1 -1
  116. package/lib/module/models/LiveStreamChatEventName.js +8 -0
  117. package/lib/module/models/LiveStreamChatEventName.js.map +1 -0
  118. package/lib/module/models/LiveStreamEventDetails.js +2 -0
  119. package/lib/module/models/LiveStreamEventDetails.js.map +1 -0
  120. package/lib/module/models/LiveStreamEventName.js +10 -0
  121. package/lib/module/models/LiveStreamEventName.js.map +1 -0
  122. package/lib/module/models/LiveStreamMessageDetails.js +2 -0
  123. package/lib/module/models/LiveStreamMessageDetails.js.map +1 -0
  124. package/lib/module/models/VideoFeedSource.js +2 -0
  125. package/lib/module/models/VideoFeedSource.js.map +1 -0
  126. package/lib/module/models/VideoPlaybackEventName.js.map +1 -1
  127. package/lib/module/modules/FireworkSDKModule.js +3 -0
  128. package/lib/module/modules/FireworkSDKModule.js.map +1 -1
  129. package/lib/module/modules/LiveStreamModule.js +12 -0
  130. package/lib/module/modules/LiveStreamModule.js.map +1 -0
  131. package/lib/module/modules/ShoppingModule.js +3 -1
  132. package/lib/module/modules/ShoppingModule.js.map +1 -1
  133. package/lib/typescript/FireworkSDK.d.ts +26 -24
  134. package/lib/typescript/LiveStream.d.ts +21 -0
  135. package/lib/typescript/VideoShopping.d.ts +6 -6
  136. package/lib/typescript/components/VideoFeed.d.ts +11 -4
  137. package/lib/typescript/index.d.ts +15 -6
  138. package/lib/typescript/models/AdBadgeConfiguration.d.ts +15 -0
  139. package/lib/typescript/models/{ADConfig.d.ts → AdConfig.d.ts} +1 -1
  140. package/lib/typescript/models/FWEventName.d.ts +14 -0
  141. package/lib/typescript/models/FWEvents.d.ts +15 -12
  142. package/lib/typescript/models/FeedItemDetails.d.ts +11 -4
  143. package/lib/typescript/models/LiveStreamChatEventName.d.ts +7 -0
  144. package/lib/typescript/models/LiveStreamEventDetails.d.ts +3 -0
  145. package/lib/typescript/models/LiveStreamEventName.d.ts +15 -0
  146. package/lib/typescript/models/LiveStreamMessageDetails.d.ts +14 -0
  147. package/lib/typescript/models/VideoFeedConfiguration.d.ts +7 -3
  148. package/lib/typescript/models/VideoFeedSource.d.ts +2 -0
  149. package/lib/typescript/models/VideoPlaybackDetails.d.ts +1 -2
  150. package/lib/typescript/models/VideoPlaybackEventName.d.ts +1 -1
  151. package/lib/typescript/models/VideoPlayerConfiguration.d.ts +13 -0
  152. package/lib/typescript/modules/FireworkSDKModule.d.ts +8 -4
  153. package/lib/typescript/modules/LiveStreamModule.d.ts +8 -0
  154. package/lib/typescript/modules/ShoppingModule.d.ts +4 -2
  155. package/package.json +3 -4
  156. package/react-native-firework-sdk.podspec +3 -1
  157. package/src/FireworkSDK.ts +49 -33
  158. package/src/LiveStream.ts +51 -0
  159. package/src/VideoShopping.ts +15 -13
  160. package/src/components/VideoFeed.tsx +69 -7
  161. package/src/index.tsx +32 -15
  162. package/src/models/AdBadgeConfiguration.ts +16 -0
  163. package/src/models/{ADConfig.ts → AdConfig.ts} +1 -1
  164. package/src/models/FWEventName.ts +14 -0
  165. package/src/models/FWEvents.ts +17 -13
  166. package/src/models/FeedItemDetails.ts +12 -4
  167. package/src/models/LiveStreamChatEventName.ts +8 -0
  168. package/src/models/LiveStreamEventDetails.ts +4 -0
  169. package/src/models/LiveStreamEventName.ts +16 -0
  170. package/src/models/LiveStreamMessageDetails.ts +14 -0
  171. package/src/models/VideoFeedConfiguration.ts +7 -3
  172. package/src/models/VideoFeedSource.ts +2 -0
  173. package/src/models/VideoPlaybackDetails.ts +1 -3
  174. package/src/models/VideoPlaybackEventName.ts +1 -1
  175. package/src/models/VideoPlayerConfiguration.ts +14 -0
  176. package/src/modules/FireworkSDKModule.ts +10 -4
  177. package/src/modules/LiveStreamModule.ts +26 -0
  178. package/src/modules/ShoppingModule.ts +14 -7
  179. package/android/src/main/java/com/reactnativefireworksdk/components/videofeed/FWVideoFeed.kt +0 -124
  180. package/android/src/main/java/com/reactnativefireworksdk/manager/FWVideoFeedManager.kt +0 -88
  181. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedConfigModel.kt +0 -27
  182. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedMode.kt +0 -7
  183. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoPlayerConfigModel.kt +0 -20
  184. package/android/src/main/java/com/reactnativefireworksdk/utils/FWVideoPlayerUtils.kt +0 -18
  185. package/lib/commonjs/models/ADConfig.js +0 -2
  186. package/lib/module/models/ADConfig.js +0 -2
@@ -1,19 +1,19 @@
1
- package com.reactnativefireworksdk.module
1
+ package com.fireworksdk.bridge.reactnative.module
2
2
 
3
3
  import android.annotation.SuppressLint
4
4
  import android.content.pm.PackageManager
5
5
  import android.provider.Settings
6
6
  import com.facebook.react.bridge.*
7
- import com.loopnow.fireworklibrary.FwSDK
8
- import com.loopnow.fireworklibrary.SdkStatus
9
- import com.loopnow.fireworklibrary.VideoEvent
10
- import com.reactnativefireworksdk.models.FWVideoPlaybackDetails
11
- import com.reactnativefireworksdk.models.FWVideoPlaybackSubEventName
12
- import com.reactnativefireworksdk.models.FWVideoPlayerConfigModel
13
- import com.reactnativefireworksdk.utils.*
7
+ import com.fireworksdk.bridge.models.FWVideoPlaybackDetails
8
+ import com.fireworksdk.bridge.models.FWVideoPlaybackSubEventName
9
+ import com.fireworksdk.bridge.models.FWVideoPlayerConfigModel
10
+ import com.fireworksdk.bridge.utils.*
14
11
  import org.json.JSONObject
15
12
  import com.facebook.react.bridge.ReactMethod
16
- import com.reactnativefireworksdk.models.FireworkSDKInterface
13
+ import com.fireworksdk.bridge.models.FWAdBadgeConfigModel
14
+ import com.fireworksdk.bridge.reactnative.models.FireworkSDKInterface
15
+ import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
16
+ import com.loopnow.fireworklibrary.*
17
17
 
18
18
 
19
19
  class FireworkSDKModule(
@@ -79,10 +79,19 @@ class FireworkSDKModule(
79
79
  *
80
80
  */
81
81
  @ReactMethod
82
- override fun setShareBaseURL(url: String?) {
82
+ override fun setShareBaseURL(url: String?, promise: Promise) {
83
83
  if (!url.isNullOrBlank()) {
84
84
  FwSDK.setBasePlayerUrl(url)
85
85
  }
86
+ promise.resolve(Arguments.createMap())
87
+ }
88
+
89
+ @ReactMethod
90
+ override fun setAdBadgeConfiguration(config: ReadableMap?, promise: Promise) {
91
+ val configMap = config?.toHashMap()
92
+ val adBadgeConfigModel = FWJsonUtils.fromMap(configMap, FWAdBadgeConfigModel::class.java)
93
+ FWVideoPlayerUtils.setAdBadgeConfig(adBadgeConfigModel)
94
+ promise.resolve(Arguments.createMap())
86
95
  }
87
96
 
88
97
  @ReactMethod
@@ -125,19 +134,9 @@ class FireworkSDKModule(
125
134
  SdkStatus.RefreshTokenFailed -> {
126
135
  FWEventUtils.sendInitFailedEvent(reactApplicationContext, extra)
127
136
  }
128
- SdkStatus.LoadingContent -> {
129
- FWLogUtils.d { "LoadingContent" }
130
- }
131
- SdkStatus.LoadingContentFailed -> {
132
- FWLogUtils.e { "LoadingContentFailed" }
133
- }
134
- SdkStatus.ContentLoaded -> {
135
- FWLogUtils.d { "ContentLoaded" }
136
- }
137
137
  }
138
138
  }
139
139
  })
140
- handleVideoPlaybackEvent()
141
140
  }
142
141
  }
143
142
 
@@ -230,15 +229,17 @@ class FireworkSDKModule(
230
229
  }
231
230
 
232
231
  @ReactMethod
233
- fun addListener(eventName: String?) {
232
+ fun addListener(eventName: String?, promise: Promise) {
234
233
  // Set up any upstream listeners or background tasks as necessary
235
234
  FWLogUtils.d { "addListener: $eventName" }
235
+ promise.resolve(Arguments.createMap())
236
236
  }
237
237
 
238
238
  @ReactMethod
239
- fun removeListeners(count: Int?) {
239
+ fun removeListeners(count: Int?, promise: Promise) {
240
240
  // Remove upstream listeners, stop unnecessary background tasks
241
241
  FWLogUtils.d { "removeListeners: $count" }
242
+ promise.resolve(Arguments.createMap())
242
243
  }
243
244
 
244
245
  override fun getName(): String {
@@ -1,11 +1,11 @@
1
- package com.reactnativefireworksdk.pages
1
+ package com.fireworksdk.bridge.reactnative.pages
2
2
 
3
3
  import android.app.Activity
4
4
  import android.content.Intent
5
5
  import android.os.Bundle
6
6
  import androidx.appcompat.app.AppCompatActivity
7
7
  import androidx.fragment.app.Fragment
8
- import com.reactnativefireworksdk.R
8
+ import com.fireworksdk.bridge.R
9
9
  import com.facebook.react.ReactFragment
10
10
  import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
11
11
 
@@ -14,7 +14,7 @@ class FWVideoShoppingCartActivity : AppCompatActivity(), DefaultHardwareBackBtnH
14
14
 
15
15
  override fun onCreate(savedInstanceState: Bundle?) {
16
16
  super.onCreate(savedInstanceState)
17
- setContentView(R.layout.fwrn_fragment_shoppingcart)
17
+ setContentView(R.layout.fw_bridge_fragment_shoppingcart)
18
18
 
19
19
  val reactNativeFragment: Fragment = ReactFragment.Builder()
20
20
  .setComponentName("FWShoppingCartPage")
@@ -23,7 +23,7 @@ class FWVideoShoppingCartActivity : AppCompatActivity(), DefaultHardwareBackBtnH
23
23
 
24
24
  supportFragmentManager
25
25
  .beginTransaction()
26
- .add(R.id.shopping_cart_container, reactNativeFragment)
26
+ .add(R.id.fw_bridge_shopping_cart_container, reactNativeFragment)
27
27
  .commit()
28
28
  }
29
29
 
@@ -1,11 +1,12 @@
1
- package com.reactnativefireworksdk.utils
1
+ package com.fireworksdk.bridge.reactnative.utils
2
2
 
3
3
  import com.facebook.react.bridge.Arguments
4
4
  import com.facebook.react.bridge.ReactContext
5
5
  import com.facebook.react.bridge.WritableMap
6
6
  import com.facebook.react.modules.core.DeviceEventManagerModule
7
7
  import com.facebook.react.uimanager.events.RCTEventEmitter
8
- import com.reactnativefireworksdk.models.*
8
+ import com.fireworksdk.bridge.models.*
9
+ import com.loopnow.fireworklibrary.data.Product
9
10
 
10
11
  object FWEventUtils {
11
12
 
@@ -25,8 +26,9 @@ object FWEventUtils {
25
26
  val eventMap = Arguments.createMap()
26
27
  val contentMap = Arguments.createMap()
27
28
  contentMap.putInt("index", info.index?:0)
28
- contentMap.putString("videoId", info.id)
29
+ contentMap.putString("id", info.id)
29
30
  contentMap.putInt("duration", info.videoDuration?:0)
31
+ contentMap.putString("source", info.source)
30
32
  eventMap.putMap("info", contentMap)
31
33
  sendEvent(reactContext, FWEventName.VideoFeedClick.rawValue, eventMap)
32
34
  }
@@ -86,10 +88,18 @@ object FWEventUtils {
86
88
  sendEvent(reactContext, FWVideoShoppingEventName.ClickCartIcon.rawValue, eventMap)
87
89
  }
88
90
 
89
- fun sendUpdateProductDetailsEvent(reactContext: ReactContext, productId: String?, callbackId: Int?) {
91
+ fun sendUpdateProductsDetailsEvent(reactContext: ReactContext, products: List<Product>?, videoId: String?) {
90
92
  val eventMap = Arguments.createMap()
91
- eventMap.putString("productId", productId)
92
- eventMap.putInt("callbackId", callbackId?:0)
93
+
94
+ val productArray = Arguments.createArray()
95
+ if (!products.isNullOrEmpty()) {
96
+ for (product in products) {
97
+ productArray.pushString(product.extId)
98
+ }
99
+ }
100
+
101
+ eventMap.putArray("productIds", productArray)
102
+ eventMap.putString("callbackId", videoId)
93
103
  sendEvent(reactContext, FWVideoShoppingEventName.UpdateProductDetails.rawValue, eventMap)
94
104
  }
95
105
 
@@ -99,7 +109,11 @@ object FWEventUtils {
99
109
  .emit(eventName, params)
100
110
  }
101
111
 
102
- fun receiveVideoFeedLoadFinished(reactContext: ReactContext, targetTag: Int, eventName: String, name: String?, reason: String?) {
112
+ fun receiveVideoFeedLoadFinishedSuccessEvent(reactContext: ReactContext, targetTag: Int) {
113
+ receiveEvent(reactContext, targetTag, FWFeedViewEventName.VideoFeedLoadFinished.rawValue, null)
114
+ }
115
+
116
+ fun receiveVideoFeedLoadFinishedFailedEvent(reactContext: ReactContext, targetTag: Int, name: String, reason: String?) {
103
117
  val eventMap = Arguments.createMap()
104
118
  eventMap.putString("name", name)
105
119
  eventMap.putString("reason", reason)
@@ -124,4 +138,44 @@ object FWEventUtils {
124
138
  // event
125
139
  // )
126
140
  }
141
+
142
+ // live stream
143
+ fun sendLiveStreamEvent(reactContext: ReactContext, eventName: String, info: FWLiveStreamEventDetailsModel?) {
144
+ val eventMap = Arguments.createMap()
145
+ eventMap.putString("eventName", eventName)
146
+
147
+ val contentMap = Arguments.createMap()
148
+ if (!info?.id.isNullOrBlank()) {
149
+ contentMap.putString("id", info?.id)
150
+ }
151
+ eventMap.putMap("info", contentMap)
152
+ sendEvent(reactContext, FWEventName.LiveStream.rawValue, eventMap)
153
+ }
154
+
155
+ fun sendLiveStreamChatEvent(reactContext: ReactContext, eventName: String, message: FWLiveStreamMessageDetailsModel?, liveStream: FWLiveStreamEventDetailsModel?) {
156
+ val eventMap = Arguments.createMap()
157
+ eventMap.putString("eventName", eventName)
158
+
159
+ // chat map
160
+ val chatMap = Arguments.createMap()
161
+ if (!message?.messageId.isNullOrBlank()) {
162
+ chatMap.putString("messageId", message?.messageId)
163
+ }
164
+ if (!message?.username.isNullOrBlank()) {
165
+ chatMap.putString("username", message?.username)
166
+ }
167
+ if (!message?.text.isNullOrBlank()) {
168
+ chatMap.putString("text", message?.text)
169
+ }
170
+ eventMap.putMap("chat", chatMap)
171
+
172
+ // live stream map
173
+ val liveStreamMap = Arguments.createMap()
174
+ if (!liveStream?.id.isNullOrBlank()) {
175
+ liveStreamMap.putString("id", liveStream?.id)
176
+ }
177
+ eventMap.putMap("liveStream", liveStreamMap)
178
+
179
+ sendEvent(reactContext, FWEventName.LiveStreamChat.rawValue, eventMap)
180
+ }
127
181
  }
@@ -1,7 +1,8 @@
1
- package com.reactnativefireworksdk.utils
1
+ package com.fireworksdk.bridge.utils
2
2
 
3
3
  import android.os.Looper
4
4
  import com.fasterxml.jackson.annotation.JsonInclude
5
+ import com.fasterxml.jackson.core.type.TypeReference
5
6
  import com.fasterxml.jackson.databind.DeserializationFeature
6
7
  import com.fasterxml.jackson.databind.ObjectMapper
7
8
  import com.fasterxml.jackson.databind.SerializationFeature
@@ -54,4 +55,31 @@ object FWJsonUtils {
54
55
  }
55
56
  return null
56
57
  }
58
+
59
+ @JvmStatic
60
+ fun <T> fromJson(json: String?, type: TypeReference<T>): T? {
61
+ if (json.isNullOrBlank()) {
62
+ return null
63
+ }
64
+ try {
65
+ return mapper.readValue(json, type)
66
+ } catch (e: Exception) {
67
+ e.printStackTrace()
68
+ logJsonError(e)
69
+ }
70
+ return null
71
+ }
72
+
73
+ @JvmStatic
74
+ fun toJson(obj: Any?): String? {
75
+ if (obj == null) {
76
+ return null
77
+ }
78
+ try {
79
+ return mapper.writeValueAsString(obj)
80
+ } catch (e: Exception) {
81
+ e.printStackTrace()
82
+ }
83
+ return null
84
+ }
57
85
  }
@@ -1,9 +1,9 @@
1
- package com.reactnativefireworksdk.utils
1
+ package com.fireworksdk.bridge.utils
2
2
 
3
3
  import android.os.Looper
4
4
  import android.os.SystemClock
5
5
  import android.util.Log
6
- import com.reactnativefireworksdk.BuildConfig
6
+ import com.fireworksdk.bridge.BuildConfig
7
7
  import kotlin.math.max
8
8
 
9
9
  /**
@@ -1,4 +1,4 @@
1
- package com.reactnativefireworksdk.utils
1
+ package com.fireworksdk.bridge.utils
2
2
 
3
3
  import android.net.Uri
4
4
 
@@ -0,0 +1,94 @@
1
+ package com.fireworksdk.bridge.utils
2
+
3
+ import android.graphics.Color
4
+ import com.loopnow.fireworklibrary.VideoPlayerProperties
5
+ import com.fireworksdk.bridge.constants.FWVideoPlayerConstant
6
+ import com.fireworksdk.bridge.models.FWAdBadgeConfigModel
7
+ import com.fireworksdk.bridge.models.FWVideoFeedConfigModel
8
+ import com.fireworksdk.bridge.models.FWVideoFeedTitlePosition
9
+ import com.fireworksdk.bridge.models.FWVideoPlayerConfigModel
10
+ import com.loopnow.fireworklibrary.AdLabelType
11
+ import com.loopnow.fireworklibrary.VideoFeedProperties
12
+ import com.loopnow.fireworklibrary.models.FeedTitlePosition
13
+ import com.loopnow.fireworklibrary.views.PlaylistGroupFeedView
14
+ import com.loopnow.fireworklibrary.views.VideoFeedView
15
+
16
+ object FWVideoPlayerUtils {
17
+
18
+ var customCTAClickEnabled: Boolean = false
19
+ var videoPlaybackEventEnabled: Boolean = false
20
+
21
+ private var hasAssignedLaunchAppWithMute = false
22
+ /**
23
+ * if true, mute when open player (can be set only once)
24
+ */
25
+ private var launchPlayerWithMute = false
26
+ set(value) {
27
+ if (!hasAssignedLaunchAppWithMute) {
28
+ hasAssignedLaunchAppWithMute = true
29
+ VideoPlayerProperties.launchPlayerWithMute = value
30
+ field = value
31
+ }
32
+ }
33
+
34
+
35
+ fun setAdBadgeConfig(config: FWAdBadgeConfigModel?) {
36
+ val badgeTextType = config?.badgeTextType
37
+ when {
38
+ badgeTextType.equals(FWVideoPlayerConstant.FW_AD_BADGE_LABEL_AD) -> {
39
+ VideoFeedProperties.setAdLabel(AdLabelType.AD)
40
+ }
41
+ badgeTextType.equals(FWVideoPlayerConstant.FW_AD_BADGE_LABEL_SPONSORED) -> {
42
+ VideoFeedProperties.setAdLabel(AdLabelType.SPONSORED)
43
+ }
44
+ }
45
+ }
46
+
47
+ fun setPlaylistGroupFeedConfig(feedView: PlaylistGroupFeedView?, config: FWVideoFeedConfigModel?) {
48
+ val backgroundColor = config?.backgroundColor
49
+ if (!backgroundColor.isNullOrBlank()) {
50
+ feedView?.setBackgroundColor(Color.parseColor(backgroundColor))
51
+ } else {
52
+ feedView?.setBackgroundColor(Color.TRANSPARENT)
53
+ }
54
+
55
+ feedView?.setTitleVisible(config?.title?.hidden != true)
56
+
57
+ val titlePosition = when {
58
+ config?.titlePosition.equals(FWVideoFeedTitlePosition.Stacked.rawValue) -> FeedTitlePosition.BELOW
59
+ else -> FeedTitlePosition.ALIGN_BOTTOM
60
+ }
61
+ feedView?.setTitlePosition(titlePosition)
62
+ VideoFeedProperties.displayAdLabel = config?.showAdBadge == true
63
+ }
64
+
65
+ fun setVideoFeedConfig(feedView: VideoFeedView?, config: FWVideoFeedConfigModel?) {
66
+ val backgroundColor = config?.backgroundColor
67
+ if (!backgroundColor.isNullOrBlank()) {
68
+ feedView?.setBackgroundColor(Color.parseColor(backgroundColor))
69
+ } else {
70
+ feedView?.setBackgroundColor(Color.TRANSPARENT)
71
+ }
72
+
73
+ feedView?.setTitleVisible(config?.title?.hidden != true)
74
+
75
+ val titlePosition = when {
76
+ config?.titlePosition.equals(FWVideoFeedTitlePosition.Stacked.rawValue) -> FeedTitlePosition.BELOW
77
+ else -> FeedTitlePosition.ALIGN_BOTTOM
78
+ }
79
+ feedView?.setTitlePosition(titlePosition)
80
+ VideoFeedProperties.displayAdLabel = config?.showAdBadge == true
81
+ }
82
+
83
+ fun setVideoPlayerConfig(config: FWVideoPlayerConfigModel?) {
84
+ VideoPlayerProperties.share = config?.showShareButton != false
85
+ VideoPlayerProperties.loop = config?.videoCompleteAction != FWVideoPlayerConstant.FW_VIDEO_COMPLETE_ACTION_ADVANCE_TO_NEXT
86
+ // VideoPlayerProperties.autoPlayOnComplete = config?.videoCompleteAction != FWVideoPlayerConstant.FW_VIDEO_COMPLETE_ACTION_LOOP
87
+ VideoPlayerProperties.fullScreenPlayer = config?.playerStyle != FWVideoPlayerConstant.FW_PLAYER_STYLE_FIT
88
+ VideoPlayerProperties.enableOneTouchMute = config?.showMuteButton == true
89
+ VideoPlayerProperties.enablePlayPauseControl = config?.showPlaybackButton == true
90
+ if (config?.launchBehavior != null) {
91
+ launchPlayerWithMute = config.launchBehavior == FWVideoPlayerConstant.FW_PLAYER_LAUNCH_BEHAVIOR_MUTE_ON_FIRST_LAUNCH
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,18 @@
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:id="@+id/fw_bridge_playlistfeed_container"
6
+ android:background="@color/fw_bridge_white"
7
+ android:layout_width="match_parent"
8
+ android:layout_height="match_parent">
9
+
10
+ <com.loopnow.fireworklibrary.views.PlaylistGroupFeedView
11
+ android:id="@+id/fw_bridge_playlistfeed"
12
+ android:layout_width="match_parent"
13
+ android:layout_height="match_parent"
14
+ app:imageStyle="@style/FWFeedViewImageStyle"
15
+ app:textStyle="@style/FWFeedViewCaptionStyle"
16
+ />
17
+
18
+ </androidx.constraintlayout.widget.ConstraintLayout>
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <androidx.constraintlayout.widget.ConstraintLayout
3
3
  xmlns:android="http://schemas.android.com/apk/res/android"
4
- android:id="@+id/shopping_cart_container"
4
+ android:id="@+id/fw_bridge_shopping_cart_container"
5
5
  android:layout_width="match_parent"
6
6
  android:layout_height="match_parent">
7
7
 
@@ -2,11 +2,12 @@
2
2
  <androidx.constraintlayout.widget.ConstraintLayout
3
3
  xmlns:android="http://schemas.android.com/apk/res/android"
4
4
  xmlns:app="http://schemas.android.com/apk/res-auto"
5
+ android:id="@+id/fw_bridge_videofeed_container"
5
6
  android:layout_width="match_parent"
6
7
  android:layout_height="match_parent">
7
8
 
8
9
  <com.loopnow.fireworklibrary.views.VideoFeedView
9
- android:id="@+id/fwrn_integrated_videofeed"
10
+ android:id="@+id/fw_bridge_videofeed"
10
11
  android:layout_width="match_parent"
11
12
  android:layout_height="match_parent"
12
13
  app:feedLayout="horizontal"
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <color name="fw_bridge_white">#FFFFFF</color>
4
+ </resources>
@@ -31,7 +31,7 @@ public enum VideoFeedMode: Int {
31
31
 
32
32
  @objc
33
33
  public enum VideFeedSourceType: Int {
34
- case discover, channel, playlist
34
+ case discover, channel, playlist, playlistGroup
35
35
  }
36
36
 
37
37
  public protocol VideoFeedViewDelegate: AnyObject {
@@ -47,6 +47,7 @@ public class VideoFeed: UIView, VideoFeedViewControllerDelegate {
47
47
  @objc public var sourceType: VideFeedSourceType = .discover
48
48
  @objc public var channel: String = ""
49
49
  @objc public var playlist: String = ""
50
+ @objc public var playlistGroup: String = ""
50
51
  @objc public var mode: VideoFeedMode = .row
51
52
  @objc public var feedViewConfig: VideoFeedConfiguration? {
52
53
  didSet {
@@ -78,6 +79,8 @@ public class VideoFeed: UIView, VideoFeedViewControllerDelegate {
78
79
  return .channel(channelID: channel)
79
80
  case .playlist:
80
81
  return .channelPlaylist(channelID: channel, playlistID: playlist)
82
+ case .playlistGroup:
83
+ return .playlistGroup(groupID: playlistGroup)
81
84
  }
82
85
  }
83
86
 
@@ -113,11 +116,13 @@ public class VideoFeed: UIView, VideoFeedViewControllerDelegate {
113
116
  }
114
117
 
115
118
  public override func removeFromSuperview() {
116
- guard let feedVC = feedVC, let parentVC = parentViewController else {
119
+ guard let feedVC = feedVC, feedVC.parent != nil else {
117
120
  return
118
121
  }
119
122
 
120
- parentVC.detachChild(feedVC)
123
+ feedVC.willMove(toParent: nil)
124
+ feedVC.removeFromParent()
125
+ feedVC.view.removeFromSuperview()
121
126
  // feedVC.willMove(toParent: nil)
122
127
  // feedVC.removeFromParent()
123
128
  // feedVC.view.removeFromSuperview()
@@ -148,6 +153,28 @@ public class VideoFeed: UIView, VideoFeedViewControllerDelegate {
148
153
  }
149
154
 
150
155
  extension VideoFeed {
156
+ private func convertToFWAdBadgeConfiguration(_ adBadgeConfiguration: AdBadgeConfiguration?) -> FireworkVideo.AdBadgeConfiguration? {
157
+ guard let adBadgeConfiguration = adBadgeConfiguration else {
158
+ return nil
159
+ }
160
+
161
+ var fwAdBadgeConfiguration = FireworkVideo.AdBadgeConfiguration()
162
+ if let textColor = adBadgeConfiguration.textColor {
163
+ fwAdBadgeConfiguration.textColor = textColor.uicolor()
164
+ }
165
+ if let backgroundColor = adBadgeConfiguration.backgroundColor {
166
+ fwAdBadgeConfiguration.backgroundColor = backgroundColor.uicolor()
167
+ }
168
+ switch adBadgeConfiguration.badgeTextType {
169
+ case .sponsored:
170
+ fwAdBadgeConfiguration.badgeText = FireworkVideo.AdBadgeConfiguration.BadgeText.sponsored
171
+ default:
172
+ fwAdBadgeConfiguration.badgeText = FireworkVideo.AdBadgeConfiguration.BadgeText.ad
173
+ }
174
+
175
+ return fwAdBadgeConfiguration
176
+ }
177
+
151
178
  private func convertToVideoFeedConentConfiguration() -> VideoFeedContentConfiguration {
152
179
  var videoConfig = VideoFeedContentConfiguration()
153
180
  //set default value so that behavior will the same with Android
@@ -169,6 +196,10 @@ extension VideoFeed {
169
196
  if let shareBaseUrl = gShareBaseURL {
170
197
  videoConfig.playerView.shareButton.behavior.baseURL = URL(string:shareBaseUrl)
171
198
  }
199
+ let adBadge = self.convertToFWAdBadgeConfiguration(gAdBadgeConfiguration)
200
+ if let adBadge = adBadge {
201
+ videoConfig.adBadge = adBadge
202
+ }
172
203
 
173
204
  //set a value different from default value to compatible with FireworkVideo SDK misalign bug
174
205
  videoConfig.itemView.titleLayoutConfiguration.insets = UIEdgeInsets(top: 7, left: 7, bottom: 7, right: 7)
@@ -216,6 +247,12 @@ extension VideoFeed {
216
247
  vfcConfig.titleLayoutConfiguration.titlePosition = .nested
217
248
  }
218
249
  }
250
+ if let showSponsored = config.showSponsored {
251
+ vfcConfig.sponsored.isHidden = !showSponsored
252
+ }
253
+ if let showAdBadge = config.showAdBadge {
254
+ vfcConfig.sponsored.isHidden = !showAdBadge
255
+ }
219
256
 
220
257
  return vfcConfig
221
258
  }
@@ -256,7 +293,27 @@ extension VideoFeed {
256
293
  vpcConfig.ctaButton.font = UIFont.systemFont(ofSize: CGFloat(fontSize))
257
294
  }
258
295
  }
296
+ if let showPlaybackButton = config.showPlaybackButton {
297
+ vpcConfig.playbackButton.isHidden = !showPlaybackButton
298
+ }
299
+ if let showMuteButton = config.showMuteButton {
300
+ vpcConfig.muteButton.isHidden = !showMuteButton
301
+ if let launchBehavior = config.launchBehavior {
302
+ vpcConfig.onFirstLaunch = launchBehavior.behavior()
303
+ }
304
+ }
259
305
 
260
306
  return vpcConfig
261
307
  }
262
308
  }
309
+
310
+ extension VideoPlayerConfiguration.VideoLaunchBehavior {
311
+ func behavior() -> VideoPlayerContentConfiguration.VideoLaunchBehavior {
312
+ switch self {
313
+ case .muteOnFirstLaunch:
314
+ return .muteOnFirstLaunch
315
+ default:
316
+ return .`default`
317
+ }
318
+ }
319
+ }
@@ -14,6 +14,8 @@ public class VideoFeedConfiguration: NSObject, Codable {
14
14
  var title: VideoFeedTitleConfiguration?
15
15
  var titlePosition: VideoFeedTitlePosition?
16
16
  var playIcon: VideoFeedPlayIconConfiguration?
17
+ var showSponsored: Bool?
18
+ var showAdBadge: Bool?
17
19
 
18
20
  class VideoFeedTitleConfiguration: NSObject, Codable {
19
21
  public var hidden: Bool?
@@ -21,6 +21,8 @@ RCT_CUSTOM_VIEW_PROPERTY(source, VideFeedSourceType, VideoFeed) {
21
21
  }
22
22
  RCT_EXPORT_VIEW_PROPERTY(channel, NSString)
23
23
  RCT_EXPORT_VIEW_PROPERTY(playlist, NSString)
24
+ RCT_EXPORT_VIEW_PROPERTY(playlistGroup, NSString)
25
+
24
26
  RCT_CUSTOM_VIEW_PROPERTY(mode, VideoFeedMode, VideoFeed) {
25
27
  if (json) {
26
28
  VideoFeedMode mode = [RCTConvert videoFeedMode:json];
@@ -13,6 +13,9 @@ public class VideoPlayerConfiguration: NSObject, Codable {
13
13
  var videoCompleteAction: VideoPlayerCompleteAction?
14
14
  var showShareButton: Bool?
15
15
  var ctaButtonStyle: VideoPlayerCTAStyle?
16
+ var showPlaybackButton: Bool?
17
+ var showMuteButton: Bool?
18
+ var launchBehavior: VideoLaunchBehavior?
16
19
 
17
20
  public enum VideoPlayerStyle: String, Codable {
18
21
  case full, fit
@@ -27,4 +30,8 @@ public class VideoPlayerConfiguration: NSObject, Codable {
27
30
  var textColor: String?
28
31
  var fontSize: Int?
29
32
  }
33
+
34
+ public enum VideoLaunchBehavior: String, Codable {
35
+ case `default`, muteOnFirstLaunch
36
+ }
30
37
  }
@@ -7,11 +7,14 @@
7
7
 
8
8
  import Foundation
9
9
 
10
+ /// Video event
10
11
  enum FWEventName: String, CaseIterable {
11
12
  case SDKInit = "fw:sdk-init"
12
13
  case CustomCTAClick = "fw:custom-cta-click"
13
14
  case VideoPlayback = "fw:video-playback"
14
15
  case VideoFeedClick = "fw:video-feed-click"
16
+ case ShareBaseURLUpdated = "fw:share-base-url-updated" //emitted in JS side
17
+ case AdBadgeConfigurationUpdated = "fw:ad-badge-configuration-updated" //emitted in JS side
15
18
  }
16
19
 
17
20
  enum VideoPlaybackSubEventName: String {
@@ -26,9 +29,26 @@ enum VideoPlaybackSubEventName: String {
26
29
  case ClickShare = "fw:video:click-share"
27
30
  }
28
31
 
32
+ /// Shopping event
29
33
  enum ShoppingEventName: String, CaseIterable {
30
34
  case UpdateProductDetails = "fw:shopping:update-product-details"
31
35
  case WillDisplayProduct = "fw:shopping:will-display-product"
32
36
  case AddToCart = "fw:shopping:add-to-cart"
33
37
  case ClickCartIcon = "fw:shopping:click-cart-icon"
34
38
  }
39
+
40
+ /// Live stream event
41
+ enum LiveStreamEventName: String, CaseIterable {
42
+ case livestream = "fw:livestream"
43
+ case livestreamChat = "fw:livestream-chat"
44
+ }
45
+
46
+ enum LiveStreamSubEventName: String {
47
+ case UserDidjoin = "fw:livestream:user-join"
48
+ case UserDidLeave = "fw:livestream:user-leave"
49
+ case UserSendLike = "fw:livestream:user-send-like"
50
+ }
51
+
52
+ enum LiveStreamChatSubEventName: String {
53
+ case UserSendChat = "fw:livestream:user-send-chat"
54
+ }