rive-app / rive-android

A runtime for interactive animations on Android
https://rive.app
MIT License
333 stars 30 forks source link

Declarative UI #259

Open Huckleberry322 opened 2 years ago

Huckleberry322 commented 2 years ago

Rive already has support SwiftUI for IOS. But what about Android Compose UI? In my current project i wrap it in AndroidView Composable. Any future ideas for Compose UI?

zplata commented 2 years ago

Hey @Huckleberry322 - Jetpack Compose is definitely something we want to explore next with the Rive Android runtime! We can update this issue when we have some kind of support for this

imougy commented 1 year ago

Thank you, please put this a priority. We recently started developing for Android just because of Compose, pre-Compose, life is messy and inoperable.

riggaroo commented 1 year ago

Hey @zplata 👋🏻 I'm from the Developer Relations Team at Google focusing on Compose, Rive is a really cool technology. We'd love to help you get a Compose friendly version of Rive SDK out, let us know if you need any reviews or have any questions on Compose that we could help answer for you.

imougy commented 1 year ago

@riggaroo one more reason to develop for Android (Compose is another)! Thanks you!

akardas16 commented 1 year ago

this may help you

Rive already has support SwiftUI for IOS. But what about Android Compose UI? In my current project i wrap it in AndroidView Composable. Any future ideas for Compose UI?

this may help you https://github.com/mjtalbot/rive_piggy

Tommyten commented 1 year ago

Compose UI support would be awesome to have. Ideally not only Jetpack Compose, but also Jetbrains Compose could be supported.

MysteryMS commented 1 year ago

Definitely looking forward on this. Any news?

rahmanrezaee commented 1 year ago

use androidview composable function

setContent {
            Bettary_appTheme(
                darkTheme = false
            ) {
                Column(
                    Modifier.fillMaxSize(),
                    Arrangement.Center,
                    Alignment.CenterHorizontally
                ) {
                    Text(text = "Select Address Activity")
                    AndroidView({
                        LayoutInflater.from(it)
                            .inflate(R.layout.charging_animation_layout, null)
                            .apply {
                                animationView = findViewById(R.id.charging_animation)
                                animationView.setRiveResource(
                                    R.raw.charging,
                                    autoplay = true
                                )

                            }
                    })

                }

            }
        }
MysteryMS commented 1 year ago

Well, yeah, that's a workaround, but it would be nicer to have built in support to compose like only calling a RiveAnimation() function for example with detailed configuration

dimsuz commented 1 year ago

Also the above example is a pretty simplistic one. What about reacting to compose state changes to influence the scene? Or reacting to clicks in the rive scene to influence Compose or vice versa? Of course all this can be done, but it's not idiomatic, requires this interop with the legacy View stuff, etc, etc.

Native integration would be much nicer to have, but it's good that AndroidView still can be used as a workaround.

FrancoisBlavoet commented 1 year ago

Any news here?

Hard to justify investing in Rive if it only supports the old view system. For fully compose apps, that's unfortunately a big step backward. We can always wrap view code, but a native compose implementation would give us idiomatic declarative APIs.

umberto-sonnino commented 1 year ago

Just a quick update: we added an example of a Compose component that wraps the current View in 4.3.2

This is a starting point and we're still looking to add a proper Jetpack Compose API in the upcoming versions!

iZakirSheikh commented 10 months ago

Please add the compose support asap on priority.

carlfindahl commented 10 months ago

We are considering to use Rive and need good Compose support to make that choice, so hopefully this will be coming soon 😁

wwalkingg commented 9 months ago

If using Compose's API, should directly support Compose Multiplatform. This can prepare for the future Compose iOS and also take the initiative. Moreover, the Compose API is cross-platform.

Veeksi commented 8 months ago

Any updates regarding this?

umberto-sonnino commented 8 months ago

Any updates regarding this?

We have an example Activity showing how to wrap our RiveAnimationView with Compose.

We plan on having a more comprehensive Compose solution but it has not been scheduled yet

MysteryMS commented 8 months ago

I believe Lottie for compose is a better alternative for now. They seem to have enhanced support using compose principles.

delrioe commented 6 months ago

Hey guys, I took the time to find a way to have Rive composables in my project and I made a post in Stack Overflow with the code. That is the best solution I could come up with.

Rive + Jetpack Compose

Hope it helps.

JurajBegovac commented 5 months ago

Hi, any updates regarding this? Also, is there a plan/roadmap to support it for compose multiplatform?

delrioe commented 3 months ago

I made a composable using AndroidView. It works pretty well for listening state Changes etc. I made sure there weren't any memory leaks in case you guys want to have callbacks. But please, please feel free to test it and let me know if that works for you. https://stackoverflow.com/questions/77668942/rive-jetpack-compose-android

jsparidaans commented 3 months ago

@umberto-sonnino it's been a while, any update on when compose might be supported?

distivi commented 1 month ago

@umberto-sonnino, our team is thinking of migrating from Lottie to Rive. Any updates/plans/roadmap on this topic?