react-native-daro 1.0.7 → 1.0.8
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/android/build.gradle +4 -3
- package/android/src/main/java/com/darom/DaroMAdBannerViewManager.kt +31 -15
- package/android/src/main/java/com/darom/DaroMModule.kt +13 -4
- package/android/src/main/java/com/darom/view/DaroMAdBannerViewContainer.kt +31 -0
- package/ios/Daro+Extensions.swift +12 -0
- package/package.json +1 -1
- package/react-native-daro-m.podspec +1 -1
package/android/build.gradle
CHANGED
|
@@ -8,7 +8,7 @@ buildscript {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
dependencies {
|
|
11
|
-
classpath "com.android.tools.build:gradle:
|
|
11
|
+
classpath "com.android.tools.build:gradle:8.2.0"
|
|
12
12
|
// noinspection DifferentKotlinGradleVersion
|
|
13
13
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
14
|
}
|
|
@@ -85,6 +85,7 @@ android {
|
|
|
85
85
|
repositories {
|
|
86
86
|
mavenCentral()
|
|
87
87
|
google()
|
|
88
|
+
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
@@ -93,7 +94,7 @@ dependencies {
|
|
|
93
94
|
// For < 0.71, this will be from the local maven repo
|
|
94
95
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
95
96
|
//noinspection GradleDynamicVersion
|
|
96
|
-
implementation "com.facebook.react:react-
|
|
97
|
+
implementation "com.facebook.react:react-android:+"
|
|
97
98
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
98
|
-
implementation "so.daro:daro-core:1.3.
|
|
99
|
+
implementation "so.daro:daro-core:1.3.8"
|
|
99
100
|
}
|
|
@@ -31,25 +31,30 @@ class DaroMAdBannerViewManager : SimpleViewManager<DaroMAdBannerViewContainer>()
|
|
|
31
31
|
val placement = initialProps?.getString("placement")
|
|
32
32
|
val adUnitId = initialProps?.getString("adUnitId")
|
|
33
33
|
|
|
34
|
-
val
|
|
34
|
+
val cacheKey = when {
|
|
35
|
+
adUnitId.isNullOrBlank() || placement.isNullOrBlank() -> ""
|
|
36
|
+
else -> "{$adUnitId}_${placement}${reactContext.hashCode()}"
|
|
37
|
+
}
|
|
35
38
|
|
|
36
|
-
if (
|
|
37
|
-
viewCache.keys
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
39
|
+
if (cacheKey.isNotBlank()) {
|
|
40
|
+
viewCache.keys
|
|
41
|
+
.filter { it.contains(cacheKey) && it != cacheKey }
|
|
42
|
+
.forEach { viewCache.remove(it)?.destroy() }
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
return
|
|
45
|
-
viewCache[
|
|
46
|
-
|
|
45
|
+
return cacheKey.let {
|
|
46
|
+
viewCache[cacheKey].let { cachedView ->
|
|
47
|
+
cachedView?.id = reactTag
|
|
47
48
|
|
|
48
|
-
if(
|
|
49
|
-
|
|
49
|
+
if(cachedView?.parent == null) {
|
|
50
|
+
cachedView?.resumeAd()
|
|
51
|
+
cachedView
|
|
52
|
+
} else {
|
|
53
|
+
null
|
|
54
|
+
}
|
|
50
55
|
}
|
|
51
56
|
} ?: super.createViewInstance(reactTag, reactContext, initialProps, stateWrapper).also { view ->
|
|
52
|
-
if (
|
|
57
|
+
if (cacheKey.isNotBlank()) viewCache[cacheKey] = view
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
|
|
@@ -72,7 +77,13 @@ class DaroMAdBannerViewManager : SimpleViewManager<DaroMAdBannerViewContainer>()
|
|
|
72
77
|
|
|
73
78
|
override fun onDropViewInstance(view: DaroMAdBannerViewContainer) {
|
|
74
79
|
super.onDropViewInstance(view)
|
|
75
|
-
|
|
80
|
+
|
|
81
|
+
val isCached = viewCache.values.contains(view)
|
|
82
|
+
if (isCached) {
|
|
83
|
+
view.pauseAd()
|
|
84
|
+
} else {
|
|
85
|
+
view.destroy()
|
|
86
|
+
}
|
|
76
87
|
}
|
|
77
88
|
|
|
78
89
|
@Deprecated("")
|
|
@@ -88,6 +99,11 @@ class DaroMAdBannerViewManager : SimpleViewManager<DaroMAdBannerViewContainer>()
|
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
|
|
102
|
+
@ReactProp(name = "isVisible")
|
|
103
|
+
fun setIsVisible(view: DaroMAdBannerViewContainer, isVisible: Boolean) {
|
|
104
|
+
view.setAdVisibility(isVisible)
|
|
105
|
+
}
|
|
106
|
+
|
|
91
107
|
@ReactProp(name = "adUnitId")
|
|
92
108
|
fun setAdUnitId(view: DaroMAdBannerViewContainer, adUnitId: String) {
|
|
93
109
|
view.adUnitId = adUnitId
|
|
@@ -107,10 +123,10 @@ class DaroMAdBannerViewManager : SimpleViewManager<DaroMAdBannerViewContainer>()
|
|
|
107
123
|
fun setPlacement(view: DaroMAdBannerViewContainer, placement: String) {
|
|
108
124
|
}
|
|
109
125
|
|
|
126
|
+
@OptIn(ExperimentalStdlibApi::class)
|
|
110
127
|
override fun getExportedCustomBubblingEventTypeConstants(): MutableMap<String, Any> {
|
|
111
128
|
return AdViewEvent.entries.associate {
|
|
112
129
|
it.value to mutableMapOf("phasedRegistrationNames" to mutableMapOf("bubbled" to it.key))
|
|
113
130
|
}.toMutableMap()
|
|
114
131
|
}
|
|
115
132
|
}
|
|
116
|
-
|
|
@@ -20,6 +20,7 @@ import com.facebook.react.bridge.ReactMethod
|
|
|
20
20
|
import com.facebook.react.bridge.ReadableMap
|
|
21
21
|
import com.facebook.react.bridge.WritableMap
|
|
22
22
|
import droom.daro.Daro
|
|
23
|
+
import droom.daro.Daro.SDKConfig
|
|
23
24
|
|
|
24
25
|
class DaroMModule(reactContext: ReactApplicationContext) :
|
|
25
26
|
ReactContextBaseJavaModule(reactContext) {
|
|
@@ -39,7 +40,10 @@ class DaroMModule(reactContext: ReactApplicationContext) :
|
|
|
39
40
|
@ReactMethod
|
|
40
41
|
fun initializeSdk() {
|
|
41
42
|
Daro.init(
|
|
42
|
-
application =
|
|
43
|
+
application = context.applicationContext as Application,
|
|
44
|
+
sdkConfig = SDKConfig.Builder()
|
|
45
|
+
.setDebugMode(false)
|
|
46
|
+
.build()
|
|
43
47
|
)
|
|
44
48
|
|
|
45
49
|
isInitialized = true
|
|
@@ -82,6 +86,7 @@ class DaroMModule(reactContext: ReactApplicationContext) :
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
|
|
89
|
+
@OptIn(ExperimentalStdlibApi::class)
|
|
85
90
|
internal abstract class DaroMInterstitialModule(context: ReactContext) :
|
|
86
91
|
DaroMComponentModule(context) {
|
|
87
92
|
abstract fun isInterstitialReady(adUnitId: String, promise: Promise)
|
|
@@ -96,7 +101,7 @@ class DaroMModule(reactContext: ReactApplicationContext) :
|
|
|
96
101
|
private val daroMInterstitialModule: DaroMInterstitialModule =
|
|
97
102
|
DaroMInterstitialModuleImpl(
|
|
98
103
|
context = reactContext,
|
|
99
|
-
getCurrentActivity = {
|
|
104
|
+
getCurrentActivity = { getCurrentActivity() }
|
|
100
105
|
)
|
|
101
106
|
|
|
102
107
|
@ReactMethod
|
|
@@ -114,6 +119,7 @@ class DaroMModule(reactContext: ReactApplicationContext) :
|
|
|
114
119
|
daroMInterstitialModule.showInterstitial(adUnitId)
|
|
115
120
|
}
|
|
116
121
|
|
|
122
|
+
@OptIn(ExperimentalStdlibApi::class)
|
|
117
123
|
internal abstract class DaroMRewardedModule(context: ReactContext) :
|
|
118
124
|
DaroMComponentModule(context) {
|
|
119
125
|
abstract fun isRewardedAdReady(adUnitId: String, promise: Promise)
|
|
@@ -128,7 +134,7 @@ class DaroMModule(reactContext: ReactApplicationContext) :
|
|
|
128
134
|
private val daroMRewardedModule: DaroMRewardedModule =
|
|
129
135
|
DaroMRewardedAdModuleImpl(
|
|
130
136
|
context = reactContext,
|
|
131
|
-
getCurrentActivity = {
|
|
137
|
+
getCurrentActivity = { getCurrentActivity() }
|
|
132
138
|
)
|
|
133
139
|
|
|
134
140
|
@ReactMethod
|
|
@@ -146,6 +152,7 @@ class DaroMModule(reactContext: ReactApplicationContext) :
|
|
|
146
152
|
daroMRewardedModule.showRewardedAd(adUnitId, customData)
|
|
147
153
|
}
|
|
148
154
|
|
|
155
|
+
@OptIn(ExperimentalStdlibApi::class)
|
|
149
156
|
internal abstract class DaroMLightPopupModule(context: ReactContext) :
|
|
150
157
|
DaroMComponentModule(context) {
|
|
151
158
|
abstract fun isLightPopupReady(adUnitId: String, promise: Promise)
|
|
@@ -158,9 +165,10 @@ class DaroMModule(reactContext: ReactApplicationContext) :
|
|
|
158
165
|
return LightPopupEvent.entries.associate { it.value to it.value }.toMutableMap()
|
|
159
166
|
}
|
|
160
167
|
}
|
|
168
|
+
|
|
161
169
|
private val daroMLightPopupModule: DaroMLightPopupModule = DaroMLightPopupModuleImpl(
|
|
162
170
|
context = reactContext,
|
|
163
|
-
getCurrentActivity = {
|
|
171
|
+
getCurrentActivity = { getCurrentActivity() }
|
|
164
172
|
)
|
|
165
173
|
|
|
166
174
|
@ReactMethod
|
|
@@ -183,6 +191,7 @@ class DaroMModule(reactContext: ReactApplicationContext) :
|
|
|
183
191
|
daroMLightPopupModule.setLightPopupAdConfiguration(adUnitId, configurationMap)
|
|
184
192
|
}
|
|
185
193
|
|
|
194
|
+
@OptIn(ExperimentalStdlibApi::class)
|
|
186
195
|
internal abstract class DaroMBannerModule(context: ReactContext) : DaroMComponentModule(context) {
|
|
187
196
|
override fun getComponents(): MutableMap<String, Any> {
|
|
188
197
|
return InternalDaroMBannerSize.entries.associate { it.key to it.name }.toMutableMap()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
package com.darom.view
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
|
+
import android.view.View
|
|
4
5
|
import androidx.core.view.children
|
|
6
|
+
import androidx.core.view.isVisible
|
|
5
7
|
import com.darom.event.AdViewEvent
|
|
6
8
|
import com.darom.util.AdInfoUtil
|
|
7
9
|
import com.darom.util.EventEmitterUtil.sendNativeViewEvent
|
|
@@ -27,6 +29,9 @@ class DaroMAdBannerViewContainer(val context: ReactContext) : ReactViewGroup(con
|
|
|
27
29
|
|
|
28
30
|
internal var loadOnMount: Boolean = true
|
|
29
31
|
|
|
32
|
+
private var isVisible: Boolean = true
|
|
33
|
+
private var isAdPaused: Boolean = false
|
|
34
|
+
|
|
30
35
|
fun loadAd() {
|
|
31
36
|
(adView ?: buildAdView())?.apply {
|
|
32
37
|
adView = this
|
|
@@ -60,6 +65,32 @@ class DaroMAdBannerViewContainer(val context: ReactContext) : ReactViewGroup(con
|
|
|
60
65
|
adView?.destroy()
|
|
61
66
|
}
|
|
62
67
|
|
|
68
|
+
fun setAdVisibility(visible: Boolean) {
|
|
69
|
+
isVisible = visible
|
|
70
|
+
this.isVisible = visible
|
|
71
|
+
adView?.isVisible = visible
|
|
72
|
+
|
|
73
|
+
if (visible) {
|
|
74
|
+
resumeAd()
|
|
75
|
+
} else {
|
|
76
|
+
pauseAd()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fun pauseAd() {
|
|
81
|
+
if (!isAdPaused) {
|
|
82
|
+
isAdPaused = true
|
|
83
|
+
adView?.pause()
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fun resumeAd() {
|
|
88
|
+
if (isAdPaused) {
|
|
89
|
+
isAdPaused = false
|
|
90
|
+
adView?.resume()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
63
94
|
override fun onAdClicked(adInfo: DaroAdInfo) {
|
|
64
95
|
sendNativeViewEvent(
|
|
65
96
|
reactContext = context,
|
|
@@ -143,6 +143,18 @@ extension UIButton {
|
|
|
143
143
|
if let colorHex = style["color"] as? String {
|
|
144
144
|
setTitleColor(UIColor(hex: colorHex), for: .normal)
|
|
145
145
|
}
|
|
146
|
+
if let textAlign = style["textAlign"] as? String {
|
|
147
|
+
switch textAlign {
|
|
148
|
+
case "center":
|
|
149
|
+
self.contentHorizontalAlignment = .center
|
|
150
|
+
case "right":
|
|
151
|
+
self.contentHorizontalAlignment = .right
|
|
152
|
+
case "left":
|
|
153
|
+
self.contentHorizontalAlignment = .left
|
|
154
|
+
default:
|
|
155
|
+
self.contentHorizontalAlignment = .center
|
|
156
|
+
}
|
|
157
|
+
}
|
|
146
158
|
}
|
|
147
159
|
}
|
|
148
160
|
|
package/package.json
CHANGED
|
@@ -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.1.
|
|
19
|
+
s.dependency "DaroAds", "1.1.45"
|
|
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.
|