home: hide fab when bottom sheet expands
This commit is contained in:
parent
a9b25e8f10
commit
ec5aca0b4c
2 changed files with 21 additions and 5 deletions
|
@ -208,12 +208,14 @@ class HomeFragment :
|
||||||
updateFabVisibility(
|
updateFabVisibility(
|
||||||
homeModel.songList.value,
|
homeModel.songList.value,
|
||||||
homeModel.isFastScrolling.value,
|
homeModel.isFastScrolling.value,
|
||||||
|
homeModel.sheetObscuresFab.value,
|
||||||
homeModel.currentTabType.value)
|
homeModel.currentTabType.value)
|
||||||
|
|
||||||
// --- VIEWMODEL SETUP ---
|
// --- VIEWMODEL SETUP ---
|
||||||
collect(homeModel.recreateTabs.flow, ::handleRecreate)
|
collect(homeModel.recreateTabs.flow, ::handleRecreate)
|
||||||
collectImmediately(homeModel.currentTabType, ::updateCurrentTab)
|
collectImmediately(homeModel.currentTabType, ::updateCurrentTab)
|
||||||
collectImmediately(homeModel.songList, homeModel.isFastScrolling, ::updateFab)
|
collectImmediately(
|
||||||
|
homeModel.songList, homeModel.isFastScrolling, homeModel.sheetObscuresFab, ::updateFab)
|
||||||
collect(homeModel.speedDialOpen, ::updateSpeedDial)
|
collect(homeModel.speedDialOpen, ::updateSpeedDial)
|
||||||
collect(detailModel.toShow.flow, ::handleShow)
|
collect(detailModel.toShow.flow, ::handleShow)
|
||||||
collect(listModel.menu.flow, ::handleMenu)
|
collect(listModel.menu.flow, ::handleMenu)
|
||||||
|
@ -373,7 +375,11 @@ class HomeFragment :
|
||||||
MusicType.PLAYLISTS -> R.id.home_playlist_recycler
|
MusicType.PLAYLISTS -> R.id.home_playlist_recycler
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFabVisibility(homeModel.songList.value, homeModel.isFastScrolling.value, tabType)
|
updateFabVisibility(
|
||||||
|
homeModel.songList.value,
|
||||||
|
homeModel.isFastScrolling.value,
|
||||||
|
homeModel.sheetObscuresFab.value,
|
||||||
|
tabType)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleRecreate(recreate: Unit?) {
|
private fun handleRecreate(recreate: Unit?) {
|
||||||
|
@ -408,6 +414,7 @@ class HomeFragment :
|
||||||
updateFabVisibility(
|
updateFabVisibility(
|
||||||
homeModel.songList.value,
|
homeModel.songList.value,
|
||||||
homeModel.isFastScrolling.value,
|
homeModel.isFastScrolling.value,
|
||||||
|
homeModel.sheetObscuresFab.value,
|
||||||
homeModel.currentTabType.value)
|
homeModel.currentTabType.value)
|
||||||
binding.homeIndexingContainer.visibility = View.INVISIBLE
|
binding.homeIndexingContainer.visibility = View.INVISIBLE
|
||||||
return
|
return
|
||||||
|
@ -553,20 +560,21 @@ class HomeFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFab(songs: List<Song>, isFastScrolling: Boolean) {
|
private fun updateFab(songs: List<Song>, isFastScrolling: Boolean, sheetRising: Boolean) {
|
||||||
updateFabVisibility(songs, isFastScrolling, homeModel.currentTabType.value)
|
updateFabVisibility(songs, isFastScrolling, sheetRising, homeModel.currentTabType.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFabVisibility(
|
private fun updateFabVisibility(
|
||||||
songs: List<Song>,
|
songs: List<Song>,
|
||||||
isFastScrolling: Boolean,
|
isFastScrolling: Boolean,
|
||||||
|
sheetRising: Boolean,
|
||||||
tabType: MusicType
|
tabType: MusicType
|
||||||
) {
|
) {
|
||||||
val binding = requireBinding()
|
val binding = requireBinding()
|
||||||
// If there are no songs, it's likely that the library has not been loaded, so
|
// If there are no songs, it's likely that the library has not been loaded, so
|
||||||
// displaying the shuffle FAB makes no sense. We also don't want the fast scroll
|
// displaying the shuffle FAB makes no sense. We also don't want the fast scroll
|
||||||
// popup to overlap with the FAB, so we hide the FAB when fast scrolling too.
|
// popup to overlap with the FAB, so we hide the FAB when fast scrolling too.
|
||||||
if (songs.isEmpty() || isFastScrolling) {
|
if (songs.isEmpty() || isFastScrolling || sheetRising) {
|
||||||
logD("Hiding fab: [empty: ${songs.isEmpty()} scrolling: $isFastScrolling]")
|
logD("Hiding fab: [empty: ${songs.isEmpty()} scrolling: $isFastScrolling]")
|
||||||
hideAllFabs()
|
hideAllFabs()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -160,6 +160,9 @@ constructor(
|
||||||
/** A marker for whether the speed dial is open or not. */
|
/** A marker for whether the speed dial is open or not. */
|
||||||
val speedDialOpen: StateFlow<Boolean> = _speedDialOpen
|
val speedDialOpen: StateFlow<Boolean> = _speedDialOpen
|
||||||
|
|
||||||
|
private val _sheetObscuresFab = MutableStateFlow(false)
|
||||||
|
val sheetObscuresFab: StateFlow<Boolean> = _sheetObscuresFab
|
||||||
|
|
||||||
private val _showOuter = MutableEvent<Outer>()
|
private val _showOuter = MutableEvent<Outer>()
|
||||||
val showOuter: Event<Outer>
|
val showOuter: Event<Outer>
|
||||||
get() = _showOuter
|
get() = _showOuter
|
||||||
|
@ -307,6 +310,11 @@ constructor(
|
||||||
_speedDialOpen.value = speedDialOpen
|
_speedDialOpen.value = speedDialOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setSheetRising(sheetRising: Boolean) {
|
||||||
|
logD("Updating sheet rising state: $sheetRising")
|
||||||
|
_sheetObscuresFab.value = sheetRising
|
||||||
|
}
|
||||||
|
|
||||||
fun showSettings() {
|
fun showSettings() {
|
||||||
_showOuter.put(Outer.Settings)
|
_showOuter.put(Outer.Settings)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue