CNLiveDigitalAuthCell.swift
4.25 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// CNLiveDigitalAuthCell.swift
// metaCode
//
// Created by zx on 2024/6/5.
// 数字认证cell
import Foundation
import Kingfisher
import SnapKit
typealias SelectBlock = (_ currentCell: CNLiveDigitalAuthCell ,_ identitiesId:String) -> Void
class CNLiveDigitalAuthCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource {
lazy var lineView :UIView = {
let lineView = UIView(frame: CGRect(x: 0, y: 19, width: 3, height: 15))
lineView.backgroundColor = HexColor("#1F64E3")
return lineView
}()
lazy var twoTitleLabel: UILabel = {
let titleLabel = UILabel.init(frame: CGRectMake(self.lineView.right+19, 15, KSreenWidth-30-40, 23))
titleLabel.textColor = HexColor("#1F64E3")
titleLabel.textAlignment = .left
titleLabel.font = Font_16
return titleLabel
}()
//3级身份列表
lazy var threeArr: [MineAuthenticationsChildIdentitiesModel] = {
var threeArr = [MineAuthenticationsChildIdentitiesModel]()
return threeArr
}()
let kCNLiveDigitalThreeCollectCellID = "kCNLiveDigitalThreeCollectCellID"
lazy var threeCollectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSizeMake(100, 93)
layout.minimumLineSpacing = 10
layout.scrollDirection = .horizontal
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.backgroundColor = .white
collectionView.register(CNLiveDigitalThreeCollectCell.self, forCellWithReuseIdentifier: kCNLiveDigitalThreeCollectCellID)
return collectionView
}()
//childModel
var _childModel : MineAuthenticationsChildModel?
var childModel : MineAuthenticationsChildModel? {
get{
_childModel
}
set{
_childModel = newValue!
setupNewUI(model: _childModel!)
}
}
var _tblCellIsSelect:Bool = false
var tblCellIsSelect:Bool{
get{
_tblCellIsSelect
}
set{
_tblCellIsSelect = newValue
}
}
var currentSeleIndex = 0
var selectBlock:SelectBlock?
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.contentView.addSubview(self.lineView)
self.contentView.addSubview(self.twoTitleLabel)
self.contentView.addSubview(self.threeCollectionView)
self.threeCollectionView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(self.twoTitleLabel.snp.bottom).offset(20)
make.height.equalTo(93)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewUI(model:MineAuthenticationsChildModel){
self.twoTitleLabel.text = model.name
self.threeArr = model.identities
self.threeCollectionView.reloadData()
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
self.childModel?.identities.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveDigitalThreeCollectCellID, for: indexPath) as! CNLiveDigitalThreeCollectCell
if indexPath.row == currentSeleIndex{
if self.tblCellIsSelect == true{
cell.cellIsSelected = true
}else{
cell.cellIsSelected = false
}
}else{
cell.cellIsSelected = false
}
cell.identitiesModel = self.threeArr[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// let identitiesModel = self.threeArr[indexPath.row]
currentSeleIndex = indexPath.row
let identitiesModel = self.threeArr[indexPath.row]
self.threeCollectionView.reloadData()
self.selectBlock?(self,identitiesModel.id)
}
}