mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 20:01:53 +01:00
Lighten shadows on bottom sheets in controllers
This commit is contained in:
parent
05cff20b71
commit
a3f210dbf0
@ -96,6 +96,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
var libraryRecyler: View? = null
|
var libraryRecyler: View? = null
|
||||||
var controller: LibraryController? = null
|
var controller: LibraryController? = null
|
||||||
var bottomBarHeight = 0
|
var bottomBarHeight = 0
|
||||||
|
val shadowAlpha = 0.15f
|
||||||
|
val shadow2Alpha = 0.05f
|
||||||
|
|
||||||
override fun onFinishInflate() {
|
override fun onFinishInflate() {
|
||||||
super.onFinishInflate()
|
super.onFinishInflate()
|
||||||
@ -122,8 +124,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||||
this@FilterBottomSheet.controller?.updateFilterSheetY()
|
this@FilterBottomSheet.controller?.updateFilterSheetY()
|
||||||
binding.pill.alpha = (1 - max(0f, progress)) * 0.25f
|
binding.pill.alpha = (1 - max(0f, progress)) * 0.25f
|
||||||
shadow2.alpha = (1 - max(0f, progress)) * 0.25f
|
shadow2.alpha = (1 - max(0f, progress)) * shadow2Alpha
|
||||||
shadow.alpha = 1 + min(0f, progress)
|
shadow.alpha = (1 + min(0f, progress)) * shadowAlpha
|
||||||
updateRootPadding(progress)
|
updateRootPadding(progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +161,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
else -> 0f
|
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) {
|
if (binding.secondLayout.width + (binding.groupBy.width * 2) + 20.dpToPx < width) {
|
||||||
binding.secondLayout.removeView(binding.viewOptions)
|
binding.secondLayout.removeView(binding.viewOptions)
|
||||||
@ -191,7 +193,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
val shadow = controller?.binding?.shadow ?: return
|
val shadow = controller?.binding?.shadow ?: return
|
||||||
controller?.updateHopperY()
|
controller?.updateHopperY()
|
||||||
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
shadow.alpha = 1f
|
shadow.alpha = shadowAlpha
|
||||||
libraryRecyler?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0 + 10.dpToPx + bottomBarHeight)
|
libraryRecyler?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0 + 10.dpToPx + bottomBarHeight)
|
||||||
}
|
}
|
||||||
if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
|
@ -106,6 +106,8 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
private var lastChapterId: Long? = null
|
private var lastChapterId: Long? = null
|
||||||
private var showingDownloads = false
|
private var showingDownloads = false
|
||||||
var headerHeight = 0
|
var headerHeight = 0
|
||||||
|
val shadowAlpha = 0.15f
|
||||||
|
val shadow2Alpha = 0.05f
|
||||||
private var query = ""
|
private var query = ""
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
@ -195,8 +197,8 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
(activity as? MainActivity)?.showTabBar(show = false, animate = false)
|
(activity as? MainActivity)?.showTabBar(show = false, animate = false)
|
||||||
}
|
}
|
||||||
val isCollapsed = binding.downloadBottomSheet.root.sheetBehavior.isCollapsed()
|
val isCollapsed = binding.downloadBottomSheet.root.sheetBehavior.isCollapsed()
|
||||||
binding.shadow2.alpha = if (isCollapsed) 0.25f else 0f
|
binding.shadow2.alpha = if (isCollapsed) shadow2Alpha else 0f
|
||||||
binding.shadow.alpha = if (isCollapsed) 0.5f else 0f
|
binding.shadow.alpha = if (isCollapsed) shadowAlpha else 0f
|
||||||
binding.fakeAppBar.alpha = if (isExpanded) 1f else 0f
|
binding.fakeAppBar.alpha = if (isExpanded) 1f else 0f
|
||||||
binding.downloadBottomSheet.dlRecycler.alpha = isExpanded.toInt().toFloat()
|
binding.downloadBottomSheet.dlRecycler.alpha = isExpanded.toInt().toFloat()
|
||||||
binding.downloadBottomSheet.sheetLayout.backgroundTintList = ColorStateList.valueOf(
|
binding.downloadBottomSheet.sheetLayout.backgroundTintList = ColorStateList.valueOf(
|
||||||
@ -219,16 +221,16 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
binding.downloadBottomSheet.dlBottomSheet.onCreate(this)
|
binding.downloadBottomSheet.dlBottomSheet.onCreate(this)
|
||||||
|
|
||||||
binding.shadow2.alpha =
|
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 =
|
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(
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.addBottomSheetCallback(
|
||||||
object :
|
object :
|
||||||
BottomSheetBehavior.BottomSheetCallback() {
|
BottomSheetBehavior.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||||
binding.shadow2.alpha = (1 - abs(progress)) * 0.25f
|
binding.shadow2.alpha = (1 - abs(progress)) * shadow2Alpha
|
||||||
binding.shadow.alpha = (1 - abs(progress)) * 0.5f
|
binding.shadow.alpha = (1 - abs(progress)) * shadowAlpha
|
||||||
val height =
|
val height =
|
||||||
binding.root.height - binding.downloadBottomSheet.dlRecycler.paddingTop
|
binding.root.height - binding.downloadBottomSheet.dlRecycler.paddingTop
|
||||||
// Doing some fun math to hide the tab bar just as the title text of the
|
// 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) {
|
if (state == BottomSheetBehavior.STATE_HIDDEN || state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
binding.shadow2.alpha =
|
binding.shadow2.alpha =
|
||||||
if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.25f else 0f
|
if (state == BottomSheetBehavior.STATE_COLLAPSED) shadow2Alpha else 0f
|
||||||
binding.shadow.alpha =
|
binding.shadow.alpha =
|
||||||
if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.5f else 0f
|
if (state == BottomSheetBehavior.STATE_COLLAPSED) shadowAlpha else 0f
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.downloadBottomSheet.sheetLayout.isClickable =
|
binding.downloadBottomSheet.sheetLayout.isClickable =
|
||||||
|
@ -94,6 +94,8 @@ class BrowseController :
|
|||||||
var showingExtensions = false
|
var showingExtensions = false
|
||||||
|
|
||||||
var snackbar: Snackbar? = null
|
var snackbar: Snackbar? = null
|
||||||
|
val shadowAlpha = 0.15f
|
||||||
|
val shadow2Alpha = 0.05f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when controller is initialized.
|
* Called when controller is initialized.
|
||||||
@ -154,7 +156,7 @@ class BrowseController :
|
|||||||
bottom = (activityBinding?.bottomNav?.height ?: 0) + 58.spToPx
|
bottom = (activityBinding?.bottomNav?.height ?: 0) + 58.spToPx
|
||||||
)
|
)
|
||||||
val isCollapsed = binding.bottomSheet.root.sheetBehavior.isCollapsed()
|
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()
|
updateTitleAndMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,14 +164,14 @@ class BrowseController :
|
|||||||
binding.bottomSheet.root.onCreate(this)
|
binding.bottomSheet.root.onCreate(this)
|
||||||
|
|
||||||
binding.shadow.alpha =
|
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(
|
binding.bottomSheet.root.sheetBehavior?.addBottomSheetCallback(
|
||||||
object : BottomSheetBehavior
|
object : BottomSheetBehavior
|
||||||
.BottomSheetCallback() {
|
.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||||
binding.shadow2.alpha = (1 - max(0f, progress)) * 0.25f
|
binding.shadow2.alpha = (1 - max(0f, progress)) * shadow2Alpha
|
||||||
binding.shadow.alpha = (1 - abs(progress)) * 0.5f
|
binding.shadow.alpha = (1 - abs(progress)) * shadowAlpha
|
||||||
activityBinding?.appBar?.y = max(activityBinding!!.appBar.y, -headerHeight * (1 - progress))
|
activityBinding?.appBar?.y = max(activityBinding!!.appBar.y, -headerHeight * (1 - progress))
|
||||||
val oldShow = showingExtensions
|
val oldShow = showingExtensions
|
||||||
showingExtensions = progress > 0.92f
|
showingExtensions = progress > 0.92f
|
||||||
@ -203,7 +205,7 @@ class BrowseController :
|
|||||||
|
|
||||||
if (state == BottomSheetBehavior.STATE_EXPANDED || state == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (state == BottomSheetBehavior.STATE_EXPANDED || state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
binding.shadow.alpha =
|
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) {
|
retainViewMode = if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
android:id="@+id/shadow"
|
android:id="@+id/shadow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:alpha="0.5"
|
android:alpha="0.15"
|
||||||
android:background="@drawable/shape_gradient_top_shadow"
|
android:background="@drawable/shape_gradient_top_shadow"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
app:layout_anchorGravity="top"
|
app:layout_anchorGravity="top"
|
||||||
@ -39,6 +39,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="8dp"
|
android:layout_height="8dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:alpha="0.25"
|
android:alpha="0.05"
|
||||||
android:background="@drawable/shape_gradient_top_shadow" />
|
android:background="@drawable/shape_gradient_top_shadow" />
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
android:id="@+id/shadow"
|
android:id="@+id/shadow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:alpha="0.5"
|
android:alpha="0.15"
|
||||||
android:background="@drawable/shape_gradient_top_shadow"
|
android:background="@drawable/shape_gradient_top_shadow"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
app:layout_anchor="@id/filter_bottom_sheet"
|
app:layout_anchor="@id/filter_bottom_sheet"
|
||||||
@ -143,6 +143,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="8dp"
|
android:layout_height="8dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:alpha="0.25"
|
android:alpha="0.05"
|
||||||
android:background="@drawable/shape_gradient_top_shadow" />
|
android:background="@drawable/shape_gradient_top_shadow" />
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -45,7 +45,7 @@
|
|||||||
android:id="@+id/shadow"
|
android:id="@+id/shadow"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:alpha="0.5"
|
android:alpha="0.15"
|
||||||
android:background="@drawable/shape_gradient_top_shadow"
|
android:background="@drawable/shape_gradient_top_shadow"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
app:layout_anchor="@id/download_bottom_sheet"
|
app:layout_anchor="@id/download_bottom_sheet"
|
||||||
@ -69,6 +69,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="8dp"
|
android:layout_height="8dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:alpha="0.25"
|
android:alpha="0.05"
|
||||||
android:background="@drawable/shape_gradient_top_shadow" />
|
android:background="@drawable/shape_gradient_top_shadow" />
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
Loading…
Reference in New Issue
Block a user