//
//  VoiceDialogueLeftAppCTC.swift
//  MobilePortal
//
//  Created by caiyang on 2020/5/18.
//  Copyright © 2020 yin chen. All rights reserved.
//

import UIKit

class VoiceDialogueLeftAppCTC: BaseCollectionViewCell {
    var block:passParameterBlock!
    var modelHttp = VoiceDialogueLeftAppCTCModel()
    
    lazy var bagBtn: UIButton = {
        let bagBtn = UIButton.init(type: .custom)
        bagBtn.alpha = 0.1
        bagBtn.backgroundColor = UIColor.clear
        bagBtn.addTarget(self, action: #selector(actions), for: .touchUpInside)
        return bagBtn
    }()
    lazy var bagView: UIImageView = {
        let bagView = UIImageView.init()
        bagView.backgroundColor = UIColor.white
        //设置遮罩
        bagView.layer.masksToBounds = true
        //设置圆角半径(宽度的一半)，显示成圆形。
        bagView.layer.cornerRadius = 5
        return bagView
    }()
    lazy var titleLable: UILabel = {
        let titleLable = UILabel.init()
        titleLable.textAlignment = .center
        titleLable.font = UIFont.test_systemFont(ofSize: 12)
        titleLable.numberOfLines = 0
        titleLable.backgroundColor = UIColor.clear
        titleLable.lineBreakMode = .byCharWrapping
        //        titleLable.textColor = blackTitleColor
        titleLable.textColor = UIColorFromRGB(rgbValue: 0x434952)
        return titleLable
    }()
    override func awakeFromNib() {
        super.awakeFromNib()
        self.backgroundColor = UIColorFromRGB(rgbValue: 0xE9F2F8)
        self .addSubview(bagView)
        self .addSubview(titleLable)
        self .addSubview(bagBtn)
    }
    override func configurateTheCell(info:BaseCollectionViewCellModel){
        self.modelHttp = info as! VoiceDialogueLeftAppCTCModel
        self.block = self.modelHttp.block
        bagView.frame = CGRect(x:10, y: 10, width:self.width-20 , height:self.height-20)
        titleLable.frame = CGRect(x:0, y: bagView.originY, width:getTexWidth(textStr: modelHttp.titleValue!, font: UIFont.test_systemFont(ofSize: 12), height: self.height-10) , height:bagView.height)
        titleLable.center = bagView.center
        titleLable.text = modelHttp.titleValue
        bagBtn.frame = CGRect(x:0, y: 0, width:self.width , height:self.height)
    }
    @objc func actions() {
        //if self.modelHttp.url != nil && self.modelHttp.url?.characters.count != 0 {
        self.block(self.modelHttp.comments as AnyObject)
        //}
    }
    
}
class VoiceDialogueLeftAppCTCModel: BaseCollectionViewCellModel {
    var titleValue:String?
    var imageName:String?
    var block:passParameterBlock!
    var isInstallation = true
    var biaojiNum:String?
    var applicationPlatformsType:ApplicationPlatformsType = .WebType
    var platforms: String? {
        didSet {
            if platforms == "1" {
                applicationPlatformsType = .AndroidiOSType
            }else{
                applicationPlatformsType = .WebType
            }
        }
    }
    //var url:String?
    var comments:String?
    var openUrl:String?
    var httpDetailModel = ApplicationHttpListModel()
    var applicationType:ApplicationType = .OftenApplicationType
    var cellW = CGFloat()
    
}
