mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 19:51:50 +01:00
peek for filter bar now hides on expanding
This commit is contained in:
parent
24d592d999
commit
6973093ea1
@ -31,6 +31,7 @@ import eu.kanade.tachiyomi.util.view.marginBottom
|
||||
import eu.kanade.tachiyomi.util.view.marginTop
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.view.updatePadding
|
||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import kotlinx.android.synthetic.main.filter_bottom_sheet.view.*
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
@ -103,13 +104,14 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
topbar.setOnClickListener {
|
||||
if (sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED) {
|
||||
sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
topbar.animate().alpha(0f).setDuration(100).start()
|
||||
} else {
|
||||
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
}
|
||||
|
||||
sortText.alpha = if (sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED) 1f else 0f
|
||||
title.alpha = if (sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) 1f else 0f
|
||||
sortText.alpha = 1f
|
||||
title.alpha = 0f
|
||||
|
||||
pager = pagerView
|
||||
pager?.setPadding(0, 0, 0, topbar.height)
|
||||
@ -122,13 +124,14 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
progress < 0.1f -> 0f
|
||||
else -> progress
|
||||
}
|
||||
sortText.alpha = 1 - newProg
|
||||
title.alpha = newProg
|
||||
topbar.alpha = 1 - newProg
|
||||
}
|
||||
|
||||
override fun onStateChanged(p0: View, state: Int) {
|
||||
if (state == BottomSheetBehavior.STATE_COLLAPSED) reSortViews()
|
||||
else setMainSortText()
|
||||
topbar.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED
|
||||
topbar.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
})
|
||||
topbar.viewTreeObserver.addOnGlobalLayoutListener {
|
||||
@ -191,6 +194,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
val params = sortText.layoutParams as? MarginLayoutParams ?: return
|
||||
params.rightMargin = (if (downloading) 80 else 8).dpToPx
|
||||
sortText.layoutParams = params
|
||||
|
||||
filterScrollView.updatePaddingRelative(end = (if (downloading) 80 else 20).dpToPx)
|
||||
}
|
||||
|
||||
fun updateRootPadding(progress: Float? = null) {
|
||||
|
@ -13,58 +13,16 @@
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/topbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="?android:attr/colorPrimary"
|
||||
android:background="@drawable/bg_bottom_sheet_dialog_fragment">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:src="@drawable/ic_sort_white_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/sortText"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/sortText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sortText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="@string/filter_and_sort"
|
||||
android:textAlignment="textStart"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
android:textColor="?attr/actionBarTintColor"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView2"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Filter & Sort"
|
||||
android:textAlignment="textStart"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
android:textColor="?attr/actionBarTintColor"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/sortText"
|
||||
app:layout_constraintEnd_toEndOf="@+id/sortText"
|
||||
app:layout_constraintStart_toStartOf="@+id/sortText"
|
||||
app:layout_constraintTop_toTopOf="@+id/sortText" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="match_parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
@ -196,4 +154,57 @@
|
||||
</HorizontalScrollView>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/topbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_bottom_sheet_dialog_fragment"
|
||||
android:backgroundTint="?android:attr/colorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:src="@drawable/ic_sort_white_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/sortText"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/sortText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sortText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="@string/filter_and_sort"
|
||||
android:textAlignment="textStart"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
android:textColor="?attr/actionBarTintColor"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/imageView2"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Filter & Sort"
|
||||
android:textAlignment="textStart"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
android:textColor="?attr/actionBarTintColor"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/sortText"
|
||||
app:layout_constraintEnd_toEndOf="@+id/sortText"
|
||||
app:layout_constraintStart_toStartOf="@+id/sortText"
|
||||
app:layout_constraintTop_toTopOf="@+id/sortText" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet>
|
Loading…
Reference in New Issue
Block a user