Fixed fab bottom margin
This commit is contained in:
parent
a83879dffb
commit
541a6fffe5
8 changed files with 36 additions and 13 deletions
|
@ -132,7 +132,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
val navbarHeight = RetroUtil.getNavigationBarHeight()
|
||||
updatePadding(bottom = navbarHeight)
|
||||
binding.bottomNavigationView.updateLayoutParams {
|
||||
height = dip(R.dimen.mini_player_height) + navbarHeight
|
||||
height = dip(R.dimen.bottom_nav_height) + navbarHeight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
|
||||
open fun onPanelExpanded() {
|
||||
if (nowPlayingScreen == Blur ) {
|
||||
if (nowPlayingScreen == Blur) {
|
||||
super.setLightStatusbar(false)
|
||||
} else {
|
||||
super.setLightStatusbarAuto(surfaceColor())
|
||||
|
@ -289,14 +289,12 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
fun hideBottomBar(hide: Boolean) {
|
||||
val heightOfBar = RetroUtil.getNavigationBarHeight() +
|
||||
if (MusicPlayerRemote.isCasting) dip(R.dimen.cast_mini_player_height) else dip(R.dimen.mini_player_height)
|
||||
val heightOfBarWithTabs = RetroUtil.getNavigationBarHeight() +
|
||||
if (MusicPlayerRemote.isCasting) dip(R.dimen.mini_cast_player_height_expanded) else dip(
|
||||
R.dimen.mini_player_height_expanded
|
||||
)
|
||||
val heightOfBarWithTabs = heightOfBar + dip(R.dimen.bottom_nav_height)
|
||||
val isVisible = binding.bottomNavigationView.isVisible
|
||||
if (hide) {
|
||||
bottomSheetBehavior.isHideable = true
|
||||
bottomSheetBehavior.peekHeight = 0
|
||||
libraryViewModel.setFabMargin(if (isVisible) dip(R.dimen.bottom_nav_height) else 0)
|
||||
ViewCompat.setElevation(binding.slidingPanel, 0f)
|
||||
ViewCompat.setElevation(binding.bottomNavigationView, 10f)
|
||||
collapsePanel()
|
||||
|
@ -310,9 +308,11 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
if (bottomSheetBehavior.state != STATE_EXPANDED)
|
||||
getBottomNavigationView().translateYAnimate(0F)
|
||||
bottomSheetBehavior.peekHeightAnimate(heightOfBarWithTabs)
|
||||
libraryViewModel.setFabMargin(heightOfBarWithTabs - RetroUtil.getNavigationBarHeight())
|
||||
} else {
|
||||
println("Details")
|
||||
bottomSheetBehavior.peekHeight = heightOfBar
|
||||
libraryViewModel.setFabMargin(heightOfBar - RetroUtil.getNavigationBarHeight())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.interfaces.IMusicServiceEventListener
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.repository.RealRepository
|
||||
import code.name.monkey.retromusic.util.DensityUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -40,6 +41,7 @@ class LibraryViewModel(
|
|||
private val legacyPlaylists = MutableLiveData<List<Playlist>>()
|
||||
private val genres = MutableLiveData<List<Genre>>()
|
||||
private val searchResults = MutableLiveData<List<Any>>()
|
||||
private val fabMargin = MutableLiveData(0)
|
||||
val paletteColor: LiveData<Int> = _paletteColor
|
||||
|
||||
init {
|
||||
|
@ -85,6 +87,10 @@ class LibraryViewModel(
|
|||
return home
|
||||
}
|
||||
|
||||
fun getFabMargin(): LiveData<Int> {
|
||||
return fabMargin
|
||||
}
|
||||
|
||||
private fun fetchSongs() {
|
||||
viewModelScope.launch(IO) {
|
||||
songs.postValue(repository.allSongs())
|
||||
|
@ -328,6 +334,14 @@ class LibraryViewModel(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setFabMargin(bottomMargin: Int) {
|
||||
fabMargin.postValue(
|
||||
// Normal Margin
|
||||
DensityUtil.dip2px(App.getContext(), 16F) +
|
||||
bottomMargin
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
enum class ReloadType {
|
||||
|
|
|
@ -22,6 +22,7 @@ import androidx.appcompat.widget.Toolbar
|
|||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -85,6 +86,11 @@ abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : Recycle
|
|||
} else {
|
||||
binding.shuffleButton.isVisible = false
|
||||
}
|
||||
libraryViewModel.getFabMargin().observe(viewLifecycleOwner, {
|
||||
binding.shuffleButton.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = it
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
open fun onShuffleClicked() {
|
||||
|
|
|
@ -52,7 +52,7 @@ class PlayingQueueFragment : AbsRecyclerViewFragment<PlayingQueueAdapter, Linear
|
|||
|
||||
private fun setupToolbar() {
|
||||
toolbar().apply {
|
||||
setOnClickListener {
|
||||
setNavigationOnClickListener {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
setNavigationIcon(R.drawable.ic_keyboard_backspace_black)
|
||||
|
|
|
@ -23,12 +23,10 @@ import android.speech.RecognizerIntent
|
|||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.CompoundButton
|
||||
import androidx.core.view.children
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.*
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.transition.TransitionManager
|
||||
|
@ -89,6 +87,11 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
view.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
}
|
||||
libraryViewModel.getFabMargin().observe(viewLifecycleOwner, {
|
||||
binding.keyboardPopup.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = it
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun setupChips() {
|
||||
|
|
|
@ -85,6 +85,5 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
app:srcCompat="@drawable/ic_shuffle"
|
||||
android:layout_marginBottom="116dp"
|
||||
android:layout_marginHorizontal="16dp"/>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -56,7 +56,7 @@
|
|||
<code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
||||
android:id="@+id/bottomNavigationView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:layout_height="@dimen/bottom_nav_height"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="?attr/colorSurface"
|
||||
android:elevation="0dp"
|
||||
|
|
|
@ -53,4 +53,5 @@
|
|||
<dimen name="indicator_radius">10dp</dimen>
|
||||
<dimen name="lyrics_dialog_radius">20dp</dimen>
|
||||
<dimen name="cast_mini_player_height">64dp</dimen>
|
||||
<dimen name="bottom_nav_height">56dp</dimen>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue