Fully expand source filter sheet on show (closes #4455)

This commit is contained in:
arkon 2021-04-12 17:28:14 -04:00
parent 12e90ae35e
commit 99b46096a4
3 changed files with 19 additions and 28 deletions

View File

@ -5,6 +5,7 @@ import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import com.google.android.material.bottomsheet.BottomSheetBehavior
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.databinding.SourceFilterSheetBinding import eu.kanade.tachiyomi.databinding.SourceFilterSheetBinding
@ -17,10 +18,10 @@ class SourceFilterSheet(
onResetClicked: () -> Unit onResetClicked: () -> Unit
) : BaseBottomSheetDialog(activity) { ) : BaseBottomSheetDialog(activity) {
private var filterNavView: FilterNavigationView private var filterNavView: FilterNavigationView = FilterNavigationView(activity)
private val sheetBehavior: BottomSheetBehavior<*>
init { init {
filterNavView = FilterNavigationView(activity)
filterNavView.onFilterClicked = { filterNavView.onFilterClicked = {
onFilterClicked() onFilterClicked()
this.dismiss() this.dismiss()
@ -28,13 +29,23 @@ class SourceFilterSheet(
filterNavView.onResetClicked = onResetClicked filterNavView.onResetClicked = onResetClicked
setContentView(filterNavView) setContentView(filterNavView)
sheetBehavior = BottomSheetBehavior.from(filterNavView.parent as ViewGroup)
}
override fun show() {
super.show()
sheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
} }
fun setFilters(items: List<IFlexible<*>>) { fun setFilters(items: List<IFlexible<*>>) {
filterNavView.adapter.updateDataSet(items) filterNavView.adapter.updateDataSet(items)
} }
class FilterNavigationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : class FilterNavigationView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) :
SimpleNavigationView(context, attrs) { SimpleNavigationView(context, attrs) {
var onFilterClicked = {} var onFilterClicked = {}
@ -42,9 +53,12 @@ class SourceFilterSheet(
val adapter: FlexibleAdapter<IFlexible<*>> = FlexibleAdapter<IFlexible<*>>(null) val adapter: FlexibleAdapter<IFlexible<*>> = FlexibleAdapter<IFlexible<*>>(null)
.setDisplayHeadersAtStartUp(true) .setDisplayHeadersAtStartUp(true)
.setStickyHeaders(true)
private val binding = SourceFilterSheetBinding.inflate(LayoutInflater.from(context), null, false) private val binding = SourceFilterSheetBinding.inflate(
LayoutInflater.from(context),
null,
false
)
init { init {
recycler.adapter = adapter recycler.adapter = adapter

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/black"
android:pathData="M22.15,13.85H1.85A1.86,1.86,0,0,1,0,12H0a1.86,1.86,0,0,1,1.85-1.85H22.15A1.86,1.86,0,0,1,24,12h0A1.86,1.86,0,0,1,22.15,13.85Z" />
</vector>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
@ -15,19 +14,6 @@
android:paddingStart="?attr/listPreferredItemPaddingStart" android:paddingStart="?attr/listPreferredItemPaddingStart"
android:paddingEnd="?attr/listPreferredItemPaddingEnd"> android:paddingEnd="?attr/listPreferredItemPaddingEnd">
<ImageView
android:id="@+id/pull_up_bar"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:alpha="0.5"
android:scaleType="fitCenter"
android:src="@drawable/ic_drag_pill_24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="?attr/colorOnSurface"
tools:ignore="ContentDescription" />
<Button <Button
android:id="@+id/reset_btn" android:id="@+id/reset_btn"
style="@style/Theme.Widget.Button" style="@style/Theme.Widget.Button"