https://github.com/futuredapp/hauler
Library with swipe to dismiss Activity gesture implementation
https://github.com/futuredapp/hauler
activity android dragtodismiss swipetodismiss view
Last synced: about 1 year ago
JSON representation
Library with swipe to dismiss Activity gesture implementation
- Host: GitHub
- URL: https://github.com/futuredapp/hauler
- Owner: futuredapp
- License: mit
- Created: 2018-11-16T13:50:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-17T14:10:45.000Z (almost 4 years ago)
- Last Synced: 2025-03-28T22:49:45.388Z (about 1 year ago)
- Topics: activity, android, dragtodismiss, swipetodismiss, view
- Language: Kotlin
- Homepage:
- Size: 1.55 MB
- Stars: 437
- Watchers: 7
- Forks: 19
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Hauler
[](https://search.maven.org/artifact/app.futured.hauler/hauler/)

[]( https://android-arsenal.com/details/1/7359 )


Hauler is an Android library containing custom layout which enables to easily create swipe to dismiss `Activity`.
Implementation is based on code from project [Plaid](https://github.com/nickbutcher/plaid).

# Installation
```groovy
dependencies {
implementation("app.futured.hauler:hauler:latestVersion")
// optional dependency with set of Data Binding adapters
implementation("app.futured.hauler:databinding:latestVersion")
}
```
### Snapshot installation
Add new maven repo to your top level gradle file.
```groovy
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
```
Snapshots are grouped based on major version, so for version 5.x.x use:
```groovy
implementation "app.futured.hauler:hauler:5.X.X-SNAPSHOT"
```
# Features
Hauler library comes with highly customizable `HaulerView` which provides swipe to dismiss functionality.
It also ships with `databinding` module which contains Binding Adapters for smoother experience with Android Data Binding implementation.
# Usage
Activity which is meant to be dismissed must contain `HaulerView` as a root view and `NestedScrollView` (or other `View` what supports nested scroll)
as its child. Make sure your `NestedScrollview`'s attribute `android:fillViewport` is set to `true` otherwise it might not behave as
expected:
```xml
```
Secondly, define translucent floating Theme and assign it to the Activity you want to give dismiss ability:
```xml
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/dark_gray</item>
```
```xml
```
Set `onDragDismissListener` to react properly to user dismiss request. Example implementation might look like this:
```kotlin
override fun onCreate(savedInstanceState: Bundle?) {
// ...
haulerView.setOnDragDismissedListener {
finish() // finish activity when dismissed
}
}
```
## Customization
There are few styleable attributes you might want to use to customize your `HaulerView`:
```xml
```
| Attribute name | Type | Default value | Description|
| -------------- | ---- | ------------- | ---------- |
| `app:dragDismissDistance` | dimen | 100dp | Distance which should be `View` swiped to consider Activity as dismissed |
| `app:dragDismissFraction` | float | unspecified | `<0;1>` - Fraction of `View`'s height we should reach swiping to consider Activity as dismissed |
| `app:dragElasticity` | float | 0.8 | `<0;1>` - Toughness of swipe. Higher value indicates more rigid feeling |
| `app:dragDismissScale` | float | 0.95 | `<0;1>` - Scale factor of `View` while performing swipe action |
| `app:dragUpEnabled` | boolean | false | Flag indicating if drag up dismiss gesture is enabled |
| `app:fadeSystemBars` | boolean | true | Flag indicating if system bars (status & navigation) fades while dismiss is in progress |
Attributes `dragDismissDistance` and `dragDismissFraction` are exclusive. Do not use them together.
# License
Hauler is available under the MIT license. See the [LICENSE file](LICENCE) for more information.