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

import UIKit

class MineInfoTableViewCell: BaseTableViewCell {

    var xinfo:MineInfoTableViewCellModel!
    var block:selectBlock!
    
    lazy var headImageView: UIImageView = {
        let headImageView = UIImageView.init(frame: CGRect(x:10*WHIDTH_RATIO(), y:12*HEIGHT_RATIO(), width:23*WHIDTH_RATIO() , height:23*WHIDTH_RATIO() ))
        self .addSubview(headImageView)
        return headImageView
    }()
    lazy var nameLabel: UILabel = {
        let nameLabel = UILabel.init()
        nameLabel.font = UIFont.systemFont(ofSize: 16*WHIDTH_RATIO())
        nameLabel.textColor = blackTitleColor
        nameLabel.textAlignment = .left
        //nameLabel.backgroundColor = UIColor.red
        self .addSubview(nameLabel)
        return nameLabel
    }()
    lazy var titleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.font = UIFont.systemFont(ofSize: 16*WHIDTH_RATIO())
        titleLabel.textAlignment = .right
        titleLabel.textColor = titleColor
        //titleLabel.backgroundColor = UIColor.red
        self .addSubview(titleLabel)
        return titleLabel
    }()
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.backgroundColor = UIColor.white
    }
    override func configurateTheCell(_ info: BaseCellModel) {
        xinfo = info as? MineInfoTableViewCellModel
        
        nameLabel.frame = CGRect(x:headImageView.originX+headImageView.width+8*WHIDTH_RATIO(), y: 0, width:getTexWidth(textStr: xinfo.nameStr!, font: UIFont.systemFont(ofSize: 16*WHIDTH_RATIO()), height: self.height) , height:self.height )
        self.accessoryType =  xinfo.accessoryType
        if xinfo.accessoryType == .disclosureIndicator{
            titleLabel.frame = CGRect(x:self.width-(getTexWidth(textStr: xinfo.titleStr!, font: UIFont.systemFont(ofSize: 16*WHIDTH_RATIO()), height: self.height)+35*WHIDTH_RATIO()), y: 0, width:getTexWidth(textStr: xinfo.titleStr!, font: UIFont.systemFont(ofSize: 16*WHIDTH_RATIO()), height: self.height) , height:self.height )
        }else{
            titleLabel.frame = CGRect(x:self.width-(getTexWidth(textStr: xinfo.titleStr!, font: UIFont.systemFont(ofSize: 16*WHIDTH_RATIO()), height: self.height)+10*WHIDTH_RATIO()), y: 0, width:getTexWidth(textStr: xinfo.titleStr!, font: UIFont.systemFont(ofSize: 16*WHIDTH_RATIO()), height: self.height) , height:self.height )
        }
        
        self.block = xinfo.block
        headImageView.image = UIImage.init(named: xinfo.imageName!)
        nameLabel.text = xinfo.nameStr
        titleLabel.text = xinfo.titleStr
        
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        if selected {
            //self.block()
        }
    }

}
class MineInfoTableViewCellModel: BaseCellModel {
    var nameStr:String?
    var titleStr:String?
    var imageName:String?
    var block:selectBlock!
    var accessoryType:UITableViewCellAccessoryType = .none
}
