Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/commit451/modalbottomsheetdialogfragment
Modal bottom sheet dialog based on the Material Guidelines
https://github.com/commit451/modalbottomsheetdialogfragment
android bottomsheet material-design material-guidelines
Last synced: 4 days ago
JSON representation
Modal bottom sheet dialog based on the Material Guidelines
- Host: GitHub
- URL: https://github.com/commit451/modalbottomsheetdialogfragment
- Owner: Commit451
- License: apache-2.0
- Created: 2018-02-16T03:42:03.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2023-02-07T06:22:04.000Z (almost 2 years ago)
- Last Synced: 2024-12-22T21:07:24.359Z (11 days ago)
- Topics: android, bottomsheet, material-design, material-guidelines
- Language: Kotlin
- Homepage: https://material.io/components/sheets-bottom
- Size: 454 KB
- Stars: 450
- Watchers: 12
- Forks: 36
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ModalBottomSheetDialogFragment
Modal bottom sheet dialog based on the [Material Guidelines](https://material.io/components/sheets-bottom)[![](https://jitpack.io/v/Commit451/ModalBottomSheetDialogFragment.svg)](https://jitpack.io/#Commit451/ModalBottomSheetDialogFragment)
## Dependency
Add this in your root `build.gradle` file (**not** your module `build.gradle` file):
```gradle
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```Then, add the library to your project `build.gradle`
```gradle
dependencies {
implementation("com.github.Commit451:ModalBottomSheetDialogFragment:latest.version.here")
}
```## Usage
`ModalBottomSheetDialogFragment`s are typically inflated via a menu item resource. The menu item resource defines the title, icon, and ID is of each `Option`. The menu item resource might looks something like this:
```xml
```
Use the builder to create and show the bottom sheet dialog:
```kotlin
ModalBottomSheetDialogFragment.Builder()
.add(R.menu.options)
.show(supportFragmentManager, "options")
```
Make sure that your `Activity` or `Fragment` implements `ModalBottomSheetDialogFragment.Listener`. For example:
```kotlin
override fun onModalOptionSelected(tag: String?, option: Option) {
when (option.id) {
R.id.action_edit -> {
// edit something
}
R.id.action_delete -> {
// delete something
}
}
Snackbar.make(root, "Selected option ${option.title} from fragment with tag $tag", Snackbar.LENGTH_SHORT)
.show()
}
```
You can also customize things to your liking:
```kotlin
ModalBottomSheetDialogFragment.Builder()
.add(R.menu.option_lots)
//custom option, without needing menu XML
.add(OptionRequest(123, "Custom", R.drawable.ic_bluetooth_black_24dp))
.layout(R.layout.item_custom)
.theme(R.style.CustomTheme)
.header("Neat")
.columns(3)
.show(supportFragmentManager, "custom")
```
See the sample app for more.License
--------Copyright 2022 Commit 451
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.