Skip to content

Commit

Permalink
Prepare for release 1.0.0-alpha09 (#144)
Browse files Browse the repository at this point in the history
* Saving changes

* Preparing for release

* Added an FAQ question

* Nit
  • Loading branch information
vinaygaba committed Mar 26, 2021
1 parent 87acc58 commit 1a756cd
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 28 deletions.
44 changes: 38 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Showkase
![Showkase Version](https://img.shields.io/badge/Showkase-1.0.0--alpha08-brightgreen) ![Compatible with Compose](https://img.shields.io/badge/Compatible%20with%20Compose-1.0.0--beta02-brightgreen)
![Showkase Version](https://img.shields.io/badge/Showkase-1.0.0--alpha09-brightgreen) ![Compatible with Compose](https://img.shields.io/badge/Compatible%20with%20Compose-1.0.0--beta03-brightgreen)

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
Expand Down Expand Up @@ -72,8 +72,8 @@ setup, add this dependency to all the modules with UI elements that should be di
Showkase browser.

```kotlin
implementation "com.airbnb.android:showkase:1.0.0-alpha08"
kapt "com.airbnb.android:showkase-processor:1.0.0-alpha08"
implementation "com.airbnb.android:showkase:1.0.0-alpha09"
kapt "com.airbnb.android:showkase-processor:1.0.0-alpha09"
```

**Step 2**: Add the relevant annotations for every UI element that should be a part of the
Expand Down Expand Up @@ -124,13 +124,13 @@ class MyRootModule: ShowkaseRootModule

**Step 4**: Showkase is now ready for use! Showkase comes with an Activity that you need to start
for accessing the UI browser. Typically you would start this activity from the debug menu of
your app but you are free to start this from any place you like! A nice helper function
`createShowkaseBrowserIntent` is generated for you so you might have to build the app once
your app but you are free to start this from any place you like! A nice helper extension function
`getBrowserIntent` is generated for you so you might have to build the app once
before it's available for use. Just start the intent and that's all you need to do for accessing
Showkase!

```kotlin
startActivity(createShowkaseBrowserIntent(this))
startActivity(Showkase.getBrowserIntent(context))
```

## Documentation
Expand Down Expand Up @@ -290,7 +290,31 @@ Note: The root module is the main module of your app that has a dependency on al
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
<details>
Expand Down Expand Up @@ -337,6 +361,14 @@ the root module and we need to be able to access the UI elements across all the
consildating these annotations.
</details>

<details>
<summary>I would like to customize my component browser. Can this library still be useful?
</summary>
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.
</details>

## Coming Soon!

Here are some ideas that we are thinking about. We are also not limited to these and would love
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ android.useAndroidX=true
android.enableJetifier=false
kotlin.code.style=official

VERSION_NAME=1.0.0-alpha08
VERSION_NAME=1.0.0-alpha09
GROUP=com.airbnb.android
POM_DESCRIPTION=Showkase is an Android library that helps you organize, discover, search and visualize Jetpack Compose components.
POM_URL=https://github.com/airbnb/Showkase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.airbnb.android.showkase.models

data class ShowkaseElementsMetadata(
val components: List<ShowkaseBrowserComponent> = listOf(),
val colors: List<ShowkaseBrowserColor> = listOf(),
val typographyMap: List<ShowkaseBrowserTypography> = listOf(),
val componentList: List<ShowkaseBrowserComponent> = listOf(),
val colorList: List<ShowkaseBrowserColor> = listOf(),
val typographyList: List<ShowkaseBrowserTypography> = listOf(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ interface ShowkaseProvider {
fun getShowkaseTypography(): List<ShowkaseBrowserTypography>

fun metadata(): ShowkaseElementsMetadata {
val componentsMap = getShowkaseComponents()
val colorsMap = getShowkaseColors()
val typographyMap = getShowkaseTypography()
return ShowkaseElementsMetadata(componentsMap, colorsMap, typographyMap)
val componentList = getShowkaseComponents()
val colorList = getShowkaseColors()
val typographyList = getShowkaseTypography()
return ShowkaseElementsMetadata(componentList, colorList, typographyList)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,13 @@ class ShowkaseBrowserActivity : AppCompatActivity() {
return try {
val showkaseComponentProvider =
Class.forName("$classKey$AUTOGEN_CLASS_NAME").newInstance()

val componentsList =
(showkaseComponentProvider as ShowkaseProvider)
.getShowkaseComponents()

val colorsList =
showkaseComponentProvider
.getShowkaseColors()

val typographyList =
showkaseComponentProvider
.getShowkaseTypography()
val showkaseMetadata = (showkaseComponentProvider as ShowkaseProvider).metadata()

ShowkaseElementsMetadata(
components = componentsList,
colors = colorsList,
typographyMap = typographyList
componentList = showkaseMetadata.componentList,
colorList = showkaseMetadata.colorList,
typographyList = showkaseMetadata.typographyList
)
} catch (exception: ClassNotFoundException) {
ShowkaseElementsMetadata()
Expand Down

0 comments on commit 1a756cd

Please sign in to comment.