Skip to content

Commit

Permalink
Prepare for release 2.0.0-rc01
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Feb 12, 2023
1 parent 5b2d2e1 commit f3f361c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 74 deletions.
72 changes: 4 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,14 @@

![demo](demo.gif)

`cascade` builds nested popup menus with smooth height animations. It is designed to be a *drop-in* replacement for [PopupMenu](https://developer.android.com/reference/androidx/appcompat/widget/PopupMenu) so using it in your project is beautifully only a word away. Try out the [sample app](https://github.com/saket/cascade/releases/download/1.3.0/cascade_v1.3.0_sample.apk) to see it in action.
`cascade` builds nested popup menus with smooth height animations. It is designed to be a *drop-in* replacement for both [PopupMenu](https://developer.android.com/reference/androidx/appcompat/widget/PopupMenu) and [DropdownMenu](https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary#DropdownMenu(kotlin.Boolean,kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.unit.DpOffset,androidx.compose.ui.window.PopupProperties,kotlin.Function1)), so using it in your project is beautifully only a word away. Try out the [sample app](https://github.com/saket/cascade/releases/download/2.0.0-rc01/cascade_v2.0.0-rc01_sample.apk) to see it in action.

```groovy
implementation "me.saket.cascade:cascade:1.3.0"
implementation "me.saket.cascade:cascade:2.0.0-rc01"
implementation "me.saket.cascade:cascade-compose:2.0.0-rc01"
```

```diff
- val popup = PopupMenu(context, anchor)
+ val popup = CascadePopupMenu(context, anchor)
popup.inflate(R.menu.nicolas_cage_movies)
popup.show()
```

#### Use as Toolbar's overflow menu

```kotlin
toolbar.overrideAllPopupMenus { context, anchor ->
CascadePopupMenu(context, anchor)
}

// The lambda can be collapsed into a reference
// if you're only using the two-param constructor.
toolbar.overrideAllPopupMenus(with = ::CascadePopupMenu)
```

### Customization

`cascade` is great for apps that prefer applying dynamic themes at runtime, which `PopupMenu` makes it extremely hard to do so. By providing a `CascadePopupMenu.Styler` object, you can adjust colors, spacings and text styles from Kotlin ([example](https://github.com/saket/cascade/blob/ea668552999be0d3fd235e9feefa782ac92b13d4/sample/src/main/java/me/saket/cascade/sample/MainActivity.kt#L91:L110)).

```kotlin
CascadePopupMenu(context, anchor, styler = CascadePopupMenu.Styler(...))
```

By default, `cascade` will pick up values from your theme in the same way as `PopupMenu` would.

```xml
<style name="AppTheme">
<item name="popupMenuStyle">@style/PopupMenuStyle</item>
<item name="colorControlNormal">@color/menu_icon_color</item>
<item name="android:textColorPrimary">@color/menu_item_text_color</item>
<item name="android:textColorSecondary">@color/menu_title_text_color</item>
</style>

<style name="PopupMenuStyle" parent="@style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">...</item>
<item name="android:popupElevation">...</item>
</style>
```

### Navigation

For sub-menus, `cascade` will automatically navigate to the parent menu when the title is clicked. For manual navigation, `CascadePopupMenu#navigateBack()` or [CascadeBackNavigator](https://github.com/saket/cascade/blob/trunk/cascade/src/main/java/me/saket/cascade/CascadeBackNavigator.kt) can be used.

```kotlin
popup.menu.addSubMenu("Remove").also {
it.setHeaderTitle("Are you sure?")
it.add("Burn them all")
it.add("Take me back").setOnMenuItemClickListener {
popup.navigateBack()
}
}
```

### Custom layouts

`cascade` was originally inspired by Google Drive's [menu](https://twitter.com/saketme/status/1313130386743066627) that uses a variety of complex controls. For apps that want to create something similar, a batteries-included [CascadePopupWindow](https://github.com/saket/cascade/blob/trunk/cascade/src/main/java/me/saket/cascade/CascadePopupWindow.kt) is provided for use with custom layouts.

```kotlin
val popup = CascadePopupWindow(context)
popup.contentView.addView(CustomMenuView(context)) // Also see contentView.goBack().
popup.show(anchor)
```
See project website for full documentation.

## License

Expand Down
2 changes: 1 addition & 1 deletion docs/compose/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[drop_down_menu]: https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary#DropdownMenu(kotlin.Boolean,kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.unit.DpOffset,androidx.compose.ui.window.PopupProperties,kotlin.Function1)

```groovy
implementation "me.saket.cascade:cascade-compose:2.0.0-beta1"
implementation "me.saket.cascade:cascade-compose:2.0.0-rc01"
implementation "androidx.compose.material3:material3:…" // https://d.android.com/jetpack/androidx/releases/compose-material3
```

Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

![demo](https://github.com/saket/cascade/raw/trunk/demo.gif)

`cascade` builds nested popup menus with smooth height animations. It is designed to be a *drop-in* replacement for both [PopupMenu](https://developer.android.com/reference/androidx/appcompat/widget/PopupMenu) and [DropdownMenu](https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary#DropdownMenu(kotlin.Boolean,kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.unit.DpOffset,androidx.compose.ui.window.PopupProperties,kotlin.Function1)), so using it in your project is beautifully only a word away. Try out the [sample app](https://github.com/saket/cascade/releases/download/1.3.0/cascade_v1.3.0_sample.apk) to see it in action.
`cascade` builds nested popup menus with smooth height animations. It is designed to be a *drop-in* replacement for both [PopupMenu](https://developer.android.com/reference/androidx/appcompat/widget/PopupMenu) and [DropdownMenu](https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary#DropdownMenu(kotlin.Boolean,kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.unit.DpOffset,androidx.compose.ui.window.PopupProperties,kotlin.Function1)), so using it in your project is beautifully only a word away. Try out the [sample app](https://github.com/saket/cascade/releases/download/2.0.0-rc01/cascade_v2.0.0-rc01_sample.apk) to see it in action.

```groovy
implementation "me.saket.cascade:cascade:2.0.0-beta1"
implementation "me.saket.cascade:cascade-compose:2.0.0-beta1"
implementation "me.saket.cascade:cascade:2.0.0-rc01"
implementation "me.saket.cascade:cascade-compose:2.0.0-rc01"
```

=== "Compose UI"
Expand Down
2 changes: 1 addition & 1 deletion docs/views/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
`cascade` offers a drop-in replacement for [PopupMenu](https://developer.android.com/reference/androidx/appcompat/widget/PopupMenu). For guidance on creating & nesting menus, the [official documentation](https://developer.android.com/develop/ui/views/components/menus) can be followed while replacing any usages of `PopupMenu` with `CascadePopupMenu`.

```groovy
implementation "me.saket.cascade:cascade:2.0.0-beta1"
implementation "me.saket.cascade:cascade:2.0.0-rc01"
```

```diff
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ android.useAndroidX=true
android.defaults.buildfeatures.buildconfig=false

GROUP=me.saket.cascade
VERSION_NAME=2.0.0-SNAPSHOT
VERSION_NAME=2.0.0-rc01

POM_INCEPTION_YEAR=2020
POM_URL=https://github.com/saket/cascade
Expand Down

0 comments on commit f3f361c

Please sign in to comment.