mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 04:59:17 +01:00
Option to hide bottom sheets in controller by swiping down the side nav
This commit is contained in:
parent
f2851f2549
commit
05cff20b71
@ -1529,13 +1529,22 @@ class LibraryController(
|
|||||||
//region sheet methods
|
//region sheet methods
|
||||||
override fun showSheet() {
|
override fun showSheet() {
|
||||||
closeTip()
|
closeTip()
|
||||||
|
val sheetBehavior = binding.filterBottomSheet.filterBottomSheet.sheetBehavior
|
||||||
when {
|
when {
|
||||||
binding.filterBottomSheet.filterBottomSheet.sheetBehavior.isHidden() -> binding.filterBottomSheet.filterBottomSheet.sheetBehavior?.collapse()
|
sheetBehavior.isHidden() -> sheetBehavior?.collapse()
|
||||||
!binding.filterBottomSheet.filterBottomSheet.sheetBehavior.isExpanded() -> binding.filterBottomSheet.filterBottomSheet.sheetBehavior?.expand()
|
!sheetBehavior.isExpanded() -> sheetBehavior?.expand()
|
||||||
else -> showDisplayOptions()
|
else -> showDisplayOptions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun hideSheet() {
|
||||||
|
val sheetBehavior = binding.filterBottomSheet.filterBottomSheet.sheetBehavior
|
||||||
|
when {
|
||||||
|
sheetBehavior.isExpanded() -> sheetBehavior?.collapse()
|
||||||
|
!sheetBehavior.isHidden() -> binding.filterBottomSheet.filterBottomSheet.sheetBehavior?.hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
closeTip()
|
closeTip()
|
||||||
when {
|
when {
|
||||||
|
@ -915,7 +915,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
|
|||||||
val diffX = e2.x - e1.x
|
val diffX = e2.x - e1.x
|
||||||
if (abs(diffX) <= abs(diffY)) {
|
if (abs(diffX) <= abs(diffY)) {
|
||||||
val sheetRect = Rect()
|
val sheetRect = Rect()
|
||||||
binding.bottomNav?.getGlobalVisibleRect(sheetRect)
|
nav.getGlobalVisibleRect(sheetRect)
|
||||||
if (sheetRect.contains(e1.x.toInt(), e1.y.toInt()) &&
|
if (sheetRect.contains(e1.x.toInt(), e1.y.toInt()) &&
|
||||||
abs(diffY) > Companion.SWIPE_THRESHOLD &&
|
abs(diffY) > Companion.SWIPE_THRESHOLD &&
|
||||||
abs(velocityY) > Companion.SWIPE_VELOCITY_THRESHOLD &&
|
abs(velocityY) > Companion.SWIPE_VELOCITY_THRESHOLD &&
|
||||||
@ -924,6 +924,15 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
|
|||||||
val bottomSheetController =
|
val bottomSheetController =
|
||||||
router.backstack.lastOrNull()?.controller as? BottomSheetController
|
router.backstack.lastOrNull()?.controller as? BottomSheetController
|
||||||
bottomSheetController?.showSheet()
|
bottomSheetController?.showSheet()
|
||||||
|
} else if (nav == binding.sideNav &&
|
||||||
|
sheetRect.contains(e1.x.toInt(), e1.y.toInt()) &&
|
||||||
|
abs(diffY) > Companion.SWIPE_THRESHOLD &&
|
||||||
|
abs(velocityY) > Companion.SWIPE_VELOCITY_THRESHOLD &&
|
||||||
|
diffY > 0
|
||||||
|
) {
|
||||||
|
val bottomSheetController =
|
||||||
|
router.backstack.lastOrNull()?.controller as? BottomSheetController
|
||||||
|
bottomSheetController?.hideSheet()
|
||||||
}
|
}
|
||||||
result = true
|
result = true
|
||||||
}
|
}
|
||||||
@ -981,6 +990,7 @@ interface FloatingSearchInterface {
|
|||||||
|
|
||||||
interface BottomSheetController {
|
interface BottomSheetController {
|
||||||
fun showSheet()
|
fun showSheet()
|
||||||
|
fun hideSheet()
|
||||||
fun toggleSheet()
|
fun toggleSheet()
|
||||||
fun handleSheetBack(): Boolean
|
fun handleSheetBack(): Boolean
|
||||||
fun sheetIsExpanded(): Boolean
|
fun sheetIsExpanded(): Boolean
|
||||||
|
@ -48,7 +48,9 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
|||||||
import eu.kanade.tachiyomi.util.system.spToPx
|
import eu.kanade.tachiyomi.util.system.spToPx
|
||||||
import eu.kanade.tachiyomi.util.system.toInt
|
import eu.kanade.tachiyomi.util.system.toInt
|
||||||
import eu.kanade.tachiyomi.util.view.activityBinding
|
import eu.kanade.tachiyomi.util.view.activityBinding
|
||||||
|
import eu.kanade.tachiyomi.util.view.collapse
|
||||||
import eu.kanade.tachiyomi.util.view.expand
|
import eu.kanade.tachiyomi.util.view.expand
|
||||||
|
import eu.kanade.tachiyomi.util.view.hide
|
||||||
import eu.kanade.tachiyomi.util.view.isCollapsed
|
import eu.kanade.tachiyomi.util.view.isCollapsed
|
||||||
import eu.kanade.tachiyomi.util.view.isExpanded
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
import eu.kanade.tachiyomi.util.view.requestFilePermissionsSafe
|
import eu.kanade.tachiyomi.util.view.requestFilePermissionsSafe
|
||||||
@ -742,6 +744,15 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun hideSheet() {
|
||||||
|
if (!isBindingInitialized) return
|
||||||
|
if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == true) {
|
||||||
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.hide()
|
||||||
|
} else {
|
||||||
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.collapse()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
if (showingDownloads) binding.downloadBottomSheet.dlBottomSheet.dismiss()
|
if (showingDownloads) binding.downloadBottomSheet.dlBottomSheet.dismiss()
|
||||||
else binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.expand()
|
else binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.expand()
|
||||||
|
@ -302,6 +302,11 @@ class BrowseController :
|
|||||||
binding.bottomSheet.root.sheetBehavior?.expand()
|
binding.bottomSheet.root.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun hideSheet() {
|
||||||
|
if (!isBindingInitialized) return
|
||||||
|
binding.bottomSheet.root.sheetBehavior?.collapse()
|
||||||
|
}
|
||||||
|
|
||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
if (!binding.bottomSheet.root.sheetBehavior.isCollapsed()) {
|
if (!binding.bottomSheet.root.sheetBehavior.isCollapsed()) {
|
||||||
binding.bottomSheet.root.sheetBehavior?.collapse()
|
binding.bottomSheet.root.sheetBehavior?.collapse()
|
||||||
|
Loading…
Reference in New Issue
Block a user