Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabsController - tabItem colors for states. #860

Closed
OrkhanAlikhanov opened this issue Sep 8, 2017 · 10 comments
Closed

TabsController - tabItem colors for states. #860

OrkhanAlikhanov opened this issue Sep 8, 2017 · 10 comments

Comments

@OrkhanAlikhanov
Copy link
Contributor

By the way, I was using the tabBar delegate to change title colors for (de)selected states accordingly.

func tabBar(tabBar: TabBar, willSelect tabItem: TabItem) {
    tabBar.tabItems.forEach {
        $0.titleColor = .darkGray
    }    
    tabItem.titleColor = App.colors.primary
}

Shouldn't be there something like selectedTabItemTitleColor and normalTabItemTitleColor. ?
image

@daniel-jonathan
Copy link
Member

I can add this with the delegation calls.

@yasirmturk
Copy link

+100

@yasirmturk
Copy link

i do this on viewdidload

@daniel-jonathan
Copy link
Member

daniel-jonathan commented Oct 15, 2017

Please find this feature available in the latest Material 2.12.0 release.

Example:

tabBar.setColor(Color.grey.base, for: .normal)
tabBar.setColor(Color.blue.base, for: .selected)

Thank you @mohpor for the initial version, it really helped with laying down the groundwork :)

@markst
Copy link
Contributor

markst commented Oct 17, 2017

@DanielDahan I think TabItemState is unnecessary - why not just use the UIControlState enum?

Previously I would setup colours as follows:

override func prepare() {
    super.prepare()

    // Setup tab bar items appearance:
    self.viewControllers.forEach { (vc) in
        vc.tabItem.titleLabel?.font = UIFont.sparkyFont(.calibri, weight: .bold, size: 14)
        vc.tabItem.setTitleColor(UIColor.cs_Thunder(),for: .normal)
        vc.tabItem.setTitleColor(UIColor.cs_Citron(), for: .highlighted)
        vc.tabItem.setTitleColor(UIColor.cs_Citron(), for: .selected)
    }
}

However, now updateColors() overrides all of this & I don't have support for .highlighted state.

@markst
Copy link
Contributor

markst commented Oct 17, 2017

#740

@daniel-jonathan
Copy link
Member

@markst yeah, we can make that adjustment.

@daniel-jonathan
Copy link
Member

Adding this suggestion #916 (comment)

@daniel-jonathan
Copy link
Member

@markst I opted out of using UIControlState as it has more states than necessary for managing the tab items. That said, the latest interface for colors looks like this:

tabBar.setLineColor(Color.orange.base, for: .selected)
        
tabBar.setTabItemsColor(Color.grey.base, for: .normal)
tabBar.setTabItemsColor(Color.purple.base, for: .selected)
tabBar.setTabItemsColor(Color.green.base, for: .highlighted)

This is available in Material 2.12.2.

@OrkhanAlikhanov
Copy link
Contributor Author

@DanielDahan Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants