mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 01:55:06 +01:00
MD2'ified the category list hopper
Also library recycler now scrolls a bit to match the padding when exposing the list
This commit is contained in:
parent
113107e05c
commit
1ef2c6e67c
@ -172,7 +172,7 @@ class LibraryController(
|
||||
preferences.lastUsedCategory().set(order)
|
||||
activeCategory = order
|
||||
setActiveCategory()
|
||||
if (presenter.categories.size > 1 && dy != 0) {
|
||||
if (presenter.categories.size > 1 && dy != 0 && recyclerView.translationY == 0f) {
|
||||
val headerItem = getHeader() ?: return
|
||||
val view = fast_scroller ?: return
|
||||
|
||||
@ -334,7 +334,7 @@ class LibraryController(
|
||||
}
|
||||
category_recycler.onCategoryClicked = {
|
||||
scrollToHeader(it)
|
||||
showCategories(false)
|
||||
showCategories(show = false, scroll = false)
|
||||
}
|
||||
category_recycler.onShowAllClicked = { isChecked ->
|
||||
preferences.showAllCategories().set(isChecked)
|
||||
@ -601,15 +601,29 @@ class LibraryController(
|
||||
}
|
||||
}
|
||||
|
||||
private fun showCategories(show: Boolean) {
|
||||
private fun showCategories(show: Boolean, scroll: Boolean = true) {
|
||||
recycler_cover.isClickable = show
|
||||
recycler_cover.isFocusable = show
|
||||
val translateY = if (show) {
|
||||
category_layout.height.toFloat() + recycler.paddingTop
|
||||
} else {
|
||||
0f
|
||||
}
|
||||
val full = category_layout.height.toFloat() + recycler.paddingTop
|
||||
val translateY = if (show) full else 0f
|
||||
recycler.animate().translationY(translateY).start()
|
||||
if (scroll) {
|
||||
// Smooth scroll the recycler to hide the hidden content blocked by the app bar
|
||||
ValueAnimator.ofInt(recycler.translationY.roundToInt(), translateY.roundToInt()).apply {
|
||||
var start = 0f
|
||||
var last = recycler.translationY.roundToInt()
|
||||
val distance = abs(recycler.translationY.roundToInt() - translateY.roundToInt())
|
||||
addUpdateListener {
|
||||
val diff = abs(it.animatedValue as Int - last)
|
||||
last = it.animatedValue as Int
|
||||
start += diff.toFloat() / distance * recycler.paddingTop.toFloat()
|
||||
if (start > 1) {
|
||||
recycler.scrollBy(0, start.toInt() * if (show) 1 else -1)
|
||||
start %= 1
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
recycler_cover.animate().translationY(translateY).start()
|
||||
recycler_cover.animate().alpha(if (show) 0.75f else 0f).start()
|
||||
if (show) {
|
||||
|
38
app/src/main/res/drawable/material_list_item_selector.xml
Normal file
38
app/src/main/res/drawable/material_list_item_selector.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/fullRippleColor">
|
||||
<item android:id="@android:id/mask"
|
||||
android:left="12dp"
|
||||
android:right="12dp">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<solid android:color="@color/fullRippleColor" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
android:left="12dp"
|
||||
android:right="12dp">
|
||||
<selector>
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<solid android:color="@color/rippleColor" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:state_activated="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<solid android:color="@color/fullRippleColor" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<solid android:color="?android:colorBackground" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
</item>
|
||||
</ripple>
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/gray_button">
|
||||
android:color="@color/fullRippleColor">
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
|
@ -1,20 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
<com.google.android.material.textview.MaterialTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@drawable/list_item_selector">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/category_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/list_item_selector"
|
||||
android:paddingStart="12dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:background="@drawable/material_list_item_selector"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingBottom="8dp"
|
||||
tools:text="@string/categories"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
|
||||
android:textSize="16sp" />
|
||||
</FrameLayout>
|
||||
android:textSize="16sp"
|
||||
tools:text="@string/categories" />
|
||||
|
@ -33,6 +33,7 @@
|
||||
android:id="@+id/category_recycler"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="4dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
Loading…
Reference in New Issue
Block a user