Merge pull request #220 from esensar/fix/tab-color

Fix inactive tab onResume update when there are 3 tabs
This commit is contained in:
Tibor Kaputa 2023-09-13 09:46:20 +02:00 committed by GitHub
commit 673110e489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,11 +70,11 @@ class MainActivity : SimpleActivity() {
override fun onResume() {
super.onResume()
setupTabColors()
updateMenuColors()
if (getPagerAdapter()?.showRecycleBin != config.useRecycleBin) {
setupViewPager()
}
setupTabColors()
getPagerAdapter()?.onResume()
}
@ -207,9 +207,13 @@ class MainActivity : SimpleActivity() {
private fun setupTabColors() {
val activeView = binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.customView
val inactiveView = binding.mainTabsHolder.getTabAt(getInactiveTabIndex())?.customView
updateBottomTabItemColors(activeView, true)
updateBottomTabItemColors(inactiveView, false)
for (i in 0 until binding.mainTabsHolder.tabCount) {
if (i != binding.viewPager.currentItem) {
val inactiveView = binding.mainTabsHolder.getTabAt(i)?.customView
updateBottomTabItemColors(inactiveView, false)
}
}
binding.mainTabsHolder.getTabAt(binding.viewPager.currentItem)?.select()
val bottomBarColor = getBottomNavigationBackgroundColor()
@ -217,8 +221,6 @@ class MainActivity : SimpleActivity() {
updateNavigationBarColor(bottomBarColor)
}
private fun getInactiveTabIndex() = if (binding.viewPager.currentItem == 0) 1 else 0
private fun getPagerAdapter() = (binding.viewPager.adapter as? ViewPagerAdapter)
private fun launchSettings() {