//
//  UINavigation+Utils.swift
//  base-chatsdk-ios
//
//  Created by Bruno Martinez on 2/13/20.
//

import UIKit

extension UINavigationController {
    
  func setNavigationBarTranslucent(_ translucent: Bool, lineColor: UIColor, backgroundColor: UIColor) {
        if translucent {
            self.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
            self.navigationBar.shadowImage = UIImage()
            self.navigationBar.isTranslucent = true
            self.view.backgroundColor = UIColor.clear
        
        } else { 
            self.navigationBar.shadowImage = lineColor.as1ptImage()
            self.navigationBar.isTranslucent = false
            self.view.backgroundColor = backgroundColor
            self.navigationBar.barTintColor = backgroundColor
        }
    }
    
    func setNavigationBarLineHidden() {
        self.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
        self.navigationBar.shadowImage = UIImage()
    }
  
  func setNavigationTitle(font: UIFont) {
    let attrs = [
      NSAttributedString.Key.font: font
    ]
    self.navigationBar.titleTextAttributes = attrs
  }
}
