How to show a TextField in Jetpack Compose when a Rive Data Binding input changes?
Hello everyone,
I'm building an Android app using Kotlin and Jetpack Compose, with a Rive animation as a core component. I'm having trouble getting my Compose UI to react to a change within the Rive animation.
My Goal:
When a user taps a hitbox inside my Rive animation, I want my app to display an OutlinedTextField and bring up the software keyboard.
My Setup & Workflow:
I am using Rive's Data Binding feature, also known as the ViewModel Instance (VMI), with the autoBind = true parameter on my RiveAnimationView.
When the user taps the hitbox, it correctly changes a boolean input in the VMI named isTab to true.
My Jetpack Compose code needs to detect that the isTab property has changed to true.
Once the change is detected, the UI should recompose to show the OutlinedTextField and the keyboard.
The Problem:
My Compose code is not detecting the change in the isTab property. The value changes correctly inside the Rive instance, but my Composable doesn't get notified and the UI never updates to show the text field.
My Question:
What is the correct way to observe a property change from a Rive ViewModel Instance and use it to update a Jetpack Compose state?
Any help or examples would be greatly appreciated. Thank you!