adding an option to change the bottom navigation bar drawable
This commit is contained in:
parent
7f288cc10b
commit
9ffc3ac4d1
2 changed files with 16 additions and 13 deletions
|
@ -1038,13 +1038,17 @@ fun Context.getPhoneNumberTypeText(type: Int, label: String): String {
|
|||
}
|
||||
}
|
||||
|
||||
fun Context.updateBottomTabItemColors(view: View?, isActive: Boolean) {
|
||||
fun Context.updateBottomTabItemColors(view: View?, isActive: Boolean, drawable: Drawable? = null) {
|
||||
val color = if (isActive) {
|
||||
getProperPrimaryColor()
|
||||
} else {
|
||||
getProperTextColor()
|
||||
}
|
||||
|
||||
if (drawable != null) {
|
||||
view?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(drawable)
|
||||
}
|
||||
|
||||
view?.findViewById<ImageView>(R.id.tab_item_icon)?.applyColorFilter(color)
|
||||
view?.findViewById<TextView>(R.id.tab_item_label)?.setTextColor(color)
|
||||
}
|
||||
|
|
|
@ -5,17 +5,16 @@ import com.google.android.material.tabs.TabLayout
|
|||
fun TabLayout.onTabSelectionChanged(
|
||||
tabUnselectedAction: ((inactiveTab: TabLayout.Tab) -> Unit)? = null,
|
||||
tabSelectedAction: ((activeTab: TabLayout.Tab) -> Unit)? = null
|
||||
) =
|
||||
setOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||
tabSelectedAction?.invoke(tab)
|
||||
}
|
||||
) = setOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
|
||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||
tabSelectedAction?.invoke(tab)
|
||||
}
|
||||
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) {
|
||||
tabUnselectedAction?.invoke(tab)
|
||||
}
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) {
|
||||
tabUnselectedAction?.invoke(tab)
|
||||
}
|
||||
|
||||
override fun onTabReselected(tab: TabLayout.Tab) {
|
||||
tabSelectedAction?.invoke(tab)
|
||||
}
|
||||
})
|
||||
override fun onTabReselected(tab: TabLayout.Tab) {
|
||||
tabSelectedAction?.invoke(tab)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue