Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Kennyc1012/BottomSheet
BottomSheetMenu style dialogs for Android
https://github.com/Kennyc1012/BottomSheet
Last synced: about 3 hours ago
JSON representation
BottomSheetMenu style dialogs for Android
- Host: GitHub
- URL: https://github.com/Kennyc1012/BottomSheet
- Owner: Kennyc1012
- License: apache-2.0
- Created: 2015-08-09T22:53:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T12:22:56.000Z (6 months ago)
- Last Synced: 2024-08-04T00:06:57.556Z (4 months ago)
- Language: Kotlin
- Homepage:
- Size: 13 MB
- Stars: 885
- Watchers: 18
- Forks: 100
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-github-android-ui - BottomSheet - 安卓BottomSheet风格的对话框 (ActionSheet)
README
# BottomSheetMenu
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-BottomSheet-green.svg?style=flat)](https://android-arsenal.com/details/1/2315)
# Features
- Both list and grid style
- Light, Dark, and DayNight theme as well as custom themeing options
- Material3 Theme support
- XML style support
- Tablet support
- API 21+
- Kotlin support# Using BottomSheetMenu
To get started using BottomSheetMenu, first you'll need to create a menu resource file with the defined actions.
```xml
```
Then create a BottomSheetMenuDialogFragment via the Builder class using either the Builder method calls for java
or named arguments for Kotlin
```java
new BottomSheetMenuDialogFragment.Builder(getActivity())
.setSheet(R.menu.bottom_sheet)
.setTitle(R.string.options)
.setListener(myListener)
.setObject(myObject)
.show(getSupportFragmentManager());
```
```kotilin
BottomSheetMenuDialogFragment.Builder(context = this,
sheet = R.menu.bottom_sheet,
listener = myListener,
title = R.string.options,
`object` = myObject)
.show(supportFragmentManager)
```
# Styling
BottomSheetMenu comes with both a Light and Dark theme to accommodate most scenarios. However, if you want to customize itr more, you can create your own style and supply it to the builder.
Customizable attributes are:
```xml```
Then create a style
```xml<item name="bottom_sheet_menu_title_text_appearance">@style/TitleAppearance</item>
<item name="bottom_sheet_menu_list_text_appearance">@style/ListAppearance</item>
<item name="bottom_sheet_menu_grid_text_appearance">@style/GridAppearance</item><item name="android:textColor">@android:color/holo_green_light</item>
<item name="android:textColor">@android:color/holo_red_light</item>
<item name="android:textSize">18sp</item><item name="android:textColor">@android:color/holo_red_light</item>
<item name="android:textSize">20sp</item>```
Also note that each of these pre-defined styles also have a light and DayNight theme. They are named similary with a `.Light` or `DayNight` added to the end of the style name
`@style/Theme.BottomSheetMenuDialog.Light` `@style/BottomSheetMenu.Title.TextAppearance.Light` etc...Then finally pass the style into the `Builder` object.
```java
new BottomSheetMenuDialogFragment.Builder(getActivity(), R.style.MyBottomSheetStyle)
.setSheet(R.menu.bottom_sheet)
.setTitle(R.string.options)
.setListener(myListener)
.show();
``````kotlin
BottomSheetMenuDialogFragment.Builder(context = this,
sheet = R.menu.bottom_sheet,
title = R.string.options,
listener = myListener,
style = R.style.MyBottomSheetStyle)
.show(supportFragmentManager)
```# Callbacks
BottomSheetMenu uses the [BottomSheetListener](https://github.com/Kennyc1012/BottomSheetMenu/blob/master/library/src/main/java/com/kennyc/bottomsheet/BottomSheetListener.kt) for callbacks
```kotlin
/**
* Called when the [BottomSheetMenuDialogFragment] is first displayed
*
* @param bottomSheet The [BottomSheetMenuDialogFragment] that was shown
* @param object Optional [Object] to pass to the [BottomSheetMenuDialogFragment]
*/
fun onSheetShown(bottomSheet: BottomSheetMenuDialogFragment, `object`: Any?)/**
* Called when an item is selected from the list/grid of the [BottomSheetMenuDialogFragment]
*
* @param bottomSheet The [BottomSheetMenuDialogFragment] that had an item selected
* @param item The item that was selected
* @param object Optional [Object] to pass to the [BottomSheetMenuDialogFragment]
*/
fun onSheetItemSelected(bottomSheet: BottomSheetMenuDialogFragment, item: MenuItem, `object`: Any?)/**
* Called when the [BottomSheetMenuDialogFragment] has been dismissed
*
* @param bottomSheet The [BottomSheetMenuDialogFragment] that was dismissed
* @param object Optional [Object] to pass to the [BottomSheetMenuDialogFragment]
* @param dismissEvent How the [BottomSheetMenuDialogFragment] was dismissed. Possible values are:
* * [.DISMISS_EVENT_SWIPE]
* * [.DISMISS_EVENT_MANUAL]
* * [.DISMISS_EVENT_ITEM_SELECTED]
*/
fun onSheetDismissed(bottomSheet: BottomSheetMenuDialogFragment, `object`: Any?, @DismissEvent dismissEvent: Int)
```# Upgrading to 5.X
- Removed various `createShareBottomSheet` methods
- Targeting Android SDK 34
- Targeting Kotlin 1.8.22# Upgrading to 4.X
- Styles now extend Theme.Material3.* themes
- An app's style should inherit from a MaterialComponent theme. Material3 themes are preferred but not required.
- Removed `bottom_sheet_menu_selector` attribute
- Removed various resources
- Java 11 is now required to compile project
- MinSdk is now 21, also targeting API 31# Upgrading to 3.X
- `BottomSheet` has been renamed to `BottomSheetMenuDialogFragment`
- Custom views and simple messages are no longer supported. Please use a [BottomSheetDialogFragment](https://developer.android.com/reference/com/google/android/material/bottomsheet/BottomSheetDialogFragment) and customize it from there
- Many of the theme attributes have been removed or renamed. See the Styling section above for current values
- CollaspingView has been removed.
- Migration to [AndroidX](https://developer.android.com/jetpack/androidx/) and [Google Material Components](https://github.com/material-components/material-components-android)
- MinSdk is now 19, also targeting API 28# Upgrading From 1.x
When upgrading to 2.x from a 1.x release, some changes will have to be made.
- All of the builder methods for settings colors have been removed. All customzing should be done through themes.
- The style attributes have been change to text appearances rather than colors.
- The Builder constructor no longer takes a menu object. You will need to call ```setSheet(...)```.
- The ```onSheetDismissed``` callback now takes an int as an argument for simple message support.
- The gradle dependency has changed and needs to be updated.# Including in your project
To include BottomSheet in your project, make the following changes to your build.gradle file## Add repository
```groovy
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```
## Add dependency
```groovy
dependencies {
implementation "com.github.Kennyc1012:BottomSheetMenu:5.1.1"
```# Contribution
Pull requests are welcomed and encouraged. If you experience any bugs, please file an [issue](https://github.com/Kennyc1012/BottomSheet/issues)License
=======Copyright 2015 Kenny Campagna
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.