ui: use targetstate more
Use targetState whenever making decisions on whether a certain sheet state change is valid. This is mostly for stylistic consistency and has no effect on UX.
This commit is contained in:
parent
abe4255986
commit
93d3e82140
1 changed files with 5 additions and 7 deletions
|
@ -149,7 +149,7 @@ class MainFragment :
|
||||||
logD("Configuring stacked bottom sheets")
|
logD("Configuring stacked bottom sheets")
|
||||||
unlikelyToBeNull(binding.queueHandleWrapper).setOnClickListener {
|
unlikelyToBeNull(binding.queueHandleWrapper).setOnClickListener {
|
||||||
if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED &&
|
if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED &&
|
||||||
queueSheetBehavior.state == BackportBottomSheetBehavior.STATE_COLLAPSED) {
|
queueSheetBehavior.targetState == BackportBottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
// Playback sheet is expanded and queue sheet is collapsed, we can expand it.
|
// Playback sheet is expanded and queue sheet is collapsed, we can expand it.
|
||||||
queueSheetBehavior.state = BackportBottomSheetBehavior.STATE_EXPANDED
|
queueSheetBehavior.state = BackportBottomSheetBehavior.STATE_EXPANDED
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,7 @@ class MainFragment :
|
||||||
val playbackSheetBehavior =
|
val playbackSheetBehavior =
|
||||||
binding.playbackSheet.coordinatorLayoutBehavior as PlaybackBottomSheetBehavior
|
binding.playbackSheet.coordinatorLayoutBehavior as PlaybackBottomSheetBehavior
|
||||||
|
|
||||||
if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_COLLAPSED) {
|
if (playbackSheetBehavior.targetState == BackportBottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
// Playback sheet is not expanded and not hidden, we can expand it.
|
// Playback sheet is not expanded and not hidden, we can expand it.
|
||||||
logD("Expanding playback sheet")
|
logD("Expanding playback sheet")
|
||||||
playbackSheetBehavior.state = BackportBottomSheetBehavior.STATE_EXPANDED
|
playbackSheetBehavior.state = BackportBottomSheetBehavior.STATE_EXPANDED
|
||||||
|
@ -424,9 +424,9 @@ class MainFragment :
|
||||||
val queueSheetBehavior =
|
val queueSheetBehavior =
|
||||||
(binding.queueSheet.coordinatorLayoutBehavior ?: return) as QueueBottomSheetBehavior
|
(binding.queueSheet.coordinatorLayoutBehavior ?: return) as QueueBottomSheetBehavior
|
||||||
if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED &&
|
if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED &&
|
||||||
queueSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED) {
|
queueSheetBehavior.targetState == BackportBottomSheetBehavior.STATE_EXPANDED) {
|
||||||
// Queue sheet and playback sheet is expanded, close the queue sheet so the
|
// Queue sheet and playback sheet is expanded, close the queue sheet so the
|
||||||
// playback panel can eb shown.
|
// playback panel can shown.
|
||||||
logD("Collapsing queue sheet")
|
logD("Collapsing queue sheet")
|
||||||
queueSheetBehavior.state = BackportBottomSheetBehavior.STATE_COLLAPSED
|
queueSheetBehavior.state = BackportBottomSheetBehavior.STATE_COLLAPSED
|
||||||
}
|
}
|
||||||
|
@ -436,7 +436,7 @@ class MainFragment :
|
||||||
val binding = requireBinding()
|
val binding = requireBinding()
|
||||||
val playbackSheetBehavior =
|
val playbackSheetBehavior =
|
||||||
binding.playbackSheet.coordinatorLayoutBehavior as PlaybackBottomSheetBehavior
|
binding.playbackSheet.coordinatorLayoutBehavior as PlaybackBottomSheetBehavior
|
||||||
if (playbackSheetBehavior.state == BackportBottomSheetBehavior.STATE_EXPANDED) {
|
if (playbackSheetBehavior.targetState == BackportBottomSheetBehavior.STATE_EXPANDED) {
|
||||||
// Playback sheet (and possibly queue) needs to be collapsed.
|
// Playback sheet (and possibly queue) needs to be collapsed.
|
||||||
logD("Collapsing playback and queue sheets")
|
logD("Collapsing playback and queue sheets")
|
||||||
val queueSheetBehavior =
|
val queueSheetBehavior =
|
||||||
|
@ -487,8 +487,6 @@ class MainFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use targetState more
|
|
||||||
|
|
||||||
private class SheetBackPressedCallback(
|
private class SheetBackPressedCallback(
|
||||||
private val playbackSheetBehavior: PlaybackBottomSheetBehavior<*>,
|
private val playbackSheetBehavior: PlaybackBottomSheetBehavior<*>,
|
||||||
private val queueSheetBehavior: QueueBottomSheetBehavior<*>?
|
private val queueSheetBehavior: QueueBottomSheetBehavior<*>?
|
||||||
|
|
Loading…
Reference in a new issue