//
//  DialogueLeftTableViewCell.swift
//  MobilePortal
//
//  Created by caiyang on 2020/4/9.
//  Copyright © 2020 yin chen. All rights reserved.
//

import UIKit

class DialogueLeftTableViewCell: BaseTableViewCell {
    
    var xinfo = DialogueLeftTableViewCellModel()

    lazy var headImageView: UIImageView = {
        let headImageView = UIImageView.init()
        headImageView.contentMode = .scaleAspectFill
        //        subImageView.backgroundColor = UIColor.yellow
        headImageView.image = UIImage.init(named: "home_image")
        return headImageView
    }()
    lazy var webLabel: UILabel = {
        let webLabel = UILabel.init()
        webLabel.textAlignment = .left
        webLabel.numberOfLines = 0
        webLabel.font = UIFont.test_systemFont(ofSize: 13.33)
        webLabel.textColor = UIColorFromRGB(rgbValue: 0x3D444F)
        return webLabel
    }()
    lazy var bagImageView: UIImageView = {
        let bagImageView = UIImageView.init()
        return bagImageView
    }()
    override func awakeFromNib() {
        super.awakeFromNib()
        self.separatorInset=UIEdgeInsetsMake(0, SCREEN_WHIDTH(), 0, 0)
        let insets = UIEdgeInsets.init(top: 12, left: 12, bottom: 10, right: 10)
        var aaimage = UIImage.init(named: "leftBag_image")
        aaimage = aaimage?.resizableImage(withCapInsets: insets, resizingMode: UIImageResizingMode.stretch)
        bagImageView.image = aaimage
        self.backgroundColor = UIColorFromRGB(rgbValue: 0xE9F2F8)
        self.addSubview(headImageView)
        self.addSubview(bagImageView)
        self.addSubview(webLabel)
    }
    override func configurateTheCell(_ info: BaseCellModel) {
        xinfo = info as! DialogueLeftTableViewCellModel
        headImageView.frame = CGRect(x:13.67, y: 20.67, width:57.33 , height:57.33 )
        let webLabelW = SCREEN_WHIDTH()-(headImageView.originX+headImageView.width+22.67+67)
        let webLabelH = getTextHeigh(textStr: self.xinfo.titleStr!, font: UIFont.test_systemFont(ofSize: 13.33), width: webLabelW)
        
        webLabel.frame = CGRect(x:headImageView.originX+headImageView.width+23, y: headImageView.originY+24, width:webLabelW , height:webLabelH )
        webLabel.text = xinfo.titleStr
        
        var bagImageViewW = getTexWidth(textStr: xinfo.titleStr!, font: UIFont.test_systemFont(ofSize: 14), height: webLabel.height)
        if (bagImageViewW >= webLabelW) {
            bagImageViewW = webLabelW
        }
        bagImageView.frame = CGRect(x:webLabel.originX-13, y: webLabel.originY-13, width: bagImageViewW+26, height:webLabel.height+26 )
        
        
        
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }

}
class DialogueLeftTableViewCellModel: BaseCellModel {
    var titleStr:String?
    var content:String?
    var cellH:CGFloat?
    
    var block:selectBlock!
}
