Fixed bottom navigation tint

This commit is contained in:
Prathamesh More 2021-12-24 22:14:03 +05:30
parent 50d56183a1
commit e67c094320
2 changed files with 21 additions and 7 deletions

View file

@ -25,7 +25,10 @@ import android.view.ViewTreeObserver
import android.view.animation.PathInterpolator import android.view.animation.PathInterpolator
import android.widget.FrameLayout import android.widget.FrameLayout
import androidx.core.animation.doOnEnd import androidx.core.animation.doOnEnd
import androidx.core.view.* import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.commit import androidx.fragment.app.commit
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
@ -143,8 +146,11 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
setupSlidingUpPanel() setupSlidingUpPanel()
setupBottomSheet() setupBottomSheet()
updateColor() updateColor()
if (!PreferenceUtil.materialYou) {
binding.slidingPanel.backgroundTintList = ColorStateList.valueOf(darkAccentColor()) binding.slidingPanel.backgroundTintList = ColorStateList.valueOf(darkAccentColor())
bottomNavigationView.backgroundTintList = ColorStateList.valueOf(darkAccentColor()) bottomNavigationView.backgroundTintList = ColorStateList.valueOf(darkAccentColor())
}
navigationBarColor = surfaceColor() navigationBarColor = surfaceColor()
} }
@ -394,7 +400,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
if (hide) { if (hide) {
bottomSheetBehavior.peekHeight = -windowInsets.safeGetBottomInsets() bottomSheetBehavior.peekHeight = -windowInsets.safeGetBottomInsets()
bottomSheetBehavior.state = STATE_COLLAPSED bottomSheetBehavior.state = STATE_COLLAPSED
libraryViewModel.setFabMargin(if (isBottomNavVisible) dip(R.dimen.bottom_nav_height) else 0)
ViewCompat.setElevation(binding.slidingPanel, 0f) ViewCompat.setElevation(binding.slidingPanel, 0f)
ViewCompat.setElevation(binding.bottomNavigationView, 10f) ViewCompat.setElevation(binding.bottomNavigationView, 10f)
} else { } else {
@ -408,7 +413,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
} else { } else {
bottomSheetBehavior.peekHeight = heightOfBarWithTabs bottomSheetBehavior.peekHeight = heightOfBarWithTabs
} }
libraryViewModel.setFabMargin(dip(R.dimen.mini_player_height_expanded))
} else { } else {
println("Details") println("Details")
if (animate) { if (animate) {
@ -419,7 +423,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
bottomSheetBehavior.peekHeight = heightOfBar bottomSheetBehavior.peekHeight = heightOfBar
binding.slidingPanel.bringToFront() binding.slidingPanel.bringToFront()
} }
libraryViewModel.setFabMargin(dip(R.dimen.mini_player_height))
} }
} }
} }

View file

@ -244,9 +244,14 @@ fun Context.getColorCompat(@ColorRes colorRes: Int): Int {
@ColorInt @ColorInt
fun Context.darkAccentColor(): Int { fun Context.darkAccentColor(): Int {
val colorSurfaceVariant = if (surfaceColor().isColorLight) {
surfaceColor()
} else {
surfaceColor().lighterColor
}
return ColorUtils.blendARGB( return ColorUtils.blendARGB(
accentColor(), accentColor(),
surfaceColor(), colorSurfaceVariant,
if (surfaceColor().isColorLight) 0.96f else 0.975f if (surfaceColor().isColorLight) 0.96f else 0.975f
) )
} }
@ -262,3 +267,9 @@ fun Context.darkAccentColorVariant(): Int {
inline val @receiver:ColorInt Int.isColorLight inline val @receiver:ColorInt Int.isColorLight
get() = ColorUtil.isColorLight(this) get() = ColorUtil.isColorLight(this)
inline val @receiver:ColorInt Int.lighterColor
get() = ColorUtil.lightenColor(this)
inline val @receiver:ColorInt Int.darkerColor
get() = ColorUtil.darkenColor(this)