airbnb / Showkase

🔦 Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize Jetpack Compose UI elements
https://medium.com/airbnb-engineering/introducing-showkase-a-library-to-organize-discover-and-visualize-your-jetpack-compose-elements-d5c34ef01095
Apache License 2.0
2.08k stars 106 forks source link

Feature request: support for `device` parameter and others of Compose @Preview #388

Open bingningO opened 1 month ago

bingningO commented 1 month ago

seems Showkase not take screenshots depending on the configuration of @Preview parameter, such as device, widthDp, heightDp.

currently I see if having a @Preview function set as

@Preview(device = Devices.PHONE)
@Preview(device = Devices.TABLET)
@Composable
internal fun PreviewBookCreditContent() {
      ...
}

the generated ShowKaseBrowserComponent looks like below

public val PreviewBookCreditContentDefaultGroupPreviewBookCreditContent: ShowkaseBrowserComponent =
    ShowkaseBrowserComponent(
        group = "Default Group",
        componentName = "PreviewBookCreditContent",
        componentKDoc = "",
        componentKey =
            """...credit_PreviewBookCreditContent_null_DefaultGroup_PreviewBookCreditContent_0_null""",
        isDefaultStyle = false,
        component = @Composable { PreviewBookCreditContent() }
    )

not read device parameter, also not take screenshots depending on its configuration.


p.s.

also if ShowKase adds support for new compose @Preview annotations such as @PreviewScreenSizes, @PreviewFontScale, would be much more helpful.

vinaygaba commented 1 month ago

In the context of Showkase, it doesn't quite make sense to parse the device property because the Showkase browser runs on a physical device. It already supports widthDp and heightDp - https://github.com/airbnb/Showkase?tab=readme-ov-file#showkasecomposable-currently-supports-the-following-properties

Thanks for flagging @PreviewScreenSizes and @PreviewFontScale. I'll figure out how to best integrate them.