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.1k stars 107 forks source link

Add documentation regarding Custom preview annotation usage 🤩 📜 #307

Open oas004 opened 1 year ago

oas004 commented 1 year ago

Here I have added documentation for using Custom preview annotation with Showkase. I have added use cases and KSP vs KAPT differences. Also added docs about how to use this with KAPT.

This should not be merged before the next release is out to avoid confusion.

I'm not entirely sure about the placement and how the content is structured. Is there anything else that is needed to be mentioned @vinaygaba? :)

polivmi1 commented 1 year ago

I am seeing slow builds:

w: [ksp] No dependencies are reported for ShowkaseMetadata_showkase_somemultipreview which will prevent
incremental compilation.

This is how the annotation looks @Preview(name = "english", group = "some", locale = "en", showBackground = true) @Preview(name = "russian", group = "some", locale = "ru", showBackground = true) @Preview(name = "arabic", group = "some", locale = "ar", showBackground = true) @Preview(name = "0.85f", group = "some", fontScale = 0.85f, showBackground = true) @Preview(name = "1.00f", group = "some", fontScale = 1.00f, showBackground = true) @Preview(name = "1.15f", group = "some", fontScale = 1.15f, showBackground = true) @Preview(name = "1.30f", group = "some", fontScale = 1.30f, showBackground = true) @Preview(name = "LIGHT", group = "some", uiMode = Configuration.UI_MODE_NIGHT_NO, showBackground = true) @Preview(name = "DARK", group = "some", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true) @Preview(name = "NEXUS", group = "some", showSystemUi = true, device = Devices.NEXUS_5) @Preview(name = "PIXEL", group = "some", showSystemUi = true, device = Devices.PIXEL_4) @Preview(name = "LANDSCAPE", group = "some", showSystemUi = true, device = Devices.AUTOMOTIVE_1024p) annotation class SomeMultiPreview

Is there any other setup needed to make ksp incremental with the update to this library?

oas004 commented 1 year ago

@polivmi1 I think it might be better to open an issue for this. I'm not 100% sure if this has anything to do with the custom preview annotation implementation, but are you using that through a fork or something?

polivmi1 commented 1 year ago

@oas004 I am using 1.0.0-beta18 . It isn't published on github releases, but is available in https://mvnrepository.com/artifact/com.airbnb.android/showkase and should contain the latest changes. That's also the version that breaks.

oas004 commented 1 year ago

I tried copying the annotation you made in the sample project and it seems to work as expected. Is the project you are using public?

polivmi1 commented 1 year ago

Unfortunately not. Next week I will try to set up a sample project to reproduce the error.

polivmi1 commented 1 year ago

@oas004 this is a sample where it is reproducible: https://github.com/polivmi1/ShowkaseIncrementalCompilation

Screenshot 2023-03-27 at 10 49 03
oas004 commented 1 year ago

Thank you! I will check this out! :)

polivmi1 commented 1 year ago

@oas004 I have updated the sample and I am not seeing Showkase to apply any of the Preview parameters like: locale, showBackground, fontScale, uiMode, showSystemUi, device

Is that supported on ksp?

oas004 commented 1 year ago

It should support the same preview type as single preview in older versions😊

yoviekaputra commented 10 months ago

Hi everyone, my code is like this

@Preview("Light")
@Preview("Dark", uiMode = Configuration.UI_MODE_NIGHT_YES)
annotation class PreviewMultipleMode

@Composable
@PreviewMultipleMode
@ShowkaseComposable(name = "ComponentPreview", group = "Toolbar", skip = true)
fun ToolbarPreview(
    @PreviewParameter(ToolbarPreviewParameterProvider::class) parameter: ToolbarPreviewParameter
) {
    ToolbarBasePreview(parameter = parameter)
}

also, I have added to my grade

kapt {
    arguments {
        arg("multiPreviewType", "com.airbnb.android.submodule.showkasesample.LocalePreview")
    }
}

but I still have errors like this issue #357

can anyone help me?

oas004 commented 10 months ago

I think maybe if we can take the issues related to this feature in separate issues that would be cool. I don't think they are directly related to this PR. I have commented on your issue @yoviekaputra :) Will try to have a look at that.

I will try to rebase this branch. Do you think we should merge this PR @vinaygaba ? This is only documentation changes for the multi preview stuff. I think it would be nice to get that in for people using that in their code base :) Wdyt?