# Showkase **Repository Path**: pythonzz/Showkase ## Basic Information - **Project Name**: Showkase - **Description**: Showkase 是一个基于注释处理器的 Android 库,可帮助您组织、发现、搜索和可视化 Jetpack Compose UI 元素 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-01-04 - **Last Updated**: 2024-01-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Showkase   Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize [Jetpack Compose](https://developer.android.com/jetpack/compose) UI elements. With minimal configuration it generates a UI browser that helps you easily find your components, colors & typography. It also renders your components in common situations like dark mode, right-to-left layouts, and scaled fonts which help in finding issues early.
![]() |
![]() |
###### @ShowkaseComposable currently supports the following properties:
Property Name | Description
------------- | -------------
name| The name that should be used to describe your `@Composable` function. If you don't pass any value, the name of the composable function is used as the name.
group | The grouping key that will be used to group it with other `@Composable` functions. This is useful for better organization and discoverability of your components. If you don't pass any value for the group, the name of the class that wraps this function is used as the group name. If the function is a top level function, the composable is added to a "Default Group".
widthDp | The width that your component will be rendered inside the Showkase browser. Use this to restrict the size of your preview inside the Showkase browser.
heightDp | The height that your component will be rendered inside the Showkase browser. Use this to restrict the size of your preview inside the Showkase browser.
skip | Setting this to true will skip this composable from rendering in the Showkase browser. A good use case for this would be when you want to have composable with `@Preview` but want to stop Showkase from picking it up and rendering it in its browser
styleName | The name of the style that a given composable represents. This is useful for scenarios where a given component has multiple style variants and you want to organize them through Showkase for better discoverability.
defaultStyle | A boolean value to denote whether the current composable is using its default style (or the only style if the composable doesn't have other style variants)
##### 2. @ShowkaseColor
Used to annotate `Color` properties that should be presented inside the Showkase browser. Here's
how you would use it with your `Color` fields:
```kotlin
@ShowkaseColor(name = "Name", group = "Group")
val redColor = Color.Red
@ShowkaseColor("Primary", "Light Colors")
val primaryColor = Color(0xFF6200EE)
```
Name and group are optional. Look at the properties section below to understand the behavior when
you don't pass any properties.
###### @ShowkaseColor currently supports the following properties:
Property Name | Description
------------- | -------------
name | The name that should be used to describe your `Color` fields. If you don't pass any value, the name of the color field is used as the name.
group | The grouping key that will be used to group it with other `Color` fields. This is useful for better organization and discoverability of your colors. If you don't pass any value for the group, the name of the class that wraps this field is used as the group name. If the field is a top level field, the color is added to a "Default Group".
##### 3. @ShowkaseTypography
Used to annotate `TextStyle` properties that should be presented inside the Showkase browser.
Here's how you would use it with your `TextStyle` fields:
```kotlin
@ShowkaseTypography(name = "Name", group = "Group")
val h1 = TextStyle(
fontWeight = FontWeight.Light,
fontSize = 96.sp,
letterSpacing = (-1.5).sp
)
```
Name and group are optional. Look at the properties section below to understand the behavior when
you don't pass any properties.
###### @ShowkaseTypography currently supports the following properties:
Property Name | Description
------------- | -------------
name | The name that should be used to describe your `TextStyle` fields. If you don't pass any value, the name of the textStyle field is used as the name.
group | The grouping key that will be used to group it with other `TextStyle` fields. This is useful for better organization and discoverability of your typography. If you don't pass any value for the group, the name of the class that wraps this field is used as the group name. If the field is a top level field, the textStyle is added to a "Default Group".
##### 4. @ShowkaseRoot
Used to annotate the `ShowkaseRootModule` implementation class. This is needed to let Showkase
know more about the module that is going to be the root module for aggregating all the Showkase
supported UI elements across all the different modules(if you are using a multi-module project).
If you are only using a single module in your project, add it to that module. You are allowed to
have only one @ShowkaseRoot per module.
Here's an example of how you would use it:
```kotlin
@ShowkaseRoot
class MyRootModule: ShowkaseRootModule
```
Note: The root module is the main module of your app that has a dependency on all other modules
in the app. This is relevant because we generate the Showkase related classes in the package of
the root module and we need to be able to access the UI elements across all the sub modules. This
is only possible from the root module as it typically has a dependency on all the sub-modules.
##### 5. `Showkase` Object
The `Showkase` object is the receiver for all the helper methods that this library generates.
Currently there are a few extension functions that are generated with the `Showkase` object as the
receiver. In order to get access to these functions, you need to build the app once so that the
methods can be generated for your use.
Extension function | Description
------------- | -------------
getBrowserIntent | Helper function that return an intent to start the ShowkaseBrowser activity.
getMetadata | Helper function that's give's you access to Showkase metadata. This contains data about all the composables, colors and typography in your codebase that's rendered in the Showkase Browser.
```kotlin
// Example Usage
val intent = Showkase.getBrowserIntent(context)
startActivity(intent)
val metadata = Showkase.getMetadata()
val components = metadata.componentList
val colors= metadata.colorList
val typography = metadata.typographyList
```
## Frequently Asked Questions
Is Airbnb using Jetpack Compose in their main app?
Airbnb has been one of the earliest adopters of Jetpack Compose and has been using it in production since early 2021.
Compose is a really critical pillar of our overall Android strategy and we continue to heavily invest in building more
tooling on top of it. We spoke about our experience of using Jetpack Compose
at Google I/O 2022.
Can I contribute to this library?
Pull requests are welcome! We'd love help improving this library. Feel free to browse through
open issues to look for things that need
work. If you have a feature request or bug, please open a new issue so we can track it.
How do I provide feedback?
The issues tab is the best place to do
that.
Why can't we have a single annotation like `Showkase` for all the UI elements? Why did you
create a different annotation for each UI element(@ShowkaseComposable for composables,
@ShowkaseColor for colors & @ShowkaseTypography for text styles)?
This was done mostly for future proofing. Even though these annotations have the same
properties right now, it's possible that they will diverge as we add more features. Once more
people start using this library, we will get a more clear idea about whether that needs to
happen or not. If we find that it didn't evolve the way we expected, we will consider
consildating these annotations.
I would like to customize my component browser. Can this library still be useful?
We provide a nice helper function that gives you access to the metadata of all your UI elements
that are configured to work with Showkase. You can use `Showkase.getMetadata()` to get access
to it and then use it in whatever way you see fit.