PreviewLabPreview

Have me.tbsten.compose.preview.lab.gallery.previewlist.PreviewTreeNode.Preview information collected by gradle plugin. It can be used to display the Preview catalog by passing it to PreviewLabGallery.

// generated by gradle plugin
package myApp
object PreviewList : List<CollectedPreview> by listOf(...)

// user code
fun MyAppEntryPoint() {
ComposePreviewLabGallery(
previewList = myApp.PreviewList,
)
}

In addition to collecting from the gradle plugin, you can also use the CollectedPreview function to represent a pseudo-Preview.

fun MyAppEntryPoint() {
ComposePreviewLabGallery(
previews = myAppPreviews + listOf(
CollectedPreview(
displayName = "MyButtonPreview",
filePath = "myApp/src/main/kotlin/myApp/MyButtonPreview.kt",
startLineNumber = 10,
code = null,
) {
MyButton(text = fieldValue { StringField("Click!") })
},
),
)
}

See also

Inheritors

Properties

Link copied to clipboard
abstract val code: String?

The source code of Preview.

Link copied to clipboard
abstract val content: @Composable () -> Unit

The content of Preview. You can display the content of Preview by calling invoke().

Link copied to clipboard
abstract val displayName: String

The value set to displayName of the ComposePreviewLabOption annotation.

Link copied to clipboard
abstract val filePath: String?

The file where Preview exists.

Link copied to clipboard
abstract val id: String
Link copied to clipboard
abstract val startLineNumber: Int?

The starting line number of Preview.