mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 15:39:08 +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)
|
preferences.lastUsedCategory().set(order)
|
||||||
activeCategory = order
|
activeCategory = order
|
||||||
setActiveCategory()
|
setActiveCategory()
|
||||||
if (presenter.categories.size > 1 && dy != 0) {
|
if (presenter.categories.size > 1 && dy != 0 && recyclerView.translationY == 0f) {
|
||||||
val headerItem = getHeader() ?: return
|
val headerItem = getHeader() ?: return
|
||||||
val view = fast_scroller ?: return
|
val view = fast_scroller ?: return
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ class LibraryController(
|
|||||||
}
|
}
|
||||||
category_recycler.onCategoryClicked = {
|
category_recycler.onCategoryClicked = {
|
||||||
scrollToHeader(it)
|
scrollToHeader(it)
|
||||||
showCategories(false)
|
showCategories(show = false, scroll = false)
|
||||||
}
|
}
|
||||||
category_recycler.onShowAllClicked = { isChecked ->
|
category_recycler.onShowAllClicked = { isChecked ->
|
||||||
preferences.showAllCategories().set(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.isClickable = show
|
||||||
recycler_cover.isFocusable = show
|
recycler_cover.isFocusable = show
|
||||||
val translateY = if (show) {
|
val full = category_layout.height.toFloat() + recycler.paddingTop
|
||||||
category_layout.height.toFloat() + recycler.paddingTop
|
val translateY = if (show) full else 0f
|
||||||
} else {
|
|
||||||
0f
|
|
||||||
}
|
|
||||||
recycler.animate().translationY(translateY).start()
|
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().translationY(translateY).start()
|
||||||
recycler_cover.animate().alpha(if (show) 0.75f else 0f).start()
|
recycler_cover.animate().alpha(if (show) 0.75f else 0f).start()
|
||||||
if (show) {
|
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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
<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">
|
<item android:id="@android:id/mask">
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners android:radius="4dp" />
|
<corners android:radius="4dp" />
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.google.android.material.textview.MaterialTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/category_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:layout_marginTop="2dp"
|
||||||
android:background="@drawable/list_item_selector">
|
android:layout_marginBottom="2dp"
|
||||||
|
android:background="@drawable/material_list_item_selector"
|
||||||
<com.google.android.material.textview.MaterialTextView
|
android:paddingStart="24dp"
|
||||||
android:id="@+id/category_text"
|
android:paddingTop="8dp"
|
||||||
android:layout_width="match_parent"
|
android:paddingEnd="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:paddingBottom="8dp"
|
||||||
android:background="@drawable/list_item_selector"
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
|
||||||
android:paddingStart="12dp"
|
android:textSize="16sp"
|
||||||
android:paddingTop="8dp"
|
tools:text="@string/categories" />
|
||||||
android:paddingEnd="0dp"
|
|
||||||
android:paddingBottom="8dp"
|
|
||||||
tools:text="@string/categories"
|
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
|
|
||||||
android:textSize="16sp" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
android:id="@+id/category_recycler"
|
android:id="@+id/category_recycler"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="4dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user