// // MainViewController.swift // Sipradi // // Created by bibek timalsina on 5/26/17. // Copyright © 2017 Ekbana. All rights reserved. // 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.setupAppearance() } func setup(viewControllers: [UIViewController]) { self.viewControllers = viewControllers self.setupTab() setupTabItem() } // MARK: Other functions func setupAppearance() { UINavigationBar.setInsideAppearance() } private func setupTab() { // self.tabBar.barTintColor = Colors.TabBar.barTint self.tabBar.tintColor = Colors.defaultRed self.tabBar.isTranslucent = false self.tabBar.shadowImage = Colors.TabBar.shadow.image() self.tabBar.backgroundImage = UIImage() } override func setupTabItem() { self.viewControllers?.forEach({ (viewController) in viewController.tabBarItem.imageInsets = UIEdgeInsets(top: 7, left: 0, bottom: -7, right: 0) }) } } extension MainViewController: MainViewInterface { } //0xec1c24 extension UINavigationBar { static func setInsideAppearance() { let navBarAppearance = UINavigationBar.appearance() navBarAppearance.isTranslucent = false navBarAppearance.barTintColor = UIColor.white // navBarAppearance.shadowImage = UIImage() //Colors.NavBar.shadow.image() // let font = Fonts.NavBar.titleFont // // navBarAppearance.titleTextAttributes = [ // NSAttributedStringKey.foregroundColor: Colors.NavBar.tint, // NSAttributedStringKey.font: font] // navBarAppearance.tintColor = Colors.NavBar.tint } static func setOutsideAppearance() { self.setInsideAppearance() let navBarAppearance = UINavigationBar.appearance() navBarAppearance.barTintColor = Colors.defaultRed let font = Fonts.NavBar.titleFont navBarAppearance.titleTextAttributes = [ NSAttributedStringKey.foregroundColor: UIColor.black, NSAttributedStringKey.font: font] navBarAppearance.tintColor = UIColor.black } static func setupImageAppearance() { // self.setInsideAppearance() let navBarAppearance = UINavigationBar.appearance() navBarAppearance.barTintColor = Colors.defaultRed let font = Fonts.NavBar.titleFont navBarAppearance.titleTextAttributes = [ NSAttributedStringKey.foregroundColor: UIColor.black, NSAttributedStringKey.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 { private struct Family { static let regular = "SanFranciscoDisplay-regular" static let light = "SanFranciscoDisplay-light" static let bold = "SanFranciscoDisplay-Bold" } struct TabBar { static let itemFont = UIFont(name: Family.light, size: 10)! } struct NavBar { static let titleFont = UIFont(name: Family.regular, size: 17)! } struct XLTabBar { static let itemFont = UIFont(name: Family.light, size: 12)! } } 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 } }