arkivanov / Decompose

Kotlin Multiplatform lifecycle-aware business logic components (aka BLoCs) with routing (navigation) and pluggable UI (Jetpack Compose, SwiftUI, JS React, etc.)
https://arkivanov.github.io/Decompose
Apache License 2.0
2.16k stars 84 forks source link

Live Edit or @Preview Not working. Are they possible? #591

Closed adrianegraphene closed 8 months ago

adrianegraphene commented 8 months ago

Goals To work in decompose, while being able to see Android UI Changes in Live Edit, or @Preview.

Using Decompose 2.1.0-compose-experimental Android Studio 2023.1.1 Patch 1

Targets Android, iOS,

Before I take the simplest answer and assume that both "Live Edit" and "@Preview" do not work in Android emulators that are running from a Decompose codebase... I figured I'd ask here + share what I've tried.

Live Edit does not work in Kotlin files in commonMain, but. Nor does Preview. Is this expected?

My observations

Live Edit Works in androidMain, but does not work in commonMain, where most Kotlin files are.

Happy to share my files here, but they're kind of verbose. Figured I'd just ask first, if anyone's gotten Live Edit working in any version of Decompose.

arkivanov commented 8 months ago

I believe this issue is unrelated to Decompose. I'm pretty sure live previews (an actually just normal previews) are officially not supported in commonMain. I think this feature is being tracked here: https://github.com/JetBrains/compose-multiplatform/issues/2045.

adrianegraphene commented 8 months ago

that is correct, just wanted to see if anyone had gotten it working . That link you provided is perfect. I'll follow that and close this. Thank you!

arkivanov commented 8 months ago

It is possible to have normal (not live) previews in commonMain if you have the jvm (Compose for Desktop) target enabled. You need to define expect class Preview, then you can write your previews as usual. Keep in mind that you need Compose Multiplatform IDE Support plugin installed.

adrianegraphene commented 8 months ago

That was my understanding too, from reading that previous. But I'm very happy to see the advice you've provided here too, as well as the link to the plugin (which I did not have). I will follow that and things should be OK with preview. Thank you so much!