do I have to do anything special to get previews t...
# compose-desktop
k
do I have to do anything special to get previews to work in commonMain or desktop modules for compose? I see that
Copy code
implementation(compose.components.uiToolingPreview)
is in the commonMain dependencies but when I use the
@Preview
annotation to compose functions in either common or desktop modules, I do not see the compose preview icon in Android Studio The annotation imports
import org.jetbrains.compose.ui.tooling.preview.Preview
- is this the correct one?
s
in my experience, I always have to use
androidx.compose.desktop.ui.tooling.preview.Preview
to get
@Preview
to work with the Compose Multiplatform IDE Support plugin in IntelliJ
I'm not sure why
compose.components.uiToolingPreview
is a thing, honestly
k
so adding
androidx.compose.desktop.ui.tooling.preview
dependencies to commonMain?
s
hmm, I'm not totally sure in a multiplatform project as I haven't made a multiplatform project, personally - just a compose for desktop project. I just know that, at least in my experience, you need to use
androidx.compose.desktop.ui.tooling.preview.Preview
to get it to work. if you do a search for
androidx.compose.desktop.ui.tooling.preview.Preview
in this slack, I think there may be some results that can help you
k
Yeah I'm experimenting with that now. Looks like that works for
desktopMain
module but not
commonMain
. I've created an issue at CMP-1550 to find out if there's a canonical way to configure this. Feel free to contribute to this issue
c
Preview does not work in IntelliJ - use Fleet. See the blogpost about the imports. https://blog.jetbrains.com/kotlin/2024/02/compose-multiplatform-1-6-0-release/#preview-annotation-for-fleet
k
thank you - ah that's unfortunate there's no intellij support yet
e
This has worked for me in Intellij / Android Studio in the past for getting previews to work in commonMain https://github.com/eygraber/immich-kmp/tree/master/ui-preview
462 Views