diff --git a/android/build.gradle b/android/build.gradle index ade2dc9..606bee6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -138,7 +138,7 @@ dependencies { implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1' - implementation 'app.rive:rive-android:9.3.6' + implementation 'app.rive:rive-android:9.4.0' implementation "androidx.startup:startup-runtime:1.1.1" implementation 'com.android.volley:volley:1.2.0' } diff --git a/android/src/main/java/com/rivereactnative/RiveReactNativeView.kt b/android/src/main/java/com/rivereactnative/RiveReactNativeView.kt index 911f608..6f56dd9 100644 --- a/android/src/main/java/com/rivereactnative/RiveReactNativeView.kt +++ b/android/src/main/java/com/rivereactnative/RiveReactNativeView.kt @@ -495,6 +495,30 @@ class RiveReactNativeView(private val context: ThemedReactContext) : FrameLayout } } + fun fireStateAtPath(inputName: String, path: String) { + try { + riveAnimationView.fireStateAtPath(inputName, path) + } catch (ex: RiveException) { + handleRiveException(ex) + } + } + + fun setBooleanStateAtPath(inputName: String, value: Boolean, path: String) { + try { + riveAnimationView.setBooleanStateAtPath(inputName, value, path) + } catch (ex: RiveException) { + handleRiveException(ex) + } + } + + fun setNumberStateAtPath(inputName: String, value: Float, path: String) { + try { + riveAnimationView.setNumberStateAtPath(inputName, value, path) + } catch (ex: RiveException) { + handleRiveException(ex) + } + } + private fun handleRiveException(exception: RiveException) { if (isUserHandlingErrors) { val rnRiveError = RNRiveError.mapToRNRiveError(exception) diff --git a/android/src/main/java/com/rivereactnative/RiveReactNativeViewManager.kt b/android/src/main/java/com/rivereactnative/RiveReactNativeViewManager.kt index 30766c7..7df8989 100644 --- a/android/src/main/java/com/rivereactnative/RiveReactNativeViewManager.kt +++ b/android/src/main/java/com/rivereactnative/RiveReactNativeViewManager.kt @@ -70,6 +70,35 @@ class RiveReactNativeViewManager : SimpleViewManager() { } } } + "fireStateAtPath" -> { + args?.let { + val inputName = it.getString(0) + val path = it.getString(1) + view.run { + fireStateAtPath(inputName, path) + } + } + } + "setBooleanStateAtPath" -> { + args?.let { + val inputName = it.getString(0) + val value = it.getBoolean(1) + val path = it.getString(2) + view.run { + setBooleanStateAtPath(inputName, value, path) + } + } + } + "setNumberStateAtPath" -> { + args?.let { + val inputName = it.getString(0) + val value = it.getDouble(1) + val path = it.getString(2) + view.run { + setNumberStateAtPath(inputName, value.toFloat(), path) + } + } + } // Touch Events diff --git a/example/android/app/src/main/res/raw/runtime_nested_inputs.riv b/example/android/app/src/main/res/raw/runtime_nested_inputs.riv new file mode 100644 index 0000000..04c2395 Binary files /dev/null and b/example/android/app/src/main/res/raw/runtime_nested_inputs.riv differ diff --git a/example/ios/Assets/runtime_nested_inputs.riv b/example/ios/Assets/runtime_nested_inputs.riv new file mode 100644 index 0000000..04c2395 Binary files /dev/null and b/example/ios/Assets/runtime_nested_inputs.riv differ diff --git a/example/ios/RiveReactNativeExample.xcodeproj/project.pbxproj b/example/ios/RiveReactNativeExample.xcodeproj/project.pbxproj index bb4dae2..c8a5d19 100644 --- a/example/ios/RiveReactNativeExample.xcodeproj/project.pbxproj +++ b/example/ios/RiveReactNativeExample.xcodeproj/project.pbxproj @@ -32,6 +32,8 @@ E5A17A90299AA0F5008CC433 /* avatars.riv in Resources */ = {isa = PBXBuildFile; fileRef = E5A17A8F299AA0F5008CC433 /* avatars.riv */; }; E5F3FC4029B2661500D6D265 /* switch.riv in Resources */ = {isa = PBXBuildFile; fileRef = E5F3FC3F29B2661500D6D265 /* switch.riv */; }; E5FC4EAA2ABB975100D98158 /* rating.riv in Resources */ = {isa = PBXBuildFile; fileRef = E5FC4EA92ABB975100D98158 /* rating.riv */; }; + F8AA4CA42C0F3FDB00C1A5FF /* runtime_nested_inputs.riv in Resources */ = {isa = PBXBuildFile; fileRef = F8AA4CA32C0F3FDB00C1A5FF /* runtime_nested_inputs.riv */; }; + F8AA4CA52C0F3FDB00C1A5FF /* runtime_nested_inputs.riv in Resources */ = {isa = PBXBuildFile; fileRef = F8AA4CA32C0F3FDB00C1A5FF /* runtime_nested_inputs.riv */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -101,6 +103,7 @@ E5FC4EA92ABB975100D98158 /* rating.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = rating.riv; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; + F8AA4CA32C0F3FDB00C1A5FF /* runtime_nested_inputs.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = runtime_nested_inputs.riv; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -255,6 +258,7 @@ E5F3FC3F29B2661500D6D265 /* switch.riv */, 9D879D0C265BF2A400D01424 /* ui_swipe_left_to_delete.riv */, E5FC4EA92ABB975100D98158 /* rating.riv */, + F8AA4CA32C0F3FDB00C1A5FF /* runtime_nested_inputs.riv */, E5A17A8F299AA0F5008CC433 /* avatars.riv */, E59C190F2B07F6FE002F0CBA /* nested_menu.riv */, E5637D79292BD26D000CBC1E /* skills_listener.riv */, @@ -398,6 +402,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + F8AA4CA52C0F3FDB00C1A5FF /* runtime_nested_inputs.riv in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -409,6 +414,7 @@ E5FC4EAA2ABB975100D98158 /* rating.riv in Resources */, 042FD22726B81BD1004556A3 /* constrained.riv in Resources */, 9D879D0B26578A5E00D01424 /* artboard_animations.riv in Resources */, + F8AA4CA42C0F3FDB00C1A5FF /* runtime_nested_inputs.riv in Resources */, E5637D7A292BD27F000CBC1E /* skills_listener.riv in Resources */, 04A886F326A990050078530A /* two_bone_ik.riv in Resources */, 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, diff --git a/example/src/NestedInputs.tsx b/example/src/NestedInputs.tsx index 7bf4af0..d734c31 100644 --- a/example/src/NestedInputs.tsx +++ b/example/src/NestedInputs.tsx @@ -1,19 +1,60 @@ import * as React from 'react'; -import { SafeAreaView, ScrollView, StyleSheet } from 'react-native'; -import Rive, { Alignment, Fit } from 'rive-react-native'; +import { Button, SafeAreaView, ScrollView, StyleSheet } from 'react-native'; +import Rive, { Alignment, RiveRef } from 'rive-react-native'; export default function NestedInputs() { + const riveRef = React.useRef(null); + return ( +