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 indicator line bug #824

Closed
melcug opened this issue Aug 4, 2017 · 12 comments
Closed

TabsController indicator line bug #824

melcug opened this issue Aug 4, 2017 · 12 comments
Assignees

Comments

@melcug
Copy link

melcug commented Aug 4, 2017

I use following code to initialize TabBar:

extension AppTabBarController {
    fileprivate func prepareTabBar() {
        tabBarAlignment = .top
        tabBar.tabBarStyle = .auto
        tabBar.dividerColor = nil
        tabBar.lineHeight = 5.0
        tabBar.lineColor = Color.blue.lighten3
        tabBar.lineAlignment = .bottom
        tabBar.backgroundColor = Color.blue.darken2
    }
}

2017-08-04 14 16 04

As you can see, there are some problems with indicator line shown on active tab:

  • initially the line is moving from top (not from bottom) of latest active tab to next active tab;
  • the line height is ok at start, but changing the active tab to other tab it changes also the height of the line.

Regards,
Gogu.

@daniel-jonathan daniel-jonathan self-assigned this Aug 4, 2017
@daniel-jonathan
Copy link
Member

Nice, I will investigate this today :) Thank you!

@daniel-jonathan
Copy link
Member

Thank you for submitting this issue. It is now fixed. I will push an update now.

@melcug
Copy link
Author

melcug commented Aug 10, 2017

In latest version of Material (v2.9.1) the bug mentioned in first message (both issues) came back (fixed in v2.9.0).

Regards,
Gogu.

@egenvall
Copy link

This issue exists in v2.9.4 as well on the first swap between tabs

@daniel-jonathan
Copy link
Member

I will double check.

@daniel-jonathan
Copy link
Member

I cannot reproduce it. Are you sure you are using the latest? That said, if you can provide reproduction steps, that would be helpful. Thank you!

@egenvall
Copy link

Using Material (2.9.4)

class AppTabBarController: TabsController {

    override func viewDidLoad() {
        viewControllers = [someVc, someVc2]
        super.viewDidLoad()
    }


    open override func prepare() {
        super.prepare()
        tabBar.tabBarStyle = .auto
        tabBarAlignment = .top
        tabBar.dividerColor = nil
        tabBar.lineHeight = 5.0
        tabBar.lineColor = .red
        tabBar.lineAlignment = .bottom
        tabBar.backgroundColor = .white
    }
}

The only difference I guess is that AppTabBarController is one of the tabs in RamAnimatedTabBarController and then the Material TabsController has two viewcontrollers that is set in the viewDidLoad

@daniel-jonathan
Copy link
Member

Hmmm... well I cannot reproduce this within Material, you would have to setup a sample project with another library and demonstrate how Material breaks. Then I would be happy to help out.

@egenvall
Copy link

egenvall commented Aug 23, 2017

It seems to be storyboard related (modified the sample)

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func applicationDidFinishLaunching(_ application: UIApplication) {
    window = UIWindow(frame: Screen.bounds)
    window!.rootViewController = AppTabsController(viewControllers: [])
    window!.makeKeyAndVisible()
}

}

class AppTabsController: TabsController {

override func viewDidLoad() {
    viewControllers = [UIStoryboard(name: "Test", bundle: nil).instantiateViewController(withIdentifier: "blue"),UIStoryboard(name: "Test", bundle: nil).instantiateViewController(withIdentifier: "brown")]
    
    super.viewDidLoad()
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationController?.navigationBar.isHidden = true
}

open override func prepare() {
    super.prepare()
    tabBar.tabBarStyle = .auto
    tabBarAlignment = .top
    tabBar.dividerColor = nil
    tabBar.lineHeight = 5.0
    tabBar.lineColor = .red
    tabBar.lineAlignment = .bottom
    tabBar.backgroundColor = .white
    tabBar.scrollView.showsVerticalScrollIndicator = false
    tabBar.scrollView.showsHorizontalScrollIndicator = false
    

    }
}

Created a storyboard "Test" with 3 ViewControllers

  • AppTabsController: Custom class AppTabsController
  • BlueViewController: Custom class BlueViewController
  • BrownViewController: Custom class BrownViewController

i.e it's not related to the other library
This replicates the issue 100% success rate on the initial swap between the viewcontrollers

@daniel-jonathan
Copy link
Member

I need a sample project that creates this issue. As well, you shouldn't need to set this:

tabBar.scrollView.showsVerticalScrollIndicator = false
tabBar.scrollView.showsHorizontalScrollIndicator = false

They should already be set.

@egenvall
Copy link

Demo Repo
(Didn't clean away the other files from the sample)
Yes you are correct regarding the scrollview indicators.

@James-Coleman
Copy link

@egenvall I know this is a really old issue and you may have already solved this, but I had this same issue and it was solved by setting up my tabBar appearance before calling super.viewDidLoad in my subclass of TabsController:

    override func viewDidLoad() {

        setupTabBarAppearance() // Setting up the tab bar appearance before super.viewDidLoad is removing the bug where the tab line would jump from the top to the bottom the first time a new tab is selected.
        
        super.viewDidLoad()
    }

I suspect this may be related to setting the tabBarAlignment to .top

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