Tapping the toolbar now scrolls to the top of the controller

Or collaspes a bottom sheet
pull/3117/head
Jay 4 years ago
parent cd74c4d1ec
commit 770595bbd5

@ -863,6 +863,8 @@ class LibraryController(
}
}
override fun sheetIsExpanded(): Boolean = false
override fun handleSheetBack(): Boolean {
val sheetBehavior = BottomSheetBehavior.from(filter_bottom_sheet)
if (sheetBehavior.state != BottomSheetBehavior.STATE_COLLAPSED && sheetBehavior.state != BottomSheetBehavior.STATE_HIDDEN) {

@ -624,4 +624,5 @@ interface BottomSheetController {
fun showSheet()
fun toggleSheet()
fun handleSheetBack(): Boolean
fun sheetIsExpanded(): Boolean
}

@ -438,6 +438,9 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
else dl_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
}
override fun sheetIsExpanded(): Boolean = dl_bottom_sheet.sheetBehavior?.state ==
BottomSheetBehavior.STATE_EXPANDED
override fun expandSearch() {
if (showingDownloads) {
dl_bottom_sheet.dismiss()

@ -183,6 +183,9 @@ class SourceController : NucleusController<SourcePresenter>(),
}
}
override fun sheetIsExpanded(): Boolean = ext_bottom_sheet.sheetBehavior?.state ==
BottomSheetBehavior.STATE_EXPANDED
override fun handleSheetBack(): Boolean {
if (ext_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_COLLAPSED) {
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED

@ -16,9 +16,11 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import eu.kanade.tachiyomi.ui.main.BottomSheetController
import eu.kanade.tachiyomi.util.system.dpToPx
import kotlinx.android.synthetic.main.main_activity.*
import kotlin.math.abs
import kotlin.random.Random
fun Controller.setOnQueryTextChangeListener(
searchView: SearchView,
@ -70,6 +72,8 @@ fun Controller.scrollViewWith(
recycler.requestApplyInsets()
}
}
val randomTag = Random.nextLong()
recycler.doOnApplyWindowInsets { view, insets, _ ->
val headerHeight = insets.systemWindowInsetTop + appBarHeight
if (!customPadding) view.updatePaddingRelative(
@ -106,10 +110,21 @@ fun Controller.scrollViewWith(
changeType: ControllerChangeType
) {
super.onChangeStart(controller, changeHandler, changeType)
if (changeType.isEnter)
if (changeType.isEnter) {
elevateFunc(elevate)
else
activity!!.toolbar.tag = randomTag
activity!!.toolbar.setOnClickListener {
if ((this@scrollViewWith as? BottomSheetController)?.sheetIsExpanded() != true) {
recycler.scrollToPosition(0)
} else {
(this@scrollViewWith as? BottomSheetController)?.toggleSheet()
}
}
} else {
elevationAnim?.cancel()
if (activity!!.toolbar.tag == randomTag)
activity!!.toolbar.setOnClickListener(null)
}
}
})
elevateFunc(recycler.canScrollVertically(-1))

@ -42,8 +42,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<com.google.android.material.textview.MaterialTextView

Loading…
Cancel
Save