kv
06/16/2024, 6:38 PM@Preview
to work in KMP modules outside of the androidMain
module? Seems like the default compose.components.uiToolingPreview
does not work for Intellij/Android studio and that I have to explicitly add:
dependencies {
debugImplementation(libs.androidx.compose.ui.tooling)
implementation(libs.androidx.compose.ui.tooling.preview)
}
to the desktopMain
module and then I can get previews to show up - but not in the commonMain
module. I created an issue here with more detailed steps of my investigation CMP-1550Rok Oblak
06/16/2024, 6:42 PMkv
06/16/2024, 8:15 PMWout Werkman
06/17/2024, 6:13 AMdesktopMain
using the Compose Multiplatform IDE Support plugin in IntelliJ. If you want common previews without adding a desktop target, then it's only available in FleetRok Oblak
06/17/2024, 7:05 AMimport org.jetbrains.compose.ui.tooling.preview.Preview
and this is in commonMainWout Werkman
06/17/2024, 7:28 AMdesktopMain
like I mentioned. If you have a desktop target and the plugin there is a workaround available to make common previews work in IJ, but I couldn't find the link to the blog. It works via making @Preview
an expect annotation class somehow.
If you don't have desktop, (eg, only android + iOS), then there are no previews in IJ. Even if you have desktop, it's only available via a workaround.
In this case it's only available in FleetRok Oblak
06/17/2024, 9:08 AMdesktopMain
but it did not work.
I realized my issue was the wrong import:
I had
org.jetbrains.compose.ui.tooling.preview.Preview
but I needed
androidx.compose.desktop.ui.tooling.preview.Preview
With this it works in desktopMain - but then again this doesn't help me much as I can already do this with Android previews in the Android module.
I tried a suggestion here but using my custom preview like that in common main did not show the preview icon.
Either way I hope this is simplified and clarified, because it is quite confusing with multiple imports and workarounds.kv
06/17/2024, 1:38 PMWout Werkman
06/17/2024, 1:43 PMEither way I hope this is simplified and clarified, because it is quite confusing with multiple imports and workarounds.That's fair feedback! We are working on this for Fleet, it might be worth making an issue for this in AS as well
kv
06/17/2024, 2:02 PMRok Oblak
06/17/2024, 3:42 PMwiktor
08/21/2024, 5:32 PM@Preview
annotation, it must be a bug that it’s not displayed in the AS”), just found out about Fleet - silly question - is it a new recommendation for multiplatform projects? I am mostly focused on mobile platformsRok Oblak
08/21/2024, 6:08 PMWout Werkman
08/21/2024, 6:15 PMRok Oblak
08/21/2024, 6:17 PMwiktor
08/21/2024, 6:37 PMwiktor
08/21/2024, 6:38 PMWout Werkman
08/21/2024, 6:40 PMwiktor
08/21/2024, 6:41 PMwiktor
08/21/2024, 6:41 PM