mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-13 00:05:08 +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()
|
updateTitle()
|
||||||
sheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
sheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||||
val minHeight = sheetBehavior.peekHeight
|
updateRootPadding()
|
||||||
val maxHeight = bottomSheet.height
|
|
||||||
val percent = (progress * 100).roundToInt()
|
|
||||||
val value = (percent * (maxHeight - minHeight) / 100) + minHeight
|
|
||||||
pager?.setPadding(0, 0, 0, value)
|
|
||||||
sortText.alpha = 1 - progress
|
sortText.alpha = 1 - progress
|
||||||
title.alpha = progress
|
title.alpha = progress
|
||||||
//line.alpha = 1 - progress
|
//line.alpha = 1 - progress
|
||||||
@ -102,6 +98,9 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
if (sheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (sheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
pager?.setPadding(0, 0, 0, topbar.height)
|
pager?.setPadding(0, 0, 0, topbar.height)
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
updateRootPadding()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
createTags()
|
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 {
|
fun sorting(): Int {
|
||||||
return if (lastCategory != null && preferences.showCategories().getOrDefault()) {
|
return if (lastCategory != null && preferences.showCategories().getOrDefault()) {
|
||||||
when (lastCategory?.mangaSort) {
|
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.TabbedController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.category.CategoryController
|
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.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
import eu.kanade.tachiyomi.ui.migration.MigrationController
|
||||||
@ -221,6 +222,10 @@ class LibraryController(
|
|||||||
FilterBottomSheet.ACTION_BADGE -> onDownloadBadgeChanged()
|
FilterBottomSheet.ACTION_BADGE -> onDownloadBadgeChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fab.setOnClickListener {
|
||||||
|
router.pushController(DownloadController().withFadeTransaction())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enableReorderItems(category: Category) {
|
fun enableReorderItems(category: Category) {
|
||||||
|
@ -667,26 +667,17 @@ open class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
fun setDownloadBadge(downloading: Boolean) {
|
fun setDownloadBadge(downloading: Boolean) {
|
||||||
if (!bottomNav) return
|
if (!bottomNav) return
|
||||||
val badge = bottomNavView?.getOrCreateBadge(R.id.nav_drawer_settings) ?: return
|
|
||||||
val downloadManager = Injekt.get<DownloadManager>()
|
val downloadManager = Injekt.get<DownloadManager>()
|
||||||
val hasQueue = downloading || downloadManager.hasQueue()
|
val hasQueue = downloading || downloadManager.hasQueue()
|
||||||
if (hasQueue) {
|
if (hasQueue) {
|
||||||
|
val badge = bottomNavView?.getOrCreateBadge(R.id.nav_drawer_library)
|
||||||
|
?: return
|
||||||
badge.clearNumber()
|
badge.clearNumber()
|
||||||
badge.backgroundColor = bottomNavView?.context?.getResourceColor(R.attr
|
badge.backgroundColor = bottomNavView?.context?.getResourceColor(R.attr
|
||||||
.badgeColor) ?: Color.BLACK
|
.badgeColor) ?: Color.BLACK
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
bottomNavView?.removeBadge(R.id.nav_drawer_library)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,18 @@
|
|||||||
<!-- Adding bottom sheet after main content -->
|
<!-- Adding bottom sheet after main content -->
|
||||||
<include layout="@layout/filter_bottom_sheet" />
|
<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
|
<View
|
||||||
android:id="@+id/shadow2"
|
android:id="@+id/shadow2"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user