Francis Mariano
03/02/2023, 12:27 PMcurioustechizen
03/02/2023, 12:33 PM@Preview
annotation in any Android Library module or in an Application module (this is using Android Studio/Android Gradle plugin's terminology)Zheng Hong
03/02/2023, 2:02 PMcurioustechizen
03/02/2023, 2:04 PMJoseph Hawkes-Cates
03/02/2023, 2:24 PMFrancis Mariano
03/02/2023, 2:45 PMLandry Norris
03/02/2023, 3:06 PMFrancis Mariano
03/02/2023, 5:57 PMLandry Norris
03/02/2023, 6:01 PMChris Sinco [G]
03/02/2023, 6:03 PMLandry Norris
03/02/2023, 6:05 PMChris Sinco [G]
03/02/2023, 6:08 PMChris Sinco [G]
03/02/2023, 6:09 PMLandry Norris
03/02/2023, 6:09 PMChris Sinco [G]
03/02/2023, 6:09 PMArkadii Ivanov
03/02/2023, 6:16 PM@OptionalEpxectation expect annotation class Preview
annotation in the same androidx package in your module and use the Compose Multiplatform IDEA plugin for previews.Landry Norris
03/02/2023, 6:17 PMArkadii Ivanov
03/02/2023, 6:20 PMFrancis Mariano
03/02/2023, 6:26 PMArkadii Ivanov
03/02/2023, 6:29 PMLandry Norris
03/02/2023, 6:29 PMFrancis Mariano
03/02/2023, 6:30 PMFrancis Mariano
03/02/2023, 6:31 PMorg.jetbrains.compose.ui:ui-tooling
and org.jetbrains.compose.ui:ui-tooling-preview
Landry Norris
03/02/2023, 6:31 PMFrancis Mariano
03/02/2023, 6:35 PMNo matching variant of org.jetbrains.compose.ui:ui-tooling:1.3.1-rc01 was found. The consumer was configured to find a library for use during 'kotlin-api', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64' but:
Landry Norris
03/02/2023, 6:36 PMLandry Norris
03/02/2023, 6:36 PMFrancis Mariano
03/02/2023, 6:37 PMArkadii Ivanov
03/02/2023, 6:37 PMtooling
deps added and it works. There is the gutter icon next to a Composable function, the preview shows when I click on it. I'm using IntelliJ IDEA 2022.3.1Landry Norris
03/02/2023, 6:38 PMArkadii Ivanov
03/02/2023, 6:39 PMjvm
target is required in this caseLandry Norris
03/02/2023, 6:39 PMArkadii Ivanov
03/02/2023, 6:40 PMjvm
, and the Preview annotation it supports is in androidx.compose.desktop.ui.tooling.preview
packageLandry Norris
03/02/2023, 6:41 PMFrancis Mariano
03/02/2023, 6:45 PMFrancis Mariano
03/02/2023, 6:46 PMFrancis Mariano
03/02/2023, 6:47 PMFrancis Mariano
03/02/2023, 6:47 PMArkadii Ivanov
03/02/2023, 6:52 PMLandry Norris
03/02/2023, 6:53 PM@MustBeDocumented
@Retention(AnnotationRetention.BINARY)
@Target(
AnnotationTarget.ANNOTATION_CLASS,
AnnotationTarget.FUNCTION
)
@Repeatable
annotation class Preview(
val name: String = "",
val group: String = "",
@IntRange(from = 1) val apiLevel: Int = -1,
// TODO(mount): Make this Dp when they are inline classes
val widthDp: Int = -1,
// TODO(mount): Make this Dp when they are inline classes
val heightDp: Int = -1,
val locale: String = "",
@FloatRange(from = 0.01) val fontScale: Float = 1f,
val showSystemUi: Boolean = false,
val showBackground: Boolean = false,
val backgroundColor: Long = 0,
@UiMode val uiMode: Int = 0,
@Device val device: String = Devices.DEFAULT
)
Landry Norris
03/02/2023, 6:54 PMFrancis Mariano
03/02/2023, 6:58 PMMaybe because the function has arguments?No, i did another fun with no arguments
Francis Mariano
03/02/2023, 6:59 PMLandry Norris
03/02/2023, 7:00 PMFrancis Mariano
03/02/2023, 7:02 PMLandry Norris
03/02/2023, 7:03 PMFrancis Mariano
03/02/2023, 7:03 PMFrancis Mariano
03/06/2023, 9:25 PMandroidx.compose.android.ui.tooling.preview
no work because with android it is necessary to add buildFeatures {compose = true}
in the moduleLandry Norris
03/06/2023, 9:33 PMFrancis Mariano
03/06/2023, 9:35 PM