Skip to content

edtslib/swipebottomview

Repository files navigation

SwipeBottomView

SwipeBottomView

Setup

Gradle

Add this to your project level build.gradle:

allprojects {
 repositories {
    maven { url "https://jitpack.io" }
 }
}

Add this to your app build.gradle:

dependencies {
    implementation 'com.github.edtslib:swipebottomview:latest'
}

Usage

The SwipeBottomView is very easy to use. Just add it to your layout like any other view.

Via XML

Here's a basic implementation.

        <id.co.edts.emart.ui.baseview.swipeview.SwipeBottomView
        android:id="@+id/racks"
        app:title="@string/rack_near_by"
        app:content="@layout/view_rack_near_by_content"
        app:bottom="@layout/view_rack_near_by_bottom"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

Attributes information

An example is shown below.

        app:title="@string/rack_near_by"
        app:content="@layout/view_rack_near_by_content"
        app:bottom="@layout/view_rack_near_by_bottom"
        app:titleStyle="@style/TextStyle"
app:title

[string]: title of bottom view

app:content

[reference]: layout content for swipe view

app:bottom

[reference]: additional layout at bottom view, like button

app:titleStyle

[reference]: style of title text

Content and Bottom View

For access content and bottom view you can use getter SwipeBottomView

        val contentView = binding.racks.getContentView()
val adapter = RackAdapter()
val recyclerView = contentView?.findViewById(R.id.recyclerView) as
        SwipeRecyclerView

recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.adapter = adapter

val view = binding.emptyState.getBottomView()
view?.findViewById<View>(R.id.tvPositiveButton)?.setOnClickListener {
    QrCodeScannerActivity.open(this, scanResultLauncher)
}

Method for swipe actions on the SwipeBottomView

        binding.racks.delegate = object : SwipeViewDelegate {
    // y: top op SwipeBottomView
    override fun onMove(y: Float) {
        binding.actionBar.isVisible = y <= 0
    }
}