@rive-app/react-native 0.2.4 → 0.2.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.
@@ -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, config.autoPlay)
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, autoPlay: Boolean) {
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.4",
3
+ "version": "0.2.6",
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.13.0",
68
- "android": "11.1.0"
67
+ "ios": "6.15.2",
68
+ "android": "11.2.0"
69
69
  },
70
70
  "publishConfig": {
71
71
  "registry": "https://registry.npmjs.org/"
@@ -97,7 +97,7 @@
97
97
  "react": "19.0.0",
98
98
  "react-native": "0.79.2",
99
99
  "react-native-builder-bob": "^0.40.10",
100
- "react-native-nitro-modules": "0.33.2",
100
+ "react-native-nitro-modules": "0.34.1",
101
101
  "react-test-renderer": "19.0.0",
102
102
  "release-it": "^17.10.0",
103
103
  "turbo": "^1.10.7",
@@ -106,7 +106,7 @@
106
106
  "peerDependencies": {
107
107
  "react": "*",
108
108
  "react-native": "*",
109
- "react-native-nitro-modules": ">=0.33.2"
109
+ "react-native-nitro-modules": ">=0.33.2 <0.35.0"
110
110
  },
111
111
  "workspaces": [
112
112
  "example",