More design fixes

Enabled filters now have white text
Using A10's back gesture to close the snackbar works properly now
This commit is contained in:
Jay 2020-02-08 21:49:44 -08:00
parent dc103acea2
commit 08dcd06d27
4 changed files with 33 additions and 19 deletions

View File

@ -101,7 +101,6 @@ class LibraryCategoryView @JvmOverloads constructor(context: Context, attrs: Att
swipe_refresh.addView(recycler) swipe_refresh.addView(recycler)
adapter.fastScroller = fast_scroller adapter.fastScroller = fast_scroller
if (!MainActivity.bottomNav) { if (!MainActivity.bottomNav) {
fast_scroller.addOnScrollStateChangeListener { fast_scroller.addOnScrollStateChangeListener {
controller.lockFilterBar(it) controller.lockFilterBar(it)

View File

@ -547,7 +547,7 @@ class LibraryController(
override fun handleBack(): Boolean { override fun handleBack(): Boolean {
val sheetBehavior = BottomSheetBehavior.from(bottom_sheet) val sheetBehavior = BottomSheetBehavior.from(bottom_sheet)
if (sheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) { if (sheetBehavior.state != BottomSheetBehavior.STATE_COLLAPSED) {
sheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED sheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
return true return true
} }
@ -570,12 +570,12 @@ class LibraryController(
R.id.action_search -> expandActionViewFromInteraction = true R.id.action_search -> expandActionViewFromInteraction = true
R.id.action_library_filter -> { R.id.action_library_filter -> {
if (MainActivity.bottomNav) { if (MainActivity.bottomNav) {
if (bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED) if (bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_COLLAPSED)
bottom_sheet.sheetBehavior?.state =
BottomSheetBehavior.STATE_EXPANDED
else
bottom_sheet.sheetBehavior?.state = bottom_sheet.sheetBehavior?.state =
BottomSheetBehavior.STATE_COLLAPSED BottomSheetBehavior.STATE_COLLAPSED
else
bottom_sheet.sheetBehavior?.state =
BottomSheetBehavior.STATE_EXPANDED
} }
else navView?.let { activity?.drawer?.openDrawer(GravityCompat.END) } else navView?.let { activity?.drawer?.openDrawer(GravityCompat.END) }
} }

View File

@ -1,12 +1,14 @@
package eu.kanade.tachiyomi.ui.library.filter package eu.kanade.tachiyomi.ui.library.filter
import android.content.Context import android.content.Context
import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.LinearLayout
import com.f2prateek.rx.preferences.Preference import com.f2prateek.rx.preferences.Preference
import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.filter_buttons.view.* import kotlinx.android.synthetic.main.filter_buttons.view.*
@ -81,7 +83,10 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
buttons.forEach { buttons.forEach {
it.isActivated = false it.isActivated = false
} }
for (i in 0 until itemCount) buttons[i].visible() for (i in 0 until itemCount) {
buttons[i].visible()
buttons[i].setTextColor(context.getResourceColor(android.R.attr.textColorPrimary))
}
for (i in 0 until (itemCount - 1)) separators[i].visible() for (i in 0 until (itemCount - 1)) separators[i].visible()
} }
@ -96,6 +101,8 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
} }
if (itemCount == 1) { if (itemCount == 1) {
firstButton.isActivated = !firstButton.isActivated firstButton.isActivated = !firstButton.isActivated
firstButton.setTextColor(if (firstButton.isActivated) Color.WHITE else context
.getResourceColor(android.R.attr.textColorPrimary))
listener?.onFilterClicked(this, if (firstButton.isActivated) index else -1, callBack) listener?.onFilterClicked(this, if (firstButton.isActivated) index else -1, callBack)
return return
} }
@ -122,6 +129,8 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
separator2.gone() separator2.gone()
} }
} }
mainButton.setTextColor(if (mainButton.isActivated) Color.WHITE else context
.getResourceColor(android.R.attr.textColorPrimary))
} }
} }

View File

@ -115,34 +115,40 @@ class SortFilterBottomSheet @JvmOverloads constructor(context: Context, attrs: A
val shadow2:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow2) val shadow2:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow2)
val shadow:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow) val shadow:View = (pagerView.parent as ViewGroup).findViewById(R.id.shadow)
val coordLayout:View = (pagerView.parent as ViewGroup).findViewById(R.id.snackbar_layout) val coordLayout:View = (pagerView.parent as ViewGroup).findViewById(R.id.snackbar_layout)
val phoneLandscape = (isLandscape() && !isTablet())
if (phoneLandscape)
shadow.alpha = 0f
sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onSlide(bottomSheet: View, progress: Float) { override fun onSlide(bottomSheet: View, progress: Float) {
top_bar.alpha = 1 - progress top_bar.alpha = 1 - progress
shadow2.alpha = (1 - progress) * 0.25f shadow2.alpha = (1 - progress) * 0.25f
if (phoneLandscape)
shadow.alpha = progress
updateRootPadding(progress) updateRootPadding(progress)
} }
override fun onStateChanged(p0: View, state: Int) { override fun onStateChanged(p0: View, state: Int) {
if (state == BottomSheetBehavior.STATE_COLLAPSED) reSortViews() if (state == BottomSheetBehavior.STATE_COLLAPSED) {
reSortViews()
if (phoneLandscape)
shadow.alpha = 0f
}
else setMainSortText() else setMainSortText()
if (state == BottomSheetBehavior.STATE_EXPANDED) if (state == BottomSheetBehavior.STATE_EXPANDED) {
top_bar.alpha = 0f top_bar.alpha = 0f
if (phoneLandscape)
shadow.alpha = 1f
}
top_bar.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED top_bar.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED
top_bar.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED top_bar.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED
} }
}) })
top_bar.viewTreeObserver.addOnGlobalLayoutListener { if (phoneLandscape && shadow2.visibility != View.GONE) {
val phoneLandscape = (isLandscape() && !isTablet())
sheetBehavior?.peekHeight = if (phoneLandscape) {
if (shadow2.visibility != View.GONE) {
shadow.gone()
shadow2.gone() shadow2.gone()
} }
0 top_bar.viewTreeObserver.addOnGlobalLayoutListener {
} sheetBehavior?.peekHeight = if (phoneLandscape) 0
else if (!title.text.isNullOrBlank()) { else if (!title.text.isNullOrBlank()) top_bar.height
top_bar.height
}
else 0 else 0
if (sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) { if (sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) {
val height = context.resources.getDimensionPixelSize(R.dimen.rounder_radius) val height = context.resources.getDimensionPixelSize(R.dimen.rounder_radius)