CNLiveViateWorkModelLayout.swift 5.25 KB
//
//  CNLiveViateWorkModelLayout.swift
//  metaCode
//
//  Created by zx on 2024/8/1.
//

import Foundation


class CNLiveViateWorkModelLayout:NSObject{
    
    ///cell高度
    var cellH:CGFloat = 0.0
//    var descH:Float = 40.0
    
    var _workModel : CNLiveVitaeWorksModel?
    var workModel : CNLiveVitaeWorksModel? {
        get{
            _workModel
        }
        set{
            _workModel = newValue
        }
    }
    
    init(model:CNLiveVitaeWorksModel,descH:Float,isPreview:Bool,isExpand:Bool,isShowExpand:Bool){
        super.init()
        var gangwei:Float = 10
        if model.position.count == 0{
            gangwei = 0
        }else{
        }

        model.isExpand = isExpand
        model.isShowExpand = isShowExpand
        var expand:Float = 20
        
        let titleLabel = UILabel.init(frame: CGRectMake(0, 0, KSreenWidth-60, 40))
        titleLabel.textColor = HexColor("#999999")
        titleLabel.textAlignment = .left
        titleLabel.font = Font_14
        titleLabel.backgroundColor = .clear
        titleLabel.text = "描述"
        titleLabel.numberOfLines = 0
        titleLabel.text = model.jobDuties
        let lines = titleLabel.getRealLabelTextLines()
        let height = titleLabel.qmui_lineHeight
        var tempisShowExpand = false
        if lines <= 2{
            tempisShowExpand = false
        }else{
            tempisShowExpand = true
        }
        
        if tempisShowExpand{
            expand = 20
        }else{
            expand = 0
        }
        
        self.workModel = model
        var companyH:Float = 25
        let companyStr = model.companyName
        if companyStr.count == 0 || companyStr == ""{
            companyH = 0
        }else{
            companyH = 25
        }

        let imgArr = model.imgs.components(separatedBy: ",")
        var hang:Float = 1
        if imgArr.count > 0{
            if imgArr.count <= 3{
                hang = 1
            }else if imgArr.count <= 6{
                hang = 2
            }else if imgArr.count <= 9{
                hang = 3
            }else{
                hang = 4
            }
        }else{
            hang = 0
        }
        var imgWH:Float = Float((KSreenWidth-60-15-10)/3.0+10)
        var cityH:Float = 35
        let cityStr = model.city
        if cityStr.count == 0 || cityStr == "请选择"{
            cityH = 0
        }else{
            
        }
        if isPreview == false{//工作记录详情页
            _workModel?.cellH = Float(123-25)+gangwei+companyH+descH+expand+Float(hang*imgWH)-10+cityH+55+15
        }else{//预览工作记录
            imgWH = Float((Float(KSreenWidth)-30-40-50)/3.0+10)
            _workModel?.cellH = Float(162-58-25)+companyH+descH+expand+Float(hang*imgWH)+cityH//+55
        }
    }
    func getCellHModel()->CNLiveVitaeWorksModel{
        return _workModel!
    }
    
}


//获奖
class CNLiveViateAwardModelLayout:NSObject{
    
    ///cell高度
    var cellH:CGFloat = 0.0
//    var descH:Float = 40.0
    
    var _awardModel : CNLiveVitaeAwardsModel?
    var awardModel : CNLiveVitaeAwardsModel? {
        get{
            _awardModel
        }
        set{
            _awardModel = newValue
        }
    }
    
    init(model:CNLiveVitaeAwardsModel,descH:Float,isPreview:Bool,isExpand:Bool,isShowExpand:Bool){
        super.init()
        
        model.isExpand = isExpand
        model.isShowExpand = isShowExpand
        var expand:Float = 20
        
        let titleLabel = UILabel.init(frame: CGRectMake(0, 0, KSreenWidth-60, 40))
        titleLabel.textColor = HexColor("#999999")
        titleLabel.textAlignment = .left
        titleLabel.font = Font_14
        titleLabel.backgroundColor = .clear
        titleLabel.text = "描述"
        titleLabel.numberOfLines = 0
        titleLabel.text = model.description
        let lines = titleLabel.getRealLabelTextLines()
        let height = titleLabel.qmui_lineHeight
        var tempisShowExpand = false
        if lines <= 2{
            tempisShowExpand = false
        }else{
            tempisShowExpand = true
        }
        
        if tempisShowExpand{
            expand = 20
        }else{
            expand = 0
        }

        self.awardModel = model
        var companyH:Float = 25
        let companyStr = model.company
        if companyStr.count == 0 || companyStr == ""{
            companyH = 0
        }else{
            companyH = 25
        }
        let imgArr = model.imgs.components(separatedBy: ",")
        var hang:Float = 1
        if imgArr.count > 0{
            if imgArr.count <= 3{
                hang = 1
            }else if imgArr.count <= 6{
                hang = 2
            }else if imgArr.count <= 9{
                hang = 3
            }else{
                hang = 4
            }
        }else{
            hang = 0
        }
        var imgWH:Float = Float((KSreenWidth-60-15)/3.0+10)
        if isPreview == false{//获奖详情页
            _awardModel?.cellH = Float(123-25)+companyH+descH+expand+Float(hang*imgWH)-10+55+15
        }else{//预览获奖
            imgWH = Float((Float(KSreenWidth)-30-40-50)/3.0+10)
            _awardModel?.cellH = Float(162-58-25-25)+companyH+descH+expand+Float(hang*imgWH)//+55
        }
    }
    func getCellHModel()->CNLiveVitaeAwardsModel{
        return _awardModel!
    }
    
}