@rive-app/react-native 0.2.4 → 0.2.5
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.
|
@@ -10,6 +10,7 @@ import com.rive.ViewConfiguration
|
|
|
10
10
|
import app.rive.runtime.kotlin.core.Fit as RiveFit
|
|
11
11
|
import app.rive.runtime.kotlin.core.Alignment as RiveAlignment
|
|
12
12
|
import app.rive.runtime.kotlin.core.errors.*
|
|
13
|
+
import android.util.Log
|
|
13
14
|
import kotlinx.coroutines.Dispatchers
|
|
14
15
|
import kotlinx.coroutines.withContext
|
|
15
16
|
|
|
@@ -268,6 +269,7 @@ class HybridRiveView(val context: ThemedReactContext) : HybridRiveViewSpec() {
|
|
|
268
269
|
val (errorType, errorDescription) = detectErrorType(e)
|
|
269
270
|
val noteString = note?.let { " $it" } ?: ""
|
|
270
271
|
val errorMessage = "[RIVE] $tag$noteString $errorDescription"
|
|
272
|
+
Log.e(TAG, errorMessage, e)
|
|
271
273
|
val riveError = RiveError(
|
|
272
274
|
type = errorType,
|
|
273
275
|
message = errorMessage
|
|
@@ -77,7 +77,6 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
77
77
|
private var eventListeners: MutableList<RiveFileController.RiveEventListener> = mutableListOf()
|
|
78
78
|
private val viewReadyDeferred = CompletableDeferred<Boolean>()
|
|
79
79
|
private var _activeStateMachineName: String? = null
|
|
80
|
-
private var _pendingBindData: BindData? = null
|
|
81
80
|
private var willDispose = false
|
|
82
81
|
|
|
83
82
|
init {
|
|
@@ -104,11 +103,17 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
104
103
|
|
|
105
104
|
fun configure(config: ViewConfiguration, dataBindingChanged: Boolean, reload: Boolean = false, initialUpdate: Boolean = false) {
|
|
106
105
|
if (reload) {
|
|
106
|
+
val hasDataBinding = when (config.bindData) {
|
|
107
|
+
is BindData.None -> false
|
|
108
|
+
is BindData.Auto -> config.riveFile.viewModelCount > 0
|
|
109
|
+
is BindData.Instance, is BindData.ByName -> true
|
|
110
|
+
}
|
|
107
111
|
riveAnimationView?.setRiveFile(
|
|
108
112
|
config.riveFile,
|
|
109
113
|
artboardName = config.artboardName,
|
|
110
114
|
stateMachineName = config.stateMachineName,
|
|
111
115
|
autoplay = config.autoPlay,
|
|
116
|
+
autoBind = hasDataBinding,
|
|
112
117
|
alignment = config.alignment,
|
|
113
118
|
fit = config.fit
|
|
114
119
|
)
|
|
@@ -121,7 +126,7 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
121
126
|
}
|
|
122
127
|
|
|
123
128
|
if (dataBindingChanged || initialUpdate || reload) {
|
|
124
|
-
applyDataBinding(config.bindData
|
|
129
|
+
applyDataBinding(config.bindData)
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
viewReadyDeferred.complete(true)
|
|
@@ -143,20 +148,8 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
|
|
146
|
-
fun applyDataBinding(bindData: BindData
|
|
147
|
-
val stateMachines = riveAnimationView?.controller?.stateMachines
|
|
148
|
-
if (stateMachines.isNullOrEmpty()) {
|
|
149
|
-
_pendingBindData = bindData
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
|
|
151
|
+
fun applyDataBinding(bindData: BindData) {
|
|
153
152
|
bindToStateMachine(bindData)
|
|
154
|
-
|
|
155
|
-
if (autoPlay) {
|
|
156
|
-
stateMachines.first().name.let { smName ->
|
|
157
|
-
riveAnimationView?.play(smName, isStateMachine = true)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
153
|
}
|
|
161
154
|
|
|
162
155
|
fun play() {
|
|
@@ -164,14 +157,6 @@ class RiveReactNativeView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
164
157
|
_activeStateMachineName = getSafeStateMachineName()
|
|
165
158
|
}
|
|
166
159
|
riveAnimationView?.play()
|
|
167
|
-
applyPendingBindData()
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private fun applyPendingBindData() {
|
|
171
|
-
_pendingBindData?.let { bindData ->
|
|
172
|
-
_pendingBindData = null
|
|
173
|
-
bindToStateMachine(bindData)
|
|
174
|
-
}
|
|
175
160
|
}
|
|
176
161
|
|
|
177
162
|
fun pause() = riveAnimationView?.pause()
|
|
@@ -166,6 +166,7 @@ class RiveReactNativeView: UIView, RiveStateMachineDelegate {
|
|
|
166
166
|
try handleInput(name: name, path: path, type: .number) { (input: RiveRuntime.RiveSMINumber) in
|
|
167
167
|
input.setValue(value)
|
|
168
168
|
}
|
|
169
|
+
playIfNeeded()
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
func getNumberInputValue(name: String, path: String?) throws -> Float {
|
|
@@ -178,6 +179,7 @@ class RiveReactNativeView: UIView, RiveStateMachineDelegate {
|
|
|
178
179
|
try handleInput(name: name, path: path, type: .boolean) { (input: RiveRuntime.RiveSMIBool) in
|
|
179
180
|
input.setValue(value)
|
|
180
181
|
}
|
|
182
|
+
playIfNeeded()
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
func getBooleanInputValue(name: String, path: String?) throws -> Bool {
|
|
@@ -190,6 +192,7 @@ class RiveReactNativeView: UIView, RiveStateMachineDelegate {
|
|
|
190
192
|
try handleInput(name: name, path: path, type: .trigger) { (input: RiveRuntime.RiveSMITrigger) in
|
|
191
193
|
input.fire()
|
|
192
194
|
}
|
|
195
|
+
playIfNeeded()
|
|
193
196
|
}
|
|
194
197
|
|
|
195
198
|
func setTextRunValue(name: String, value: String, path: String?) throws {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rive-app/react-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Rive React Native",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
},
|
|
65
65
|
"homepage": "https://github.com/rive-app/rive-nitro-react-native#readme",
|
|
66
66
|
"runtimeVersions": {
|
|
67
|
-
"ios": "6.
|
|
68
|
-
"android": "11.
|
|
67
|
+
"ios": "6.15.2",
|
|
68
|
+
"android": "11.2.0"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"registry": "https://registry.npmjs.org/"
|