https://github.com/emanprague/bottom-sheet
Implementation of Google's Bottom Sheet which was modified to fully support two peek heights.
https://github.com/emanprague/bottom-sheet
android android-library bottomsheet java
Last synced: 3 months ago
JSON representation
Implementation of Google's Bottom Sheet which was modified to fully support two peek heights.
- Host: GitHub
- URL: https://github.com/emanprague/bottom-sheet
- Owner: eManPrague
- Created: 2018-08-29T07:30:26.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-27T08:06:59.000Z (over 6 years ago)
- Last Synced: 2024-12-29T15:26:34.275Z (over 1 year ago)
- Topics: android, android-library, bottomsheet, java
- Language: Kotlin
- Homepage:
- Size: 227 KB
- Stars: 3
- Watchers: 10
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Bottom Sheet with two peek heights
[  ](https://bintray.com/emanprague/maven/cz.eman.bottomsheet/1.0.0/link)
This repository contains implementation of Google's Bottom Sheet which was modified to fully support two peek heights.
## Contents
Repository consists of two modules:
- `app` - sample application which implements required interfaces
- `sheet` - library
## Quickstart
First of all add link `bottom-sheet` library to your project.
```groovy
// Gradle Kotlin DSL
implementation("cz.eman.bottomsheet:bottomsheet:1.0.0")
// Groovy
implementation 'cz.eman.bottomsheet:bottomsheet:1.0.0'
```
Now let's create a layout for our view. You will need:
- `background_container` - container which will contain fragment that sheet will overlap (probably map)
- `coordinator_layout` - do not forget to include id of layout or `CoordinatorLayout` will not restore instance state
- `bottom_sheet` - our sheet will inflate into this layout
- `sheet_container` - place sheet container here
Here's sample:
```xml
```
Then in your code initialize your sheet. You can do it manually, or you can use our handy `SheetHelper`.
By default you'll need to just specify two peek heights - collapsed (smaller) and semi-collapsed (bigger).
```kotlin
val helper = SheetsHelper.Builder(context = this, sheetView = this).apply {
setCollapsedHeight(resources.getDimensionPixelSize(R.dimen.sheet_collapsed_height))
setSemiCollapsedHeight(resources.getDimensionPixelSize(R.dimen.sheet_semicollapsed_height))
}.build()
```
Then just attach sheet with helper depending on your desires.
- `SheetHelper#init(View, BottomSheet)` - initializes with two collapsed states as defined in builder
- `SheetHelper#initSemiCollapsed(View, BottomSheet)` - initializes with only collapsed state (semi-collapsed) as defined in builder
- `SheetHelper#initCollapsed(View, BottomSheet)` - initializes with only collapsed state (collapsed) as defined in builder
```kotlin
helper.init(bottomSheet, behavior)
helper.initSemiCollapsed(bottomSheet, behavior)
helper.initCollapsed(bottomSheet, behavior)
```
Changing states is also really easy - image that your sheet now supports two collapsed states and you want to change it to just one bigger. No problem, call one of these:
```java
helper.animateToSemiCollapsed()
helper.restoreSemiCollapsedState()
```
Want to restore two collapsed states behaviour? Pick one of these:
```kotlin
helper.animateToTwoStates()
helper.restoreTwoStates()
```