宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
//  JobTCell.swift
//  OKProject
//
//  Created by 无故事王国 on 2022/5/16.
//  Copyright © 2022 yangwang. All rights reserved.
//
 
import UIKit
import RxSwift
 
class JobTCell: UITableViewCell {
 
    @IBOutlet weak var titleL: UILabel!
    @IBOutlet weak var priceL: UILabel!
    @IBOutlet weak var collectionView: UICollectionView!
    @IBOutlet weak var collectionViewHeiCons: NSLayoutConstraint!
    private var jobListModel:JobListModel?
    private var disposeBag = DisposeBag()
    override func awakeFromNib() {
        super.awakeFromNib()
        selectionStyle = .none
        collectionView.delegate = self
        collectionView.dataSource = self
        collectionView.register(UINib(nibName: "Common_SingleText_CCell", bundle: nil), forCellWithReuseIdentifier: "_Common_SingleText_CCell")
    }
 
    func setJobListModel(_ m:JobListModel){
        jobListModel = m
 
        //75002 [司机招募]招聘信息显示标题(内外一致)且需将面议招聘信息显示为薪资面议
        titleL.text = m.title
        if m.startSalary == 0 && m.endSalary == 0{
            priceL.text = "薪资面议"
        }else{
            priceL.text = String(format: "%.2lf-%.2lf元/月", m.startSalary,m.endSalary)
        }
        collectionView.reloadData()
    }
}
 
extension JobTCell:UICollectionViewDelegate{
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
 
    }
}
 
extension JobTCell:UICollectionViewDataSource{
 
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return jobListModel!.welfare.components(separatedBy: ",").filter({!$0.isEmpty}).count
    }
 
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let text = jobListModel!.welfare.components(separatedBy: ",").filter({!$0.isEmpty})[indexPath.row]
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_Common_SingleText_CCell", for: indexPath) as! Common_SingleText_CCell
        cell.titleL.text = text
        cell.titleL.font = UIFont.systemFont(ofSize: 12)
        cell.titleL.cornerRadius = 2
        cell.titleL.borderWidth = 0.6
        cell.titleL.maskToBounds = true
        cell.titleL.borderColor = UIColor.color(hexString: "#00BF30")
        cell.titleL.backgroundColor = .white
        cell.titleL.textColor = UIColor.color(hexString: "#00BF30")
        return cell
    }
}
 
extension JobTCell:UICollectionViewDelegateFlowLayout{
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
        return 8
    }
 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
        return 8
    }
 
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        let title = jobListModel!.welfare.components(separatedBy: ",").filter({!$0.isEmpty})[indexPath.row]
       let calCellW = title.width(UIFont.systemFont(ofSize: 12), height: 18)
        return CGSize(width: calCellW+6, height: 18)
    }
}