From a3f210dbf02b3373dde63a18c38b878c1b226c98 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sat, 10 Jul 2021 13:28:31 -0400 Subject: [PATCH] Lighten shadows on bottom sheets in controllers --- .../ui/library/filter/FilterBottomSheet.kt | 10 ++++++---- .../tachiyomi/ui/recents/RecentsController.kt | 18 ++++++++++-------- .../tachiyomi/ui/source/BrowseController.kt | 12 +++++++----- app/src/main/res/layout/browse_controller.xml | 4 ++-- app/src/main/res/layout/library_controller.xml | 4 ++-- app/src/main/res/layout/recents_controller.xml | 4 ++-- 6 files changed, 29 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt index d742470886..d22f3402a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt @@ -96,6 +96,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri var libraryRecyler: View? = null var controller: LibraryController? = null var bottomBarHeight = 0 + val shadowAlpha = 0.15f + val shadow2Alpha = 0.05f override fun onFinishInflate() { super.onFinishInflate() @@ -122,8 +124,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri override fun onSlide(bottomSheet: View, progress: Float) { this@FilterBottomSheet.controller?.updateFilterSheetY() binding.pill.alpha = (1 - max(0f, progress)) * 0.25f - shadow2.alpha = (1 - max(0f, progress)) * 0.25f - shadow.alpha = 1 + min(0f, progress) + shadow2.alpha = (1 - max(0f, progress)) * shadow2Alpha + shadow.alpha = (1 + min(0f, progress)) * shadowAlpha updateRootPadding(progress) } @@ -159,7 +161,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri else -> 0f } ) - shadow.alpha = if (sheetBehavior.isHidden()) 0f else 1f + shadow.alpha = if (sheetBehavior.isHidden()) 0f else shadowAlpha if (binding.secondLayout.width + (binding.groupBy.width * 2) + 20.dpToPx < width) { binding.secondLayout.removeView(binding.viewOptions) @@ -191,7 +193,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri val shadow = controller?.binding?.shadow ?: return controller?.updateHopperY() if (state == BottomSheetBehavior.STATE_COLLAPSED) { - shadow.alpha = 1f + shadow.alpha = shadowAlpha libraryRecyler?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0 + 10.dpToPx + bottomBarHeight) } if (state == BottomSheetBehavior.STATE_EXPANDED) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt index 90ce20e9d0..ac72b7e660 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recents/RecentsController.kt @@ -106,6 +106,8 @@ class RecentsController(bundle: Bundle? = null) : private var lastChapterId: Long? = null private var showingDownloads = false var headerHeight = 0 + val shadowAlpha = 0.15f + val shadow2Alpha = 0.05f private var query = "" set(value) { field = value @@ -195,8 +197,8 @@ class RecentsController(bundle: Bundle? = null) : (activity as? MainActivity)?.showTabBar(show = false, animate = false) } val isCollapsed = binding.downloadBottomSheet.root.sheetBehavior.isCollapsed() - binding.shadow2.alpha = if (isCollapsed) 0.25f else 0f - binding.shadow.alpha = if (isCollapsed) 0.5f else 0f + binding.shadow2.alpha = if (isCollapsed) shadow2Alpha else 0f + binding.shadow.alpha = if (isCollapsed) shadowAlpha else 0f binding.fakeAppBar.alpha = if (isExpanded) 1f else 0f binding.downloadBottomSheet.dlRecycler.alpha = isExpanded.toInt().toFloat() binding.downloadBottomSheet.sheetLayout.backgroundTintList = ColorStateList.valueOf( @@ -219,16 +221,16 @@ class RecentsController(bundle: Bundle? = null) : binding.downloadBottomSheet.dlBottomSheet.onCreate(this) binding.shadow2.alpha = - if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) 0.25f else 0f + if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) shadow2Alpha else 0f binding.shadow.alpha = - if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) 0.5f else 0f + if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) shadowAlpha else 0f binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.addBottomSheetCallback( object : BottomSheetBehavior.BottomSheetCallback() { override fun onSlide(bottomSheet: View, progress: Float) { - binding.shadow2.alpha = (1 - abs(progress)) * 0.25f - binding.shadow.alpha = (1 - abs(progress)) * 0.5f + binding.shadow2.alpha = (1 - abs(progress)) * shadow2Alpha + binding.shadow.alpha = (1 - abs(progress)) * shadowAlpha val height = binding.root.height - binding.downloadBottomSheet.dlRecycler.paddingTop // Doing some fun math to hide the tab bar just as the title text of the @@ -315,9 +317,9 @@ class RecentsController(bundle: Bundle? = null) : } if (state == BottomSheetBehavior.STATE_HIDDEN || state == BottomSheetBehavior.STATE_COLLAPSED) { binding.shadow2.alpha = - if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.25f else 0f + if (state == BottomSheetBehavior.STATE_COLLAPSED) shadow2Alpha else 0f binding.shadow.alpha = - if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.5f else 0f + if (state == BottomSheetBehavior.STATE_COLLAPSED) shadowAlpha else 0f } binding.downloadBottomSheet.sheetLayout.isClickable = diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt index bb74451d56..bdfacbb502 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/BrowseController.kt @@ -94,6 +94,8 @@ class BrowseController : var showingExtensions = false var snackbar: Snackbar? = null + val shadowAlpha = 0.15f + val shadow2Alpha = 0.05f /** * Called when controller is initialized. @@ -154,7 +156,7 @@ class BrowseController : bottom = (activityBinding?.bottomNav?.height ?: 0) + 58.spToPx ) val isCollapsed = binding.bottomSheet.root.sheetBehavior.isCollapsed() - binding.shadow.alpha = if (isCollapsed) 0.5f else 0f + binding.shadow.alpha = if (isCollapsed) shadowAlpha else 0f updateTitleAndMenu() } @@ -162,14 +164,14 @@ class BrowseController : binding.bottomSheet.root.onCreate(this) binding.shadow.alpha = - if (binding.bottomSheet.root.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) 0.5f else 0f + if (binding.bottomSheet.root.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) shadowAlpha else 0f binding.bottomSheet.root.sheetBehavior?.addBottomSheetCallback( object : BottomSheetBehavior .BottomSheetCallback() { override fun onSlide(bottomSheet: View, progress: Float) { - binding.shadow2.alpha = (1 - max(0f, progress)) * 0.25f - binding.shadow.alpha = (1 - abs(progress)) * 0.5f + binding.shadow2.alpha = (1 - max(0f, progress)) * shadow2Alpha + binding.shadow.alpha = (1 - abs(progress)) * shadowAlpha activityBinding?.appBar?.y = max(activityBinding!!.appBar.y, -headerHeight * (1 - progress)) val oldShow = showingExtensions showingExtensions = progress > 0.92f @@ -203,7 +205,7 @@ class BrowseController : if (state == BottomSheetBehavior.STATE_EXPANDED || state == BottomSheetBehavior.STATE_COLLAPSED) { binding.shadow.alpha = - if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.5f else 0f + if (state == BottomSheetBehavior.STATE_COLLAPSED) shadowAlpha else 0f } retainViewMode = if (state == BottomSheetBehavior.STATE_EXPANDED) { diff --git a/app/src/main/res/layout/browse_controller.xml b/app/src/main/res/layout/browse_controller.xml index c8cee122cf..368b5c506f 100644 --- a/app/src/main/res/layout/browse_controller.xml +++ b/app/src/main/res/layout/browse_controller.xml @@ -25,7 +25,7 @@ android:id="@+id/shadow" android:layout_width="match_parent" android:layout_height="24dp" - android:alpha="0.5" + android:alpha="0.15" android:background="@drawable/shape_gradient_top_shadow" android:paddingBottom="10dp" app:layout_anchorGravity="top" @@ -39,6 +39,6 @@ android:layout_width="match_parent" android:layout_height="8dp" android:layout_gravity="bottom" - android:alpha="0.25" + android:alpha="0.05" android:background="@drawable/shape_gradient_top_shadow" /> diff --git a/app/src/main/res/layout/library_controller.xml b/app/src/main/res/layout/library_controller.xml index 46b08fe304..ab4fe4a3b2 100644 --- a/app/src/main/res/layout/library_controller.xml +++ b/app/src/main/res/layout/library_controller.xml @@ -105,7 +105,7 @@ android:id="@+id/shadow" android:layout_width="match_parent" android:layout_height="24dp" - android:alpha="0.5" + android:alpha="0.15" android:background="@drawable/shape_gradient_top_shadow" android:paddingBottom="10dp" app:layout_anchor="@id/filter_bottom_sheet" @@ -143,6 +143,6 @@ android:layout_width="match_parent" android:layout_height="8dp" android:layout_gravity="bottom" - android:alpha="0.25" + android:alpha="0.05" android:background="@drawable/shape_gradient_top_shadow" /> \ No newline at end of file diff --git a/app/src/main/res/layout/recents_controller.xml b/app/src/main/res/layout/recents_controller.xml index 4cc154fd8a..952b7ddf82 100644 --- a/app/src/main/res/layout/recents_controller.xml +++ b/app/src/main/res/layout/recents_controller.xml @@ -45,7 +45,7 @@ android:id="@+id/shadow" android:layout_width="match_parent" android:layout_height="24dp" - android:alpha="0.5" + android:alpha="0.15" android:background="@drawable/shape_gradient_top_shadow" android:paddingBottom="10dp" app:layout_anchor="@id/download_bottom_sheet" @@ -69,6 +69,6 @@ android:layout_width="match_parent" android:layout_height="8dp" android:layout_gravity="bottom" - android:alpha="0.25" + android:alpha="0.05" android:background="@drawable/shape_gradient_top_shadow" />