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
@@ -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 FWLiveStreamMessageDetailsModel(
8
+ val messageId: String? = null,
9
+ val username: String? = null,
10
+ val text: String? = null,
11
+ ) : Parcelable
@@ -0,0 +1,28 @@
1
+ package com.fireworksdk.bridge.models
2
+
3
+ import android.os.Parcelable
4
+ import kotlinx.android.parcel.Parcelize
5
+
6
+ @Parcelize
7
+ data class FWVideoFeedConfigModel(
8
+ var backgroundColor: String? = null,
9
+ var cornerRadius: Int? = null,
10
+ var title: FWTitleModel? = null,
11
+ var titlePosition: String? = null,
12
+ var playIcon: FWPlayIconModel? = null,
13
+ var showAdBadge: Boolean? = null
14
+ ) : Parcelable {
15
+
16
+ @Parcelize
17
+ data class FWTitleModel(
18
+ var hidden: Boolean? = null,
19
+ var textColor: String? = null,
20
+ var fontSize: Int? = null,
21
+ ) : Parcelable
22
+
23
+ @Parcelize
24
+ data class FWPlayIconModel(
25
+ var hidden: Boolean? = null,
26
+ var iconWidth: Int? = null,
27
+ ) : Parcelable
28
+ }
@@ -1,4 +1,4 @@
1
- package com.reactnativefireworksdk.models
1
+ package com.fireworksdk.bridge.models
2
2
 
3
3
  import android.os.Parcelable
4
4
  import kotlinx.android.parcel.Parcelize
@@ -8,4 +8,5 @@ data class FWVideoFeedItemDetailsModel(
8
8
  val index: Int?,
9
9
  val id: String?,
10
10
  val videoDuration: Int?,
11
+ val source: String?,
11
12
  ) : Parcelable
@@ -0,0 +1,7 @@
1
+ package com.fireworksdk.bridge.models
2
+
3
+ enum class FWVideoFeedModel(val rawValue: String) {
4
+ Row("row"),
5
+ Column("column"),
6
+ Grid("grid"),
7
+ }
@@ -0,0 +1,18 @@
1
+ package com.fireworksdk.bridge.models
2
+
3
+ import android.os.Parcelable
4
+ import com.fireworksdk.bridge.models.FWVideoFeedConfigModel
5
+ import com.fireworksdk.bridge.models.FWVideoPlayerConfigModel
6
+ import kotlinx.android.parcel.Parcelize
7
+
8
+
9
+ @Parcelize
10
+ data class FWVideoFeedPropsModel(
11
+ var source: String? = null,
12
+ var channel: String? = null,
13
+ var playlist: String? = null,
14
+ var playlistGroup: String? = null,
15
+ var mode: String? = null,
16
+ var videoFeedConfiguration: FWVideoFeedConfigModel? = null,
17
+ var videoPlayerConfiguration: FWVideoPlayerConfigModel? = null,
18
+ ) : Parcelable
@@ -1,7 +1,8 @@
1
- package com.reactnativefireworksdk.models
1
+ package com.fireworksdk.bridge.models
2
2
 
3
3
  enum class FWVideoFeedSource(val rawValue: String) {
4
4
  Discover("discover"),
5
5
  Channel("channel"),
6
6
  Playlist("playlist"),
7
+ PlaylistGroup("playlistGroup"),
7
8
  }
@@ -1,4 +1,4 @@
1
- package com.reactnativefireworksdk.models
1
+ package com.fireworksdk.bridge.models
2
2
 
3
3
  enum class FWVideoFeedTitlePosition(val intValue: Int, val rawValue: String) {
4
4
  Nested(1, "nested"),
@@ -1,4 +1,4 @@
1
- package com.reactnativefireworksdk.models
1
+ package com.fireworksdk.bridge.models
2
2
 
3
3
  import android.os.Parcelable
4
4
  import com.fasterxml.jackson.annotation.JsonProperty
@@ -0,0 +1,23 @@
1
+ package com.fireworksdk.bridge.models
2
+
3
+ import android.os.Parcelable
4
+ import kotlinx.android.parcel.Parcelize
5
+
6
+ @Parcelize
7
+ data class FWVideoPlayerConfigModel(
8
+ var playerStyle: String? = null,
9
+ var videoCompleteAction: String? = null,
10
+ var showShareButton: Boolean? = null,
11
+ var ctaButtonStyle: FWCtaButtonStyleModel? = null,
12
+ var showMuteButton: Boolean? = null,
13
+ var showPlaybackButton: Boolean? = null,
14
+ var launchBehavior: String? = null,
15
+ ) : Parcelable {
16
+
17
+ @Parcelize
18
+ data class FWCtaButtonStyleModel(
19
+ var backgroundColor: String? = null,
20
+ var fontSize: String? = null,
21
+ var textColor: String? = null,
22
+ ) : Parcelable
23
+ }
@@ -1,4 +1,4 @@
1
- package com.reactnativefireworksdk.models
1
+ package com.fireworksdk.bridge.models
2
2
 
3
3
  import android.os.Parcelable
4
4
  import kotlinx.android.parcel.Parcelize
@@ -0,0 +1,19 @@
1
+ package com.fireworksdk.bridge.models
2
+
3
+ import java.lang.ref.WeakReference
4
+ import kotlin.properties.ReadWriteProperty
5
+ import kotlin.reflect.KProperty
6
+
7
+ fun <V> weakProperty(defaultValue: V? = null) = WeakProperty(defaultValue)
8
+
9
+ class WeakProperty<V>(defaultValue: V? = null) : ReadWriteProperty<Any?, V?> {
10
+ private var reference: WeakReference<V>? = WeakReference(defaultValue)
11
+
12
+ override fun getValue(thisRef: Any?, property: KProperty<*>): V? {
13
+ return reference?.get()
14
+ }
15
+
16
+ override fun setValue(thisRef: Any?, property: KProperty<*>, value: V?) {
17
+ reference = if (value != null) WeakReference(value) else null
18
+ }
19
+ }
@@ -1,17 +1,22 @@
1
- package com.reactnativefireworksdk
1
+ package com.fireworksdk.bridge.reactnative
2
2
 
3
3
  import com.facebook.react.ReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.uimanager.ViewManager
7
- import com.reactnativefireworksdk.manager.FWVideoFeedManager
8
- import com.reactnativefireworksdk.module.FWVideoShoppingModule
9
- import com.reactnativefireworksdk.module.FireworkSDKModule
7
+ import com.fireworksdk.bridge.reactnative.manager.FWVideoFeedManager
8
+ import com.fireworksdk.bridge.reactnative.module.FWLiveStreamModule
9
+ import com.fireworksdk.bridge.reactnative.module.FWVideoShoppingModule
10
+ import com.fireworksdk.bridge.reactnative.module.FireworkSDKModule
10
11
 
11
12
 
12
13
  class FireworkSDKPackage : ReactPackage {
13
14
  override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
14
- return listOf(FireworkSDKModule(reactContext), FWVideoShoppingModule(reactContext))
15
+ return listOf(
16
+ FireworkSDKModule(reactContext),
17
+ FWVideoShoppingModule(reactContext),
18
+ FWLiveStreamModule(reactContext)
19
+ )
15
20
  }
16
21
 
17
22
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
@@ -0,0 +1,175 @@
1
+ package com.fireworksdk.bridge.reactnative.manager
2
+
3
+ import android.app.Activity
4
+ import com.facebook.react.bridge.ReadableArray
5
+ import com.facebook.react.bridge.ReadableMap
6
+ import com.facebook.react.uimanager.SimpleViewManager
7
+ import com.facebook.react.uimanager.ThemedReactContext
8
+
9
+ import com.facebook.react.uimanager.annotations.ReactProp
10
+ import com.fireworksdk.bridge.constants.FWCommandConstant
11
+ import com.fireworksdk.bridge.models.FWVideoFeedConfigModel
12
+ import com.fireworksdk.bridge.models.FWVideoPlayerConfigModel
13
+ import com.fireworksdk.bridge.utils.FWJsonUtils
14
+ import com.facebook.react.common.MapBuilder
15
+ import com.fireworksdk.bridge.components.videofeed.FWVideoFeed
16
+ import com.fireworksdk.bridge.models.FWFeedViewEventName
17
+ import com.fireworksdk.bridge.models.FWVideoFeedItemDetailsModel
18
+ import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
19
+ import com.fireworksdk.bridge.utils.FWLogUtils
20
+ import com.loopnow.fireworklibrary.models.OnPlaylistGroupItemClickedListener
21
+ import com.loopnow.fireworklibrary.models.VideoContentStatus
22
+ import com.loopnow.fireworklibrary.views.OnItemClickedListener
23
+ import com.loopnow.fireworklibrary.views.OnVideoContentStatusListener
24
+
25
+
26
+ class FWVideoFeedManager : SimpleViewManager<FWVideoFeed>() {
27
+
28
+ private lateinit var reactContext: ThemedReactContext
29
+ private lateinit var videoFeed: FWVideoFeed
30
+
31
+ override fun getName(): String {
32
+ return "FWVideoFeed"
33
+ }
34
+
35
+ override fun createViewInstance(reactContext: ThemedReactContext): FWVideoFeed {
36
+ this.reactContext = reactContext
37
+ videoFeed = FWVideoFeed(reactContext.currentActivity as Activity)
38
+ return videoFeed
39
+ }
40
+
41
+ private fun addVideoFeedListener(reactContext: ThemedReactContext, videoFeed: FWVideoFeed?) {
42
+ val videoFeedView = videoFeed?.videoFeedView
43
+ videoFeedView?.addOnItemClickedListener(object: OnItemClickedListener {
44
+ override fun onItemClicked(index: Int, title: String, id: String, videoDuration: Long) {
45
+ val fwVideoFeedItemDetailsModel = FWVideoFeedItemDetailsModel(
46
+ index, id, videoDuration.toInt(), videoFeed.videoFeedPropsModel.source
47
+ )
48
+ FWEventUtils.sendVideoFeedClickEvent(reactContext, fwVideoFeedItemDetailsModel)
49
+ }
50
+
51
+ override fun onItemClicked(index: Int) {
52
+ super.onItemClicked(index)
53
+ }
54
+
55
+ override fun onItemClicked(index: Int, feedId: Int): Boolean {
56
+ return super.onItemClicked(index, feedId)
57
+ }
58
+ })
59
+ videoFeedView?.addOnVideoContentStatusListener(object: OnVideoContentStatusListener {
60
+ override fun currentStatus(status: VideoContentStatus, extra: String) {
61
+ when (status) {
62
+ VideoContentStatus.LoadingContent -> {
63
+ FWLogUtils.d { "VideoContentStatus.LoadingContent" }
64
+ }
65
+ VideoContentStatus.LoadingContentFailed -> {
66
+ FWLogUtils.e { "VideoContentStatus.LoadingContentFailed" }
67
+ FWEventUtils.receiveVideoFeedLoadFinishedFailedEvent(reactContext, videoFeedView.id, VideoContentStatus.LoadingContentFailed.rawValue, extra)
68
+ }
69
+ VideoContentStatus.ContentLoaded -> {
70
+ FWLogUtils.d { "VideoContentStatus.ContentLoaded" }
71
+ FWEventUtils.receiveVideoFeedLoadFinishedSuccessEvent(reactContext, videoFeedView.id)
72
+ }
73
+ }
74
+ }
75
+ })
76
+ }
77
+
78
+ private fun addPlaylistGroupFeedListener(reactContext: ThemedReactContext, videoFeed: FWVideoFeed?) {
79
+ val playlistGroupFeedView = videoFeed?.playlistGroupFeedView
80
+ playlistGroupFeedView?.itemClickHandler = object : OnPlaylistGroupItemClickedListener {
81
+ override fun onItemClicked(index: Int, id: String?): Boolean {
82
+ val fwVideoFeedItemDetailsModel = FWVideoFeedItemDetailsModel(
83
+ index, id, 0, videoFeed?.videoFeedPropsModel?.source
84
+ )
85
+ FWEventUtils.sendVideoFeedClickEvent(reactContext, fwVideoFeedItemDetailsModel)
86
+ return false
87
+ }
88
+ }
89
+
90
+ playlistGroupFeedView?.addOnVideoContentStatusListener(object: OnVideoContentStatusListener {
91
+ override fun currentStatus(status: VideoContentStatus, extra: String) {
92
+ when (status) {
93
+ VideoContentStatus.LoadingContent -> {
94
+ FWLogUtils.d { "VideoContentStatus.LoadingContent" }
95
+ }
96
+ VideoContentStatus.LoadingContentFailed -> {
97
+ FWLogUtils.e { "VideoContentStatus.LoadingContentFailed" }
98
+ FWEventUtils.receiveVideoFeedLoadFinishedFailedEvent(reactContext, playlistGroupFeedView.id, VideoContentStatus.LoadingContentFailed.rawValue, extra)
99
+ }
100
+ VideoContentStatus.ContentLoaded -> {
101
+ FWLogUtils.d { "VideoContentStatus.ContentLoaded" }
102
+ FWEventUtils.receiveVideoFeedLoadFinishedSuccessEvent(reactContext, playlistGroupFeedView.id)
103
+ }
104
+ }
105
+ }
106
+ })
107
+ }
108
+
109
+ @ReactProp(name = "source")
110
+ fun setSource(view: FWVideoFeed, source: String?) {
111
+ view.setSourceProps(source)
112
+ addVideoFeedListener(reactContext, videoFeed)
113
+ addPlaylistGroupFeedListener(reactContext, videoFeed)
114
+ }
115
+
116
+ @ReactProp(name = "channel")
117
+ fun setChannel(view: FWVideoFeed, channel: String?) {
118
+ view.setChannelProps(channel)
119
+ }
120
+
121
+ @ReactProp(name = "playlist")
122
+ fun setPlaylist(view: FWVideoFeed, playlist: String?) {
123
+ view.setPlaylistProps(playlist)
124
+ }
125
+
126
+ @ReactProp(name = "playlistGroup")
127
+ fun setPlaylistGroup(view: FWVideoFeed, playlistGroup: String?) {
128
+ view.setPlaylistGroupProps(playlistGroup)
129
+ }
130
+
131
+ @ReactProp(name = "mode")
132
+ fun setMode(view: FWVideoFeed, mode: String?) {
133
+ view.setModeProps(mode)
134
+ }
135
+
136
+ @ReactProp(name = "videoFeedConfiguration")
137
+ fun setVideoFeedConfig(view: FWVideoFeed, config: ReadableMap?) {
138
+ val configMap = config?.toHashMap()
139
+ val videoFeedConfigModel = FWJsonUtils.fromMap(configMap, FWVideoFeedConfigModel::class.java)
140
+ view.setVideoFeedConfigProps(videoFeedConfigModel)
141
+ }
142
+
143
+ @ReactProp(name = "videoPlayerConfiguration")
144
+ fun setVideoPlayerConfig(view: FWVideoFeed, config: ReadableMap?) {
145
+ val configMap = config?.toHashMap()
146
+ val videoPlayerConfigModel = FWJsonUtils.fromMap(configMap, FWVideoPlayerConfigModel::class.java)
147
+ view.setVideoPlayerConfigProps(videoPlayerConfigModel)
148
+ }
149
+
150
+ override fun getCommandsMap(): MutableMap<String, Int> {
151
+ val map: MutableMap<String, Int> = HashMap()
152
+ map["refresh"] = FWCommandConstant.FW_COMMAND_VIDEO_FEED_REFRESH
153
+ return map
154
+ }
155
+
156
+ override fun receiveCommand(root: FWVideoFeed, commandId: Int, args: ReadableArray?) {
157
+ when (commandId) {
158
+ FWCommandConstant.FW_COMMAND_VIDEO_FEED_REFRESH -> {
159
+ root.refresh()
160
+ }
161
+ }
162
+ }
163
+
164
+ /**
165
+ * To map the "onVideoFeedLoadFinished" event name to the "onVideoFeedLoadFinished" callback prop in JavaScript
166
+ * first onVideoFeedLoadFinished is event name
167
+ * second onVideoFeedLoadFinished is callback prop in JavaScript
168
+ */
169
+ override fun getExportedCustomBubblingEventTypeConstants(): MutableMap<String, Any>? {
170
+ return MapBuilder.builder<String, Any>()
171
+ .put(FWFeedViewEventName.VideoFeedLoadFinished.rawValue, MapBuilder.of("phasedRegistrationNames", MapBuilder.of("bubbled", FWFeedViewEventName.VideoFeedLoadFinished.rawValue)))
172
+ .build()
173
+ }
174
+
175
+ }
@@ -0,0 +1,5 @@
1
+ package com.fireworksdk.bridge.reactnative.models
2
+
3
+ interface FWLiveStreamInterface {
4
+ fun init()
5
+ }
@@ -1,11 +1,12 @@
1
- package com.reactnativefireworksdk.models
1
+ package com.fireworksdk.bridge.reactnative.models
2
2
 
3
+ import com.facebook.react.bridge.ReadableArray
3
4
  import com.facebook.react.bridge.ReadableMap
4
5
 
5
6
  interface FWVideoShoppingInterface {
6
7
 
7
8
  fun init()
8
- fun updateVideoProduct(productMap: ReadableMap?, callbackId: Int?)
9
+ fun updateVideoProducts(productArray: ReadableArray?, videoId: String?)
9
10
  fun updateProductViewConfig(config: ReadableMap?, callbackId: Int?)
10
11
  fun updateAddToCartStatus(res: String?, tip: String?, callbackId: Int?)
11
12
  fun jumpToCartPage(callbackId: Int?)
@@ -1,12 +1,14 @@
1
- package com.reactnativefireworksdk.models
1
+ package com.fireworksdk.bridge.reactnative.models
2
2
 
3
+ import com.facebook.react.bridge.Promise
3
4
  import com.facebook.react.bridge.ReadableMap
4
5
 
5
6
  interface FireworkSDKInterface {
6
7
 
7
8
  fun init(userId: String?, adConfig: ReadableMap?)
8
9
  fun openVideoPlayer(url: String, config: ReadableMap?)
9
- fun setShareBaseURL(url: String?)
10
+ fun setShareBaseURL(url: String?, promise: Promise)
11
+ fun setAdBadgeConfiguration(config: ReadableMap?, promise: Promise)
10
12
  fun setCustomCTAClickEnabled(value: Boolean?)
11
13
  fun setVideoPlaybackEventEnabled(value: Boolean?)
12
14
  }
@@ -0,0 +1,88 @@
1
+ package com.fireworksdk.bridge.reactnative.module
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.fireworksdk.bridge.models.FWLiveStreamMessageDetailsModel
7
+ import com.fireworksdk.bridge.models.FWLiveStreamEventDetailsModel
8
+ import com.fireworksdk.bridge.models.FWLiveStreamEventName
9
+ import com.fireworksdk.bridge.reactnative.models.FWLiveStreamInterface
10
+ import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
11
+ import com.fireworksdk.bridge.utils.FWLogUtils
12
+ import com.loopnow.fireworklibrary.FireworkLiveStream
13
+ import com.loopnow.fireworklibrary.FireworkLiveStreamChatDetails
14
+ import com.loopnow.fireworklibrary.FireworkLiveStreamEventDetails
15
+ import com.loopnow.fireworklibrary.FireworkLiveStreamEventListener
16
+
17
+
18
+ class FWLiveStreamModule(
19
+ reactContext: ReactApplicationContext
20
+ ) : ReactContextBaseJavaModule(reactContext), FWLiveStreamInterface {
21
+
22
+ @ReactMethod
23
+ override fun init() {
24
+ addFireworkLiveStreamEventListener()
25
+ }
26
+
27
+ private fun addFireworkLiveStreamEventListener() {
28
+ FireworkLiveStream.addFireworkLiveStreamEventListener(object : FireworkLiveStreamEventListener {
29
+ override fun userJoined(liveStreamDetails: FireworkLiveStreamEventDetails) {
30
+ super.userJoined(liveStreamDetails)
31
+ FWLogUtils.d { "userJoined: $liveStreamDetails" }
32
+ FWEventUtils.sendLiveStreamEvent(
33
+ reactApplicationContext,
34
+ FWLiveStreamEventName.UserJoin.rawValue,
35
+ FWLiveStreamEventDetailsModel(liveStreamDetails.id)
36
+ )
37
+ }
38
+
39
+ override fun userLeft(liveStreamDetails: FireworkLiveStreamEventDetails) {
40
+ super.userLeft(liveStreamDetails)
41
+ FWLogUtils.d { "userLeft: $liveStreamDetails" }
42
+ FWEventUtils.sendLiveStreamEvent(
43
+ reactApplicationContext,
44
+ FWLiveStreamEventName.UserLeave.rawValue,
45
+ FWLiveStreamEventDetailsModel(liveStreamDetails.id)
46
+ )
47
+ }
48
+
49
+ override fun userSentChat(chatDetails: FireworkLiveStreamChatDetails) {
50
+ super.userSentChat(chatDetails)
51
+ FWLogUtils.d { "userSentChat: $chatDetails" }
52
+ FWEventUtils.sendLiveStreamChatEvent(
53
+ reactApplicationContext,
54
+ FWLiveStreamEventName.UserSendChat.rawValue,
55
+ FWLiveStreamMessageDetailsModel(chatDetails.chatId, chatDetails.username, chatDetails.text),
56
+ FWLiveStreamEventDetailsModel(chatDetails.liveStreamDetails.id)
57
+ )
58
+ }
59
+
60
+ override fun userSentLike(liveStreamDetails: FireworkLiveStreamEventDetails) {
61
+ super.userSentLike(liveStreamDetails)
62
+ FWLogUtils.d { "userSentLike: $liveStreamDetails" }
63
+ FWEventUtils.sendLiveStreamEvent(
64
+ reactApplicationContext,
65
+ FWLiveStreamEventName.UserSendLike.rawValue,
66
+ FWLiveStreamEventDetailsModel(liveStreamDetails.id)
67
+ )
68
+ }
69
+ })
70
+ }
71
+
72
+ @ReactMethod
73
+ fun addListener(eventName: String?) {
74
+ // Set up any upstream listeners or background tasks as necessary
75
+ FWLogUtils.d { "addListener: $eventName" }
76
+ }
77
+
78
+ @ReactMethod
79
+ fun removeListeners(count: Int?) {
80
+ // Remove upstream listeners, stop unnecessary background tasks
81
+ FWLogUtils.d { "removeListeners: $count" }
82
+ }
83
+
84
+ override fun getName(): String {
85
+ return "LiveStreamModule"
86
+ }
87
+
88
+ }
@@ -1,16 +1,19 @@
1
- package com.reactnativefireworksdk.module
1
+ package com.fireworksdk.bridge.reactnative.module
2
2
 
3
3
  import android.app.Activity
4
4
  import com.facebook.react.bridge.*
5
+ import com.fasterxml.jackson.core.type.TypeReference
5
6
  import com.loopnow.fireworklibrary.baya.Baya
6
7
  import com.loopnow.fireworklibrary.baya.UpdateCartStatus
7
- import com.loopnow.fireworklibrary.models.Product
8
- import com.reactnativefireworksdk.models.FWVideoShoppingInterface
9
- import com.reactnativefireworksdk.models.FWVideoShoppingProduct
10
- import com.reactnativefireworksdk.pages.FWVideoShoppingCartActivity
11
- import com.reactnativefireworksdk.utils.FWEventUtils
12
- import com.reactnativefireworksdk.utils.FWJsonUtils
13
- import com.reactnativefireworksdk.utils.FWLogUtils
8
+ import com.fireworksdk.bridge.reactnative.models.FWVideoShoppingInterface
9
+ import com.fireworksdk.bridge.models.FWVideoShoppingProduct
10
+ import com.fireworksdk.bridge.reactnative.pages.FWVideoShoppingCartActivity
11
+ import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
12
+ import com.fireworksdk.bridge.utils.FWJsonUtils
13
+ import com.fireworksdk.bridge.utils.FWLogUtils
14
+ import com.loopnow.fireworklibrary.data.Product
15
+ import com.loopnow.fireworklibrary.utils.Util
16
+
14
17
 
15
18
  class FWVideoShoppingModule(
16
19
  reactContext: ReactApplicationContext
@@ -18,7 +21,7 @@ class FWVideoShoppingModule(
18
21
 
19
22
  private var addToCartHandler: Triple<Int, String, String>? = null
20
23
  private var cartClickHandler: Pair<Int, Activity>? = null
21
- private val updateProductHandler: HashMap<String, Product> = HashMap()
24
+ private val updateProductHandler: HashMap<String, List<Product>> = HashMap()
22
25
 
23
26
  @ReactMethod
24
27
  override fun init() {
@@ -27,40 +30,52 @@ class FWVideoShoppingModule(
27
30
  }
28
31
 
29
32
  @ReactMethod
30
- override fun updateVideoProduct(productMap: ReadableMap?, callbackId: Int?) {
31
- FWLogUtils.d { "FWVideoShoppingModule updateVideoProduct: $callbackId, productMap: $productMap" }
32
- if (callbackId == null) {
33
+ override fun updateVideoProducts(productArray: ReadableArray?, videoId: String?) {
34
+ FWLogUtils.d { "FWVideoShoppingModule updateVideoProduct: $videoId" }
35
+ if (videoId.isNullOrBlank()) {
33
36
  return
34
37
  }
35
38
 
36
- val configMap = productMap?.toHashMap()
37
- val videoShoppingProduct = FWJsonUtils.fromMap(configMap, FWVideoShoppingProduct::class.java)
38
- ?: return
39
- val productId = videoShoppingProduct.productId
40
- if (productId.isNullOrBlank()) {
39
+ val configArrayList = productArray?.toArrayList()
40
+ val videoShoppingProducts = FWJsonUtils.fromJson(FWJsonUtils.toJson(configArrayList), object : TypeReference<List<FWVideoShoppingProduct>?>() {})
41
+ if (videoShoppingProducts.isNullOrEmpty()) {
41
42
  return
42
43
  }
43
44
 
44
- val product = updateProductHandler[productId] ?: return
45
+ val products = updateProductHandler[videoId] ?: return
45
46
 
46
- if (videoShoppingProduct.description != null) {
47
- product.description = videoShoppingProduct.description
48
- }
47
+ for (product in products) {
48
+ for (videoShoppingProduct in videoShoppingProducts) {
49
+ if (product.extId == videoShoppingProduct.productId) {
50
+
51
+ if (videoShoppingProduct.name != null) {
52
+ product.name = videoShoppingProduct.name
53
+ }
54
+
55
+ if (videoShoppingProduct.description != null) {
56
+ product.description = videoShoppingProduct.description
57
+ }
49
58
 
50
- if (videoShoppingProduct.units != null) {
51
- for (videoShoppingProductUnit in videoShoppingProduct.units) {
52
- for (productUnit in product.units) {
53
- if (videoShoppingProductUnit.unitId.equals(productUnit.externalId)) {
54
- productUnit.name = videoShoppingProductUnit.name
55
- productUnit.price?.amount = videoShoppingProductUnit.price?.amount
56
- productUnit.price?.currencyCode = videoShoppingProductUnit.price?.currencyCode
59
+ if (videoShoppingProduct.units != null) {
60
+ for (videoShoppingProductUnit in videoShoppingProduct.units) {
61
+ for (productUnit in product.productUnits) {
62
+ if (videoShoppingProductUnit.unitId.equals(productUnit.extId)) {
63
+ productUnit.name = videoShoppingProductUnit.name
64
+ productUnit.price = videoShoppingProductUnit.price?.amount
65
+ productUnit.currencyCode = videoShoppingProductUnit.price?.currencyCode
66
+ productUnit.priceLiteral = Util.getPriceLocaleFormatter(productUnit.price, productUnit.currencyCode)
67
+ }
68
+ }
69
+ }
57
70
  }
71
+
58
72
  }
59
73
  }
60
74
  }
61
-
62
- updateProductHandler.remove(productId)
63
-
75
+ UiThreadUtil.runOnUiThread {
76
+ Baya.updateProductsComplete(videoId)
77
+ }
78
+ updateProductHandler.remove(videoId)
64
79
  }
65
80
 
66
81
  @ReactMethod
@@ -110,9 +125,8 @@ class FWVideoShoppingModule(
110
125
 
111
126
  @ReactMethod
112
127
  override fun exitCartPage() {
113
- val activity = reactApplicationContext.currentActivity
114
128
  UiThreadUtil.runOnUiThread {
115
- activity?.finish()
129
+ currentActivity?.finish()
116
130
  }
117
131
  }
118
132
 
@@ -156,13 +170,13 @@ class FWVideoShoppingModule(
156
170
 
157
171
  private fun productListener() {
158
172
  Baya.productInterface = object: Baya.ProductInterface {
159
- override fun hydrateProduct(id: String, product: Product) {
160
- FWLogUtils.d { "FWVideoShoppingModule hydrateProduct, id: $id" }
161
- val callbackId = generateCallbackId()
162
- if (!id.isNullOrBlank()) {
163
- updateProductHandler[id] = product
164
- FWEventUtils.sendUpdateProductDetailsEvent(reactApplicationContext, id, callbackId)
173
+ override fun hydrateProducts(videoId: String, products: List<Product>) {
174
+ FWLogUtils.d { "FWVideoShoppingModule hydrateProducts, videoId: $videoId" }
175
+ if (videoId.isNullOrBlank() || products.isNullOrEmpty()) {
176
+ return
165
177
  }
178
+ updateProductHandler[videoId] = products
179
+ FWEventUtils.sendUpdateProductsDetailsEvent(reactApplicationContext, products, videoId)
166
180
  }
167
181
 
168
182
  override fun displayProductInfo(