use filled icons for the selected tabs

This commit is contained in:
tibbi
2022-12-25 21:11:14 +01:00
parent 00f115df52
commit 1d1a887073
14 changed files with 57 additions and 17 deletions

View File

@ -115,7 +115,6 @@ class MainActivity : SimpleActivity() {
.build()
}
override fun onPause() {
super.onPause()
storeStateVariables()
@ -229,22 +228,22 @@ class MainActivity : SimpleActivity() {
main_tabs_holder.onTabSelectionChanged(
tabUnselectedAction = {
updateBottomTabItemColors(it.customView, false)
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
},
tabSelectedAction = {
view_pager.currentItem = it.position
updateBottomTabItemColors(it.customView, true)
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
}
)
}
private fun setupTabColors() {
val activeView = main_tabs_holder.getTabAt(view_pager.currentItem)?.customView
updateBottomTabItemColors(activeView, true)
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[view_pager.currentItem])
getInactiveTabIndexes(view_pager.currentItem).forEach { index ->
val inactiveView = main_tabs_holder.getTabAt(index)?.customView
updateBottomTabItemColors(inactiveView, false)
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
}
main_tabs_holder.getTabAt(view_pager.currentItem)?.select()
@ -255,6 +254,20 @@ class MainActivity : SimpleActivity() {
private fun getInactiveTabIndexes(activeIndex: Int) = arrayListOf(0, 1, 2, 3).filter { it != activeIndex }
private fun getSelectedTabDrawableIds() = arrayOf(
R.drawable.ic_clock_filled_vector,
R.drawable.ic_alarm_filled_vector,
R.drawable.ic_stopwatch_filled_vector,
R.drawable.ic_hourglass_filled_vector
)
private fun getDeselectedTabDrawableIds() = arrayOf(
R.drawable.ic_clock_vector,
R.drawable.ic_alarm_vector,
R.drawable.ic_stopwatch_vector,
R.drawable.ic_hourglass_vector
)
private fun launchSettings() {
startActivity(Intent(applicationContext, SettingsActivity::class.java))
}