4

Visualize Android Components with Airbnb’s ShowKase.

 1 year ago
source link: https://medium.com/@10kanake/visualize-android-components-with-airbnbs-showkase-e68821436439
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Visualize Android Components with Airbnb’s ShowKase.

3 min read2 days ago

Hello guys,hope you all good and welcome back.In today’s article we shall learn how to use Airbnb’s Showkase library to visualize android components.This is more of a browser in our android app to help engineers organize, discover, search and visualize Jetpack Compose UI elements. To jump straight to the codebase, check the repo on my github.

Setting up Showkase
To set up showkase lib in our android app, we shall be required to add dependencies in our build gradle as follows.

1*2RFdu6EfQTRyS0gaC76k_A.png

In order to visualize our android ui elements created in android app, we are required to add certain annotations provided by the showkase lib.We shall start with annotation used while creating composables.In such a scenario, we use the @Preview or @ShowkaseComposable annotation. Check this example below.

1*9Gm8zIyr6n3LiDv_6bgBNA.png

Whilst to search,visualize,discover etc Color properties,we use the @ShowkaseColor annotation. Example,

1*ZKblxzyL1zVw7nl3LO5Ecg.png

And the last property being the TextStyle, we use the @ShowkaseTypography annotation.Example,

1*AreOdI910PKIsf9m39arsA.png

Our last usecase while using showkase involves creating a component that supports multiples styles.A good example was provided by Airbnb library documentation where we have a custom button with multiple styles.The library luckily have these extra properties, the styleName and defaultStyle.The usage for such a circumstance is well captured in this code.

This the code in general for that,

1*nv9I8DoxIc_A9npp_iMbdQ.png

Our second last step is adding the Showkase root class to our android app.A.K.A 👇,

1*BjNvD5oDtY1wIqF2lIoBZw.png

After this, do not forget to rebuild your app, this is critical to make it possible for the library to add packages required and finally call the helper function provided by Showkase in our starter activity, eg,

1*3qk67T_EGRwClwoy569D1g.png

And thats all guys, thanks for reading this.

The final source code can be found here.By any chance you have a query regarding this, do not hesitate to reach out on my twitter


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK