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

import UIKit

class DialogueLeftSelectionTVC: BaseTableViewCell {

    var xinfo = DialogueLeftSelectionTVCModel()
    
    lazy var headImageView: UIImageView = {
        let headImageView = UIImageView.init()
        //subImageView.contentMode = .scaleToFill
        headImageView.contentMode = .scaleAspectFill
        //        subImageView.backgroundColor = UIColor.yellow
        headImageView.image = UIImage.init(named: "home_image")
        
        return headImageView
    }()
    lazy var selectionItemView: SelectionItemView = {
        let selectionItemView = SelectionItemView.init()
        return selectionItemView
    }()
    lazy var bagImageView: UIImageView = {
        let bagImageView = UIImageView.init()
        //        bagImageView.backgroundColor = UIColor.red
        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(selectionItemView)
        // Initialization code
    }
    override func configurateTheCell(_ info: BaseCellModel) {
        xinfo = info as! DialogueLeftSelectionTVCModel
        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.systemFont(ofSize: 14), width: webLabelW)
//        
        selectionItemView.frame = CGRect(x:headImageView.originX+headImageView.width+23, y: headImageView.originY+24, width:webLabelW , height:xinfo.leftCellH )
        selectionItemView.addItemView(selectionArray: xinfo.selectionArray)
        
        bagImageView.frame = CGRect(x:selectionItemView.originX-13, y: selectionItemView.originY-13, width: selectionItemView.width+26, height:selectionItemView.height+26 )
//        print(webLabelW,selectionItemView.width)
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }

}
class DialogueLeftSelectionTVCModel: BaseCellModel {
    var titleStr:String?
    var content:String?
    var block:selectBlock!
    /// cell的累积高度
    var leftCellH:CGFloat!
    var selectionArray = NSMutableArray()
}
class SelectionModel: NSObject {
    var typename:String?
    /// 标题的高度
    var titleH:CGFloat!
    /// 间隔高度
    var intervalH:CGFloat!
    var selectItemArray = NSMutableArray()
}

