Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

app.futured.hauler:databinding

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app.futured.hauler:databinding

Library with swipe to dismiss Activity gesture implementation.

  • 5.0.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

Hauler

Maven Central minSdk:21 Android Arsenal Publish Snapshot License

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.

Alt text

Installation

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.

maven { url "https://oss.sonatype.org/content/repositories/snapshots" }

Snapshots are grouped based on major version, so for version 4.x.x use:

implementation "app.futured.hauler:hauler:4.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:

<app.futured.hauler.HaulerView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/haulerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">
            
            <!-- your layout-->
            
    </androidx.core.widget.NestedScrollView>
</app.futured.hauler.HaulerView>

Secondly, define translucent floating Theme and assign it to the Activity you want to give dismiss ability:

<style name="AppTheme.Draggable" parent="Theme.AppCompat.Light.NoActionBar">
       <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>
</style>
<activity
        android:name=".draggable.SimpleUsageActivity"
        android:theme="@style/AppTheme.Draggable"/>

Set onDragDismissListener to react properly to user dismiss request. Example implementation might look like this:

    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:

<app.futured.hauler.HaulerView
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       app:dragDismissDistance="112dp"
       app:dragDismissFraction="0.9"
       app:dragElasticity="0.7"
       app:dragDismissScale="0.95"/>
Attribute nameTypeDefault valueDescription
app:dragDismissDistancedimen100dpDistance which should be View swiped to consider Activity as dismissed
app:dragDismissFractionfloatunspecified<0;1> - Fraction of View's height we should reach swiping to consider Activity as dismissed
app:dragElasticityfloat0.8<0;1> - Toughness of swipe. Higher value indicates more rigid feeling
app:dragDismissScalefloat0.95<0;1> - Scale factor of View while performing swipe action
app:dragUpEnabledbooleanfalseFlag indicating if drag up dismiss gesture is enabled
app:fadeSystemBarsbooleantrueFlag 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 for more information.

FAQs

Package last updated on 17 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc