//
//  BsBaseViewController.swift
//  BaiSiSMApp
//
//  Created by davidhuang on 2022/10/21.
//  Copyright © 2022 www.davidhuang.com. All rights reserved.
//

import UIKit
//import Kingfisher

class YHBaseViewController: UIViewController {
    lazy var noDataView:YHNoDataTipView  = {
        let temp = YHNoDataTipView()
        temp.frame = view.bounds
        temp.isHidden = true

        let tap = UITapGestureRecognizer(target: self, action: #selector(tapNodataViewEvent(tap:)))
        temp.addGestureRecognizer(tap)

        return temp
    }()



    override func viewDidLoad() {
        super.viewDidLoad()

        self.bs_setupLeftButton()
        
        //0
        setupNavigationAttributed()

        //1、
        view.addSubview(noDataView)
        view.backgroundColor = .white
    }
    deinit {
        #if DEBUG
        print(#function)
        #endif
    }
}

// MARK: - 私有操作方法
extension YHBaseViewController {

    @objc func tapNodataViewEvent(tap: UITapGestureRecognizer) -> Void {
        print("do nothing~~~  子类根据具体情况来实现\(#function)")
    }

    func openFullScreenBackGes(_ openFlag : Bool) {
        if self.navigationController is YHNavigationController {
            self.navigationItem.hidesBackButton = !openFlag
        }
    }
    
    ///设置导航条属性
    func setupNavigationAttributed(_ color: UIColor? = nil) {
        
        if let color = color {
            self.navigationController?.navigationBar.setBackgroundImage(UIImage.from(color: color), for: .default) //设置导航栏背景色
            self.navigationController?.navigationBar.barTintColor = color
        } else {
            self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) //设置导航栏背景透明色
            self.navigationController?.navigationBar.barTintColor = nil
        }
        self.navigationController?.navigationBar.shadowImage = UIImage() //隐藏下划线
    }
    
}
