Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom preview annotation with ShowkaseComposable #398

Open
oleksandrbalan-etn opened this issue Dec 4, 2024 · 0 comments
Open

Custom preview annotation with ShowkaseComposable #398

oleksandrbalan-etn opened this issue Dec 4, 2024 · 0 comments

Comments

@oleksandrbalan-etn
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant