• Stars
    star
    434
  • Rank 100,274 (Top 2 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created about 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Library with swipe to dismiss Activity gesture implementation

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 5.x.x use:

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:

<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 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 for more information.

More Repositories

1

donut

Doughnut-like graph view capable of displaying multiple datasets with assignable colors
Kotlin
541
star
2

TFBubbleItUp

Custom view for writing tags, contacts and etc. - written in Swift
Swift
330
star
3

Sonar

Radar style view written in swift
Swift
129
star
4

arkitekt

Arkitekt is a set of architectural tools based on Android Architecture Components, which gives you a solid base to implement the concise, testable and solid application.
Kotlin
123
star
5

TFTransparentNavigationBar

Custom transition between controllers in UINavigationController that makes navigation bar transparent on specified controllers
Swift
46
star
6

sheet-happens

Gradle plugin for generating Android / KMP string resources from Google Spreadsheets.
Kotlin
45
star
7

arkitekt-kmm

KMM library for UseCase abstraction
Kotlin
44
star
8

iOS-templates

Templates for MVVM-C architecture
Makefile
32
star
9

FuntastyKit

A collection of Swift utilities and protocols used in our projects
Swift
30
star
10

MVVM-C-Example

Example project for MVVM-C architecture in Swift
Swift
29
star
11

infinity

[Deprecated] Infinite paginated RecyclerView scrolling
Java
27
star
12

kmp-futured-template

Template for creating Kotlin Multiplatform applications at Futured.
Kotlin
20
star
13

FTAPIKit

Declarative and generic REST API framework using Codable.
Swift
19
star
14

Engineering-Handbook

Best practices and guidelines for developing apps in Futured
15
star
15

Gutenberg

Tiny library for generating attributed string with emoticons as images
Shell
14
star
16

bitrise-step-apk-info

Ruby
11
star
17

CellKit

Table View and Collection View data source wrapper
Swift
10
star
18

FormStateKit

A Swift package for simple management of forms and their fields. Focused on SwiftUI.
Swift
9
star
19

FTPropertyWrappers

Property wrappers for User Defaults, Keychain, StoredSubject and synchronization.
Swift
8
star
20

TFTableDescriptor

iOS Library / Simple table descriptor with dynamic cell height support
Objective-C
6
star
21

taste

[Deprecated]
Java
6
star
22

LocationManager

Swift
6
star
23

danger

The Danger rules we use at @futuredapp
Ruby
6
star
24

tasting

Android UI Automator wrapper for human-like scenario testing
Kotlin
6
star
25

Monkey-Madness

Easy to use ADB monkey command line wrapper
Shell
6
star
26

bitrise-step-ipa-info

Ruby
5
star
27

Funtasty-iOS-Playbook

Conventions for writing iOS applications
4
star
28

Realm-Codegen

Code Generation of Realm model files in Swift using Sourcery
Swift
2
star
29

OpenAPI-Project-Template

Template for OpenAPI specifications
Makefile
2
star
30

android-project-template

Kotlin
2
star
31

dev-academy-ios

Swift
2
star
32

f-academy-project-android

Kotlin
2
star
33

android-project-template-compose

Kotlin
1
star
34

brmo2023-kmm-talk

Code for the "KMM: Shared Navigation -- Finding The Sweet Spot" talk presented at BrMo2023 & Betsys Mobile dev meetup 2023
Kotlin
1
star
35

FTLogKit

Yet another logging framework for Apple platforms
Swift
1
star
36

ui-test-examples

xcode ui test examples
Swift
1
star
37

SwiftMonkeys

Monkeys for UI automated testing. Also known as UI/Application Exerciser Monkey.
Objective-C
1
star
38

TFSlideControl

Swift
1
star
39

.github

1
star
40

FCodeWars

1
star
41

FTTestingKit

Mockups and async extension to XCTestCase
Swift
1
star
42

FuturedKit

SwiftUI state management tools, resources and views used by Futured.
Swift
1
star
43

iOS-project-template

Template for creating iOS projects we use @futuredapp.
Ruby
1
star