PreviewLabPreview
interface 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,
)
}Content copied to clipboard
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!") })
},
),
)
}Content copied to clipboard