Skip to content

Custom preview annotation with ShowkaseComposable #398

Open
@oleksandrbalan-etn

Description

@oleksandrbalan-etn

Thank you for your library!

We recently migrated from KAPT to KSP and encountered some unexpected behavior.

We use a custom annotation, ComponentPreview, for stacking previews:

@Preview(name = "Light preview", showBackground = true)
@Preview(name = "Dark preview", showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES)
annotation class ComponentPreview

Additionally, each component preview is annotated with ShowkaseComposable to specify a group in Showkase browser:

@Composable
@ShowkaseComposable(group = "MyGroup")
@ComponentPreview
fun GreetingPreview() {
    DemoTheme {
        Greeting()
    }
}

This setup worked fine with KAPT. However, after migrating to KSP, the Showkase generates two components: one for the Default group and another for the specified group (e.g., MyGroup).

public val GreetingPreviewDefaultGroupGreetingPreviewDarkpreview1: ShowkaseBrowserComponent =
    ShowkaseBrowserComponent(
        group = "Default Group",
        componentName = "GreetingPreview - Dark preview",
        componentKDoc = "",
        componentKey =
            """com.example.showkasenewkotlin_GreetingPreview_null_DefaultGroup_GreetingPreview-Darkpreview_1_null""",
        isDefaultStyle = false,
        component = @Composable { GreetingPreview() }
    )
    
public val GreetingPreviewGroupGreetingPreview: ShowkaseBrowserComponent = ShowkaseBrowserComponent(
        group = "Group",
        componentName = "GreetingPreview",
        componentKDoc = "",
        componentKey =
            """com.example.showkasenewkotlin_GreetingPreview_null_Group_GreetingPreview_0_null""",
        isDefaultStyle = false,
        component = @Composable { GreetingPreview() }
    )

Is there a way to ignore the Default group and generate components only for composables annotated with ShowkaseComposable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions