More bottom sheet improvements (#5183)
* Edge-to-edge bottom sheet when possible * ReaderSettingsSheet: Animate background dim changes * Adjust modal bottom sheet in-out animation * Use public method to get bottom sheet behavior * Set bottom sheet peek size to 50% screen height The current auto peek height gives too low value on landscape orientation * Set bottom sheet navigation bar scrim when needed
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.setting
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.os.Bundle
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import eu.kanade.tachiyomi.R
|
||||
@@ -16,13 +17,21 @@ class ReaderSettingsSheet(
|
||||
private val generalSettings = ReaderGeneralSettings(activity)
|
||||
private val colorFilterSettings = ReaderColorFilterSettings(activity)
|
||||
|
||||
private val backgroundDimAnimator by lazy {
|
||||
val sheetBackgroundDim = window?.attributes?.dimAmount ?: 0.25f
|
||||
ValueAnimator.ofFloat(sheetBackgroundDim, 0f).also { valueAnimator ->
|
||||
valueAnimator.duration = 250
|
||||
valueAnimator.addUpdateListener {
|
||||
window?.setDimAmount(it.animatedValue as Float)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
sheetBehavior.isFitToContents = false
|
||||
sheetBehavior.halfExpandedRatio = 0.25f
|
||||
|
||||
val sheetBackgroundDim = window?.attributes?.dimAmount ?: 0.25f
|
||||
behavior.isFitToContents = false
|
||||
behavior.halfExpandedRatio = 0.25f
|
||||
|
||||
val filterTabIndex = getTabViews().indexOf(colorFilterSettings)
|
||||
binding.tabs.addOnTabSelectedListener(object : SimpleTabSelectedListener() {
|
||||
@@ -30,7 +39,15 @@ class ReaderSettingsSheet(
|
||||
val isFilterTab = tab?.position == filterTabIndex
|
||||
|
||||
// Remove dimmed backdrop so color filter changes can be previewed
|
||||
window?.setDimAmount(if (isFilterTab) 0f else sheetBackgroundDim)
|
||||
backgroundDimAnimator.run {
|
||||
if (isFilterTab) {
|
||||
if (animatedFraction < 1f) {
|
||||
start()
|
||||
}
|
||||
} else if (animatedFraction > 0f) {
|
||||
reverse()
|
||||
}
|
||||
}
|
||||
|
||||
// Hide toolbars
|
||||
if (activity.menuVisible != !isFilterTab) {
|
||||
|
||||
Reference in New Issue
Block a user