Browsing Jetpack Compose samples
source link: https://dev.to/antonshilov/browsing-jetpack-compose-samples-32m6
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.
Browsing Jetpack Compose samples
Jul 1
・2 min read
Problem
While writing apps with Jetpack Compose you can always Cmd+Click
on a library function to check their sources and comments. And often you can find a link to the sample code with an example of usages for that function. Unfortunately, sample code is not published together with the Jetpack Compose library so you cannot browse them.
Jetpack Compose has two kinds of samples. The API samples - small examples of api usages, and sample apps repo on github. In this post we're talking about API samples.
Easy Solution
All Jetpack Compose sources are open and published as a part of the AndroidX repo. We can quickly find sample code using Android Code Search website.
- Copy sample name from the sources
- Open https://cs.android.com in the browser
- Search for the sample code
Better solution
Keeping a browser tab open and manually copying function name is quite a hassle. We can do better, we can automate it! And CodeSearch plugin can help us with that. It allows us to launch search queries right from the IDE, and we can add a custom search engine.
- Install Code Search plugin https://plugins.jetbrains.com/plugin/12578-codesearch
Add Android Code Search engine to plugin settings(IDE restart required).
Name: Android CS
Url: https://cs.android.com/search?q=lang:kotlin usage:Select the sample name and search for it
Hope you found this post useful 😄. You can follow me to get the latest news about Compose.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK