//
//  ___FILENAME___
//  ___PROJECTNAME___
//
//  Created by ___FULLUSERNAME___ on ___DATE___.
//
//  The template was designed by Hưng Nguyễn. 
//  Website, application (native/flutter), hosting, SEO.
//  Email: hungnguyen.it36@gmail.com
//  ___COPYRIGHT___
//

import UIKit

class ___VARIABLE_ModuleName___TabBarViewController: UITabBarController {
    //MARK: Outlets
    private var vcs: [UIViewController] = []
    private var currentIndex: Int = 0
    init(_ viewcontrollers: [UIViewController], index: Int = 0) {
        vcs = viewcontrollers
        currentIndex = index
        super.init(nibName: nil, bundle: nil)
    }
    
    func selectVCAtIndex(_ index: Int) {
        currentIndex = index
        selectedIndex = index
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        viewControllers = vcs
        selectedIndex = currentIndex
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }

    override var traitCollection: UITraitCollection {
        let realTraits = super.traitCollection
        let fakeTraits = UITraitCollection(horizontalSizeClass: .regular)
        return UITraitCollection(traitsFrom: [realTraits, fakeTraits])
    }
}
