ارفع راسك فوق انته سوري حر ... :green_heart::green_heart:

Skip to content
Snippets Groups Projects
Select Git revision
  • ui-ux-improvments
  • signature
  • main default protected
3 results

AppTabBarController.swift

Blame
  • AppTabBarController.swift 6.20 KiB
    import UIKit
    
    class AppTabBarController: UITabBarController, UITabBarControllerDelegate, WalkthroughViewControllerDelegate {
        var window: UIWindow?
    
        struct Constants {
            static let reuseIdentifier = String(describing: AppTabBarController.self)
            static let storyboardName = "Documents"
        }
        
        static func buildViewController() -> AppTabBarController {
            let controller = UIStoryboard(name: Constants.storyboardName,
                                          bundle: .main).instantiateViewController(withIdentifier: Constants.reuseIdentifier)
            return controller as! AppTabBarController
        }
        
        private var observation: NSKeyValueObservation?
        
        required init?(coder: NSCoder) {
            super.init(coder: coder)
        }
        
        deinit {
            observation = nil
        }
        
        override func viewDidLoad() {
            super.viewDidLoad()
            window = UIWindow(frame: UIScreen.main.bounds)
            self.delegate = self
            
            observation = observe(\.tabBar.semanticContentAttribute) { value, change in
                self.reloadLocalization()
            }
            
            setupUI()
        }
        
        private func setupUI() {
            
            tabBar.items?[0].title = .fileManager.localized
            tabBar.items?[2].title = .studio.localized
            
            tabBar.items?[0].image = .folderOpen
            tabBar.items?[2].image = .gallery
        }
        
        private func reloadLocalization() {
            tabBar.items?[0].title = .fileManager.localized
            tabBar.items?[2].title = .studio.localized
        }
        
        override func viewWillAppear(_ animated: Bool) {
            super.viewWillAppear(animated)
            if UserDefaults.standard.showWalktroughAtLaunch {
                perform(#selector(showWalkTrough), with: self, afterDelay: 0.88)
            }
        }
        
        let walkthroughs = [
            WalkthroughModel(title: "Quick Overview",
                             subtitle: "Quickly visualize important business metrics. The overview in the home tab shows the most important metrics to monitor how your business is doing in real time.",
                             icon: "analytics-icon"),
            WalkthroughModel(title: "Analytics",
                             subtitle: "Dive deep into charts to extract valuable insights and come up with data driven product initiatives, to boost the success of your business.",
                             icon: "bars-icon"),
            WalkthroughModel(title: "Dashboard Feeds",
                             subtitle: "View your sales feed, orders, customers, products and employees.",
                             icon: "activity-feed-icon"),
            WalkthroughModel(title: "Get Notified",