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

import UIKit

class PopoverTableViewCell: BaseTableViewCell {
    var xinfo = PopoverTableViewCellModel()
    
    
    lazy var titleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textAlignment = .center
        //        titleLabel.font = UIFont.systemFont(ofSize: 15)
        titleLabel.numberOfLines = 0
        titleLabel.font = UIFont.systemFont(ofSize: 13.33)
//        titleLabel.backgroundColor = UIColor.red
        titleLabel.textColor = UIColorFromRGB(rgbValue: 0x424C52)
        return titleLabel
    }()
    lazy var subImageView: UIImageView = {
        let subImageView = UIImageView.init()
        subImageView.contentMode = .scaleAspectFill
        subImageView.clipsToBounds = true
        return subImageView
    }()
    override func awakeFromNib() {
        super.awakeFromNib()
        self.addSubview(subImageView)
        self.addSubview(titleLabel)
//        self.separatorInset=UIEdgeInsetsMake(0, 10, 0, 0)
//        self.backgroundColor = UIColor.yellow
        // Initialization code
    }
    override func configurateTheCell(_ info: BaseCellModel) {
        xinfo = info as! PopoverTableViewCellModel
        
        self.subImageView.frame = CGRect(x:18, y: 13.6, width:16.67 , height:16.67 )
        self.titleLabel.frame = CGRect(x:self.subImageView.originX+self.subImageView.width+9, y: 0, width:self.width-(self.subImageView.originX+self.subImageView.width+18) , height:self.height )
//        self.subImageView.centerY =
//        self.titleLabel.centerY = self.centerY
        self.titleLabel.text = xinfo.titleStr
        print(xinfo.titleStr!)
        self.subImageView.image = UIImage.init(named: xinfo.imageStr!)
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        if selected {
            xinfo.block()
        }
    }

}
class PopoverTableViewCellModel: BaseCellModel {
    var titleStr:String?
    var imageStr:String?
    var block:selectBlock!
    var h:CGFloat!
    
}
