//
//  MineInfoHeadTableViewCell.swift
//  MobilePortal
//
//  Created by xiejiangbo on 2019/3/25.
//  Copyright © 2019 yin chen. All rights reserved.
//

import UIKit

class MineInfoHeadTableViewCell: BaseTableViewCell {

    var nameLabel:UILabel!
    var companyLabel:UILabel!
    //var departementLabel:UILabel!
    var xinfo:MineInfoHeadTableViewCellModel!
    var block:selectBlock!
    
    lazy var headImageView: UIImageView = {
        let headImageView = UIImageView.init(frame: CGRect(x:20*WHIDTH_RATIO(), y:15*HEIGHT_RATIO(), width:70*WHIDTH_RATIO() , height:70*WHIDTH_RATIO() ))
        headImageView.image = UIImage.init(named: "touxiang_image")
        //设置遮罩
        headImageView.layer.masksToBounds = true
        //设置圆角半径(宽度的一半)，显示成圆形。
        headImageView.layer.cornerRadius = headImageView.width*WHIDTH_RATIO()/2
        self .addSubview(headImageView)
        return headImageView
    }()
    
    func initNameLabel() {
        nameLabel = self.getUILabel()
        nameLabel.frame = CGRect(x:headImageView.originX+headImageView.width+20*WHIDTH_RATIO(), y:headImageView.originY+1*WHIDTH_RATIO(), width:SCREEN_WHIDTH()-headImageView.originX+headImageView.width+20*WHIDTH_RATIO() , height:20*WHIDTH_RATIO() )
        
        //departementLabel = self.getUILabel()
        departementLabel.frame = CGRect(x:nameLabel.originX, y:nameLabel.originY+3*WHIDTH_RATIO()+nameLabel.height, width:SCREEN_WHIDTH()-headImageView.originX-headImageView.width-40*WHIDTH_RATIO() , height:getTextHeigh(textStr: xinfo.departementStr!, font: UIFont.systemFont(ofSize: 16*WHIDTH_RATIO()), width: SCREEN_WHIDTH()-headImageView.originX-headImageView.width-40*WHIDTH_RATIO()) )
        
        companyLabel = self.getUILabel()
        companyLabel.frame = CGRect(x:departementLabel.originX, y:departementLabel.originY+departementLabel.height, width:SCREEN_WHIDTH()-headImageView.originX+headImageView.width+20*WHIDTH_RATIO() , height:20*WHIDTH_RATIO() )
    }
    lazy var departementLabel: UILabel = {
        let departementLabel = UILabel.init()
        departementLabel.textAlignment = .left
        departementLabel.font = UIFont.systemFont(ofSize: 16*WHIDTH_RATIO())
        departementLabel.numberOfLines = 0
        departementLabel.backgroundColor = UIColor.clear
        departementLabel.lineBreakMode = .byCharWrapping
        departementLabel.textColor = UIColor.white
        //departementLabel.backgroundColor = UIColor.red
        self.addSubview(departementLabel)
        return departementLabel
    }()
    func getUILabel() -> UILabel {
        let label = UILabel.init()
        label.font = UIFont.systemFont(ofSize: 16*WHIDTH_RATIO())
        label.textColor = UIColor.white
        self .addSubview(label)
        return label
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.backgroundColor = statusBarColor
    }
    override func configurateTheCell(_ info: BaseCellModel) {
        xinfo = (info as! MineInfoHeadTableViewCellModel)
        self.block = xinfo.block
        initNameLabel()
        nameLabel.text = xinfo.nameStr!
        companyLabel.text = xinfo.companyStr!
        departementLabel.text = xinfo.departementStr!
        
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        if selected {
            //self.block()
        }
    }
    
}
class MineInfoHeadTableViewCellModel: BaseCellModel {
    var nameStr:String?
    var companyStr:String?
    var departementStr:String?
    var headImageUrl:String?
    var block:selectBlock!
    
}

