Do IDE previews work in a compose multiplatform se...
# compose-desktop
a
Do IDE previews work in a compose multiplatform setup? I’m not having much luck with previews defined in shared/…/androidMain, or even the top level android module itself. The preview pane split icon just doesn’t show. Not sure if it’s a bug or if I’m doing something wrong 🤷
d
Preview for Desktop for now works only in jvmMain source set
a
Any plans to add the
PreviewParameterProvider
API for desktop?
d
@alexey.tsvetkov What do you think about adding
PreviewParameterProvider
in the future?
a
it’s not a big deal without it, just a bit more code to write for different permutations of state 😅
Is there any plans to allow android previews to work in the androidMain source set?
s
There is any talk with Google folks to bring their code update to Compose Desktop? I don’t think our team would like to work without, it gives much faster feedback loop when building UIs. Would be awesome to have something similar in Desktop, it would even better because the desktop is lightweight comparing to running a Emulator
d
Android previews already work on androidMain inside AndroidStudio
a
ah right, seems I need to add
buildFeatures { compose = true }
for android to get the code/design pane split to appear
So with:
Copy code
val androidMain by getting {
    dependencies {
        api(compose.preview)
        ...
    }
}
It’s able to resolve all the android preview types (
Preview
annotation,
PreviewParameterProvider
etc). However Android Studio gives the following error when trying to render the preview:
Copy code
The following classes could not be found:
- androidx.compose.ui.tooling.ComposeViewAdapter
This is a problem I’ve seen long ago with Jetpack Compose, and the solution was to add this:
Copy code
debugImplementation("androidx.customview:customview-poolingcontainer:1.0.0")
But it doesn’t resolve the issue, I think it’s obsolete (for Jetpack Compose anyway). The only thing that did resolve it was to add this, which seems very very wrong 😅:
Copy code
debugImplementation(platform("androidx.compose:compose-bom:2023.04.01"))
debugImplementation("androidx.compose.ui:ui-tooling")
the solution was simply:
Copy code
dependencies {
    debugApi(compose.uiTooling)
}
in the android block of the shared module, much less complicated than I was making it out to be 🙈
2760 Views