https://kotlinlang.org logo
Title
a

Ayfri

07/15/2021, 2:00 PM
How can I use the
Preview
annotation in build 245 ?
r

Rafs

07/15/2021, 2:29 PM
You need to install this plugin as well
a

Ayfri

07/15/2021, 2:32 PM
yeah I have it
r

Rafs

07/15/2021, 2:34 PM
You also need to add the uiTooling dependency
a

Ayfri

07/15/2021, 3:07 PM
oh it was that, thanks !
does preview exists on IJ ?
r

Rafs

07/15/2021, 7:40 PM
Yes for compose desktop. In fact I do all my android UI development inside compose desktop because it is faster.
a

Ayfri

07/15/2021, 10:15 PM
How do I use it on Intellij, I don't find it 🤔
a

Ayfri

07/16/2021, 6:52 PM
ah okay it needs no arguments
a

Arkadii Ivanov

07/18/2021, 1:43 PM
I have IDEA UE 2021.1.3, the plugin and the
uiTooling
dependency added. The import
import androidx.compose.desktop.ui.tooling.preview.Preview
is unresolved and the preview does not work for me. I tried invalidate/restart/delete
.idea
folder, did not help. Am I missing something else?
j

jim

07/18/2021, 9:10 PM
Did you add it in the desktop module/sourceset or common module/sourceset? The dependency must be added to the desktop source set and can only be used from whichever source set you add it to (your desktop one)
a

Arkadii Ivanov

07/18/2021, 9:35 PM
I tried to add previews to the TodoApp's
compose-ui
module, which is a KMP module with
jvm
and
android
targets. The UI is in the
commonMain
source set. https://github.com/JetBrains/compose-jb/tree/master/examples/todoapp/common/compose-ui
j

jim

07/18/2021, 9:41 PM
Right, what I'm saying is that your preview annotations can't be in the commonMain source set. They need to be in the desktop/jvm source set. You can define a new file in your desktop/jvm source set or add them here: https://github.com/JetBrains/compose-jb/blob/master/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt
a

Arkadii Ivanov

07/18/2021, 9:51 PM
Thanks Jim for your help, I'll will do.