// // MainViewController.swift // // // Created by shishir sapkota // import Foundation import UIKit class MainViewController: UITabBarController { // MARK: Properties // MARK: ENUMS: private enum Items: Int { case home = 0 case sendMoney case branch case profile } var presenter: MainModuleInterface? // MARK: VC's Life cycle override func viewDidLoad() { super.viewDidLoad() self.delegate = self self.setupAppearance() } func setup(viewControllers: [UIViewController]) { self.viewControllers = viewControllers self.setupTab() setupTabItem() } // MARK: Other functions func setupAppearance() { UINavigationBar.setInsideAppearance() } private func setupTab() { self.tabBar.tintColor = Colors.defaultRed self.tabBar.isTranslucent = false self.tabBar.shadowImage = Colors.TabBar.shadow.image() self.tabBar.backgroundImage = UIImage() // self.tabBar.barTintColor = .themeMainBackground } override func setupTabItem() { } } extension MainViewController: MainViewInterface { } extension MainViewController: UITabBarControllerDelegate { func tabBarController( _ tabBarController: UITabBarController, shouldSelect viewController: UIViewController ) -> Bool { if let nav = viewController as? UINavigationController { if nav.viewControllers.first as? RecipientsViewController != nil { NotificationCenter.default.post( name: Notification.Name.init(AppConstants.MainWireFrameNotificationName), object: nil, userInfo: nil ) return Utility.isVerifiedUser() } } print(tabBarController.selectedIndex) return true } } extension UINavigationBar { static func setInsideAppearance() { let navBarAppearance = UINavigationBar.appearance() navBarAppearance.isTranslucent = false navBarAppearance.barTintColor = UIColor.white } static func setOutsideAppearance() { self.setInsideAppearance() let navBarAppearance = UINavigationBar.appearance() navBarAppearance.barTintColor = Colors.defaultRed let font = Fonts.NavBar.titleFont navBarAppearance.titleTextAttributes = [ NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font: font] navBarAppearance.tintColor = UIColor.black } static func setupImageAppearance() { let navBarAppearance = UINavigationBar.appearance() navBarAppearance.barTintColor = Colors.defaultRed let font = Fonts.NavBar.titleFont navBarAppearance.titleTextAttributes = [ NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font: font] navBarAppearance.tintColor = UIColor.black } } @objc protocol Setup { @objc optional func setupTabItem() } extension UIViewController: Setup { func setupTabItem() { } } struct Colors { static let separator = UIColor(hex: "#eeeeee") static let defaultRed = UIColor(hex: "#0xec1c24") static let cartBadge = UIColor(hex: "#F5951D") struct TabBar { static let textItemSelected = Colors.defaultRed static let textItemNotSelected = UIColor(hex: "#959595") static let shadow = Colors.separator } struct NavBar { // static let barTint = static let tint = UIColor.white static let shadow = Colors.separator } struct XLTabBar { static let titleUnselected = UIColor(hex: "#555555") static let titleSelected = Colors.defaultRed static let selectedBackground = Colors.defaultRed } } struct Fonts { struct TabBar { static let itemFont = UIFont.sanfrancisco(.light, size: 10) } struct NavBar { static let titleFont = UIFont.sanfrancisco(.regular, size: 17) } struct XLTabBar { static let itemFont = UIFont.sanfrancisco(.regular, size: 12) } struct Error { static let font = UIFont.sanfrancisco(.semibold, size: 11) } } extension UIColor { func image(of size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { let rect = CGRect(origin: .zero, size: size) UIGraphicsBeginImageContextWithOptions(size, false, 0) self.setFill() UIRectFill(rect) let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()! UIGraphicsEndImageContext() return image } }