react-native-daro 1.0.4 → 1.0.6

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.
@@ -95,5 +95,5 @@ dependencies {
95
95
  //noinspection GradleDynamicVersion
96
96
  implementation "com.facebook.react:react-native:+"
97
97
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
98
- implementation "so.daro:daro-core:1.2.17"
98
+ implementation "so.daro:daro-core:1.3.2"
99
99
  }
@@ -76,7 +76,10 @@ class DaroMAdNativeViewContainer(val context: ReactContext) : ReactViewGroup(con
76
76
  DaroNativeAdUnit(
77
77
  key = adUnitId,
78
78
  placement = adUnitId,
79
- adBinder = DaroNativeAdBinder
79
+ )
80
+ ).also { view ->
81
+ view.setAdBinder(
82
+ DaroNativeAdBinder
80
83
  .Builder(adViewContainer)
81
84
  .let { if (titleViewId != null) it.setTitleViewId(titleViewId!!) else it }
82
85
  .let { if (bodyViewId != null) it.setBodyTextViewId(bodyViewId!!) else it }
@@ -85,7 +88,7 @@ class DaroMAdNativeViewContainer(val context: ReactContext) : ReactViewGroup(con
85
88
  .let { if (callToActionViewId != null) it.setCallToActionViewId(callToActionViewId!!) else it }
86
89
  .build()
87
90
  )
88
- ).also { view ->
91
+
89
92
  view.setListener(this)
90
93
  view.setOnHierarchyChangeListener(
91
94
  object : OnHierarchyChangeListener {
@@ -38,11 +38,12 @@ extension DaroMModule {
38
38
  reject("LIGHTPOPUP_NOT_LOADED", "LightPopup ad not loaded", nil)
39
39
  return
40
40
  }
41
- DispatchQueue.main.async {
41
+ executeOnMainThread { [weak self] in
42
42
  guard let viewController = UIApplication.shared.windows.first?.rootViewController else {
43
43
  reject("VIEW_CONTROLLER_NOT_FOUND", "Root view controller not found", nil)
44
44
  return
45
45
  }
46
+ self?.applyStoredConfiguration(to: loadedAd, for: adUnitId)
46
47
  loadedAd.show(viewController: viewController)
47
48
  resolve(Void())
48
49
  }
@@ -60,32 +61,38 @@ extension DaroMModule {
60
61
  resolve(Void())
61
62
  return
62
63
  }
63
- executeOnMainThread {
64
- let lightPopupConfig = DaroLightPopupConfiguration()
64
+ executeOnMainThread { [weak self] in
65
+ self?.applyStoredConfiguration(to: loadedAd, for: adUnitId)
66
+ }
67
+ resolve(Void())
68
+ }
65
69
 
66
- func setColorIfValid(_ key: String, setter: (UIColor) -> Void) {
67
- if let colorString = configuration[key] as? String {
68
- setter(UIColor(hex: colorString))
69
- }
70
- }
70
+ func applyStoredConfiguration(to ad: DaroLightPopupAd, for unitId: String) {
71
+ if let configuration = lightPopupConfigurations[unitId] {
72
+ let lightPopupConfig = DaroLightPopupConfiguration()
71
73
 
72
- setColorIfValid("backgroundColor") { lightPopupConfig.backgroundColor = $0 }
73
- setColorIfValid("cardViewBackgroundColor") { lightPopupConfig.cardViewBackgroundColor = $0 }
74
- setColorIfValid("adMarkLabelTextColor") { lightPopupConfig.adMarkLabelTextColor = $0 }
75
- setColorIfValid("adMarkLabelBackgroundColor") { lightPopupConfig.adMarkLabelBackgroundColor = $0 }
76
- setColorIfValid("closeButtonTextColor") { lightPopupConfig.closeButtonTextColor = $0 }
77
- setColorIfValid("titleTextColor") { lightPopupConfig.titleTextColor = $0 }
78
- setColorIfValid("bodyTextColor") { lightPopupConfig.bodyTextColor = $0 }
79
- setColorIfValid("ctaButtonTextColor") { lightPopupConfig.ctaButtonTextColor = $0 }
80
- setColorIfValid("ctaButtonBackgroundColor") { lightPopupConfig.ctaButtonBackgroundColor = $0 }
81
-
82
- if let closeButtonText = configuration["closeButtonText"] as? String {
83
- lightPopupConfig.closeButtonText = closeButtonText
84
- }
74
+ func setColorIfValid(_ key: String, setter: (UIColor) -> Void) {
75
+ if let colorString = configuration[key] as? String {
76
+ setter(UIColor(hex: colorString))
77
+ }
78
+ }
85
79
 
86
- loadedAd.configuration = lightPopupConfig
87
- }
88
- resolve(Void())
80
+ setColorIfValid("backgroundColor") { lightPopupConfig.backgroundColor = $0 }
81
+ setColorIfValid("cardViewBackgroundColor") { lightPopupConfig.cardViewBackgroundColor = $0 }
82
+ setColorIfValid("adMarkLabelTextColor") { lightPopupConfig.adMarkLabelTextColor = $0 }
83
+ setColorIfValid("adMarkLabelBackgroundColor") { lightPopupConfig.adMarkLabelBackgroundColor = $0 }
84
+ setColorIfValid("closeButtonTextColor") { lightPopupConfig.closeButtonTextColor = $0 }
85
+ setColorIfValid("titleTextColor") { lightPopupConfig.titleTextColor = $0 }
86
+ setColorIfValid("bodyTextColor") { lightPopupConfig.bodyTextColor = $0 }
87
+ setColorIfValid("ctaButtonTextColor") { lightPopupConfig.ctaButtonTextColor = $0 }
88
+ setColorIfValid("ctaButtonBackgroundColor") { lightPopupConfig.ctaButtonBackgroundColor = $0 }
89
+
90
+ if let closeButtonText = configuration["closeButtonText"] as? String {
91
+ lightPopupConfig.closeButtonText = closeButtonText
92
+ }
93
+
94
+ ad.configuration = lightPopupConfig
95
+ }
89
96
  }
90
97
 
91
98
  func retrieveLightPopupLoader(for unitId: String) -> DaroLightPopupAdLoader {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-daro",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Daro React Native Module for Android and iOS",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
- s.dependency "DaroAds", "1.0.30-beta"
19
+ s.dependency "DaroAds", "1.1.37"
20
20
 
21
21
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
22
22
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.