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'
}
The SwipeBottomView is very easy to use. Just add it to your layout like any other view.
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" />
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"
[string]: title of bottom view
[reference]: layout content for swipe view
[reference]: additional layout at bottom view, like button
[reference]: style of title text
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)
}
binding.racks.delegate = object : SwipeViewDelegate {
// y: top op SwipeBottomView
override fun onMove(y: Float) {
binding.actionBar.isVisible = y <= 0
}
}