mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 20:15:05 +01:00
Added fab to library controller
This commit is contained in:
parent
cb599704a9
commit
e23973cc9c
@ -83,11 +83,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
updateTitle()
|
||||
sheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||
val minHeight = sheetBehavior.peekHeight
|
||||
val maxHeight = bottomSheet.height
|
||||
val percent = (progress * 100).roundToInt()
|
||||
val value = (percent * (maxHeight - minHeight) / 100) + minHeight
|
||||
pager?.setPadding(0, 0, 0, value)
|
||||
updateRootPadding()
|
||||
sortText.alpha = 1 - progress
|
||||
title.alpha = progress
|
||||
//line.alpha = 1 - progress
|
||||
@ -102,6 +98,9 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
if (sheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
pager?.setPadding(0, 0, 0, topbar.height)
|
||||
}
|
||||
else {
|
||||
updateRootPadding()
|
||||
}
|
||||
}
|
||||
createTags()
|
||||
}
|
||||
@ -135,6 +134,16 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
}
|
||||
}
|
||||
|
||||
fun updateRootPadding() {
|
||||
val sheetBehavior = BottomSheetBehavior.from(this)
|
||||
val minHeight = sheetBehavior.peekHeight
|
||||
val maxHeight = height
|
||||
val percent = ((if (sheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) 1f else 0f)
|
||||
* 100).roundToInt()
|
||||
val value = (percent * (maxHeight - minHeight) / 100) + minHeight
|
||||
pager?.setPadding(0, 0, 0, value)
|
||||
}
|
||||
|
||||
fun sorting(): Int {
|
||||
return if (lastCategory != null && preferences.showCategories().getOrDefault()) {
|
||||
when (lastCategory?.mangaSort) {
|
||||
|
@ -43,6 +43,7 @@ import eu.kanade.tachiyomi.ui.base.controller.SecondaryDrawerController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.category.CategoryController
|
||||
import eu.kanade.tachiyomi.ui.download.DownloadController
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
||||
@ -221,6 +222,10 @@ class LibraryController(
|
||||
FilterBottomSheet.ACTION_BADGE -> onDownloadBadgeChanged()
|
||||
}
|
||||
}
|
||||
|
||||
fab.setOnClickListener {
|
||||
router.pushController(DownloadController().withFadeTransaction())
|
||||
}
|
||||
}
|
||||
|
||||
fun enableReorderItems(category: Category) {
|
||||
|
@ -667,26 +667,17 @@ open class MainActivity : BaseActivity() {
|
||||
|
||||
fun setDownloadBadge(downloading: Boolean) {
|
||||
if (!bottomNav) return
|
||||
val badge = bottomNavView?.getOrCreateBadge(R.id.nav_drawer_settings) ?: return
|
||||
val downloadManager = Injekt.get<DownloadManager>()
|
||||
val hasQueue = downloading || downloadManager.hasQueue()
|
||||
if (hasQueue) {
|
||||
val badge = bottomNavView?.getOrCreateBadge(R.id.nav_drawer_library)
|
||||
?: return
|
||||
badge.clearNumber()
|
||||
badge.backgroundColor = bottomNavView?.context?.getResourceColor(R.attr
|
||||
.badgeColor) ?: Color.BLACK
|
||||
}
|
||||
else
|
||||
{
|
||||
val updates = Injekt.get<PreferencesHelper>().extensionUpdatesCount().getOrDefault()
|
||||
if (updates > 0) {
|
||||
badge.number = updates
|
||||
badge.backgroundColor = bottomNavView?.context?.getResourceColor(R.attr
|
||||
.badgeColor) ?: Color.BLACK
|
||||
badge.badgeTextColor = Color.WHITE
|
||||
}
|
||||
else {
|
||||
bottomNavView?.removeBadge(R.id.nav_drawer_settings)
|
||||
}
|
||||
else {
|
||||
bottomNavView?.removeBadge(R.id.nav_drawer_library)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,18 @@
|
||||
<!-- Adding bottom sheet after main content -->
|
||||
<include layout="@layout/filter_bottom_sheet" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_anchor="@id/bottom_sheet"
|
||||
app:layout_anchorGravity="end|top"
|
||||
android:backgroundTint="?attr/colorAccent"
|
||||
android:tint="@color/md_white_1000"
|
||||
app:tint="@color/md_white_1000"
|
||||
android:layout_margin="24dp"
|
||||
app:srcCompat="@drawable/ic_file_download_white_24dp"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/shadow2"
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user