Added animation collapse when navigating to details
This commit is contained in:
parent
e9c1559c57
commit
c495c66a38
5 changed files with 42 additions and 22 deletions
|
@ -9,12 +9,13 @@ import android.widget.FrameLayout
|
|||
import androidx.annotation.LayoutRes
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.transition.TransitionManager
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.RetroBottomSheetBehavior
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.peekHeightAnimate
|
||||
import code.name.monkey.retromusic.extensions.translateXAnimate
|
||||
import code.name.monkey.retromusic.extensions.whichFragment
|
||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||
import code.name.monkey.retromusic.fragments.MiniPlayerFragment
|
||||
|
@ -217,7 +218,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
libraryViewModel.setPanelState(HIDE)
|
||||
} else {
|
||||
if (bottomNavigationView.isVisible) {
|
||||
libraryViewModel.setPanelState(EXPAND)
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITH)
|
||||
} else {
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITHOUT)
|
||||
}
|
||||
|
@ -301,12 +302,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun hideBottomNavigation() {
|
||||
behavior.isHideable = true
|
||||
behavior.peekHeight = 0
|
||||
hideBottomBarVisibility(false)
|
||||
}
|
||||
|
||||
fun updateTabs() {
|
||||
bottomNavigationView.menu.clear()
|
||||
val currentTabs: List<CategoryInfo> = PreferenceUtil.libraryCategory
|
||||
|
@ -330,6 +325,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
|
||||
private fun updatePanelState() {
|
||||
libraryViewModel.panelState.observe(this, { state ->
|
||||
val isQueueEmpty = MusicPlayerRemote.playingQueue.isEmpty()
|
||||
when (state) {
|
||||
EXPAND -> {
|
||||
println("EXPAND")
|
||||
|
@ -337,32 +333,29 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
HIDE -> {
|
||||
println("HIDE")
|
||||
behavior.isHideable = true
|
||||
behavior.peekHeight = 0
|
||||
collapsePanel()
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
behavior.isHideable = true
|
||||
behavior.peekHeightAnimate(0)
|
||||
collapsePanel()
|
||||
}
|
||||
COLLAPSED_WITH -> {
|
||||
println("COLLAPSED_WITH")
|
||||
TransitionManager.beginDelayedTransition(mainContent)
|
||||
bottomNavigationView.isVisible = true
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
ViewCompat.setElevation(slidingPanel, 10f)
|
||||
behavior.isHideable = false
|
||||
behavior.peekHeight = (heightOfBar * 2) - 24
|
||||
behavior.peekHeightAnimate(if(isQueueEmpty) 0 else (heightOfBar * 2) - 24)
|
||||
bottomNavigationView.translateXAnimate(0f)
|
||||
}
|
||||
COLLAPSED_WITHOUT -> {
|
||||
println("COLLAPSED_WITHOUT")
|
||||
TransitionManager.beginDelayedTransition(mainContent)
|
||||
TransitionManager.beginDelayedTransition(slidingPanel)
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
bottomNavigationView.isVisible = false
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
ViewCompat.setElevation(slidingPanel, 10f)
|
||||
behavior.isHideable = false
|
||||
behavior.peekHeight = heightOfBar - 24
|
||||
behavior.peekHeightAnimate(if(isQueueEmpty) 0 else heightOfBar - 24)
|
||||
bottomNavigationView.translateXAnimate(heightOfBar.toFloat())
|
||||
}
|
||||
else -> {
|
||||
println("ELSE")
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package code.name.monkey.retromusic.extensions
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -21,6 +22,7 @@ import android.widget.EditText
|
|||
import androidx.annotation.LayoutRes
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T : View> ViewGroup.inflate(@LayoutRes layout: Int): T {
|
||||
|
@ -45,3 +47,21 @@ fun EditText.appHandleColor(): EditText {
|
|||
TintHelper.colorHandles(this, ThemeStore.accentColor(context))
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
fun View.translateXAnimate(value: Float) {
|
||||
ObjectAnimator.ofFloat(this, "translationY", value)
|
||||
.apply {
|
||||
duration = 300
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
fun BottomSheetBehavior<*>.peekHeightAnimate(value: Int) {
|
||||
ObjectAnimator.ofInt(this, "peekHeight", value)
|
||||
.apply {
|
||||
duration = 300
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
|
|||
setHasOptionsMenu(true)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
|
||||
toolbar.title = null
|
||||
setupRecyclerView()
|
||||
|
||||
|
|
|
@ -14,17 +14,22 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
|
||||
import code.name.monkey.retromusic.dialogs.ImportPlaylistDialog
|
||||
import code.name.monkey.retromusic.extensions.findNavController
|
||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import kotlinx.android.synthetic.main.fragment_library.*
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
import java.lang.String
|
||||
|
||||
class LibraryFragment : AbsMainActivityFragment(R.layout.fragment_library) {
|
||||
|
||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
retainInstance = true
|
||||
mainActivity.hideBottomBarVisibility(true)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITH)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.supportActionBar?.title = null
|
||||
toolbar.setNavigationOnClickListener {
|
||||
|
|
|
@ -20,10 +20,13 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.adapter.SearchAdapter
|
||||
import code.name.monkey.retromusic.extensions.accentColor
|
||||
import code.name.monkey.retromusic.extensions.showToast
|
||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import kotlinx.android.synthetic.main.fragment_search.*
|
||||
import org.koin.android.ext.android.inject
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
|
@ -33,6 +36,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
const val REQ_CODE_SPEECH_INPUT = 9001
|
||||
}
|
||||
|
||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||
private val viewModel: SearchViewModel by inject()
|
||||
private lateinit var searchAdapter: SearchAdapter
|
||||
private var query: String? = null
|
||||
|
@ -40,8 +44,7 @@ class SearchFragment : AbsMainActivityFragment(R.layout.fragment_search), TextWa
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.hideBottomBarVisibility(false)
|
||||
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
setupRecyclerView()
|
||||
keyboardPopup.accentColor()
|
||||
searchView.addTextChangedListener(this)
|
||||
|
|
Loading…
Reference in a new issue