CNLiveDigitalSecCell.swift
5.31 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//
// CNLiveDigitalSecCell.swift
// metaCode
//
// Created by zx on 2024/6/17.
// 数字资产-身份cell
import Foundation
import Kingfisher
import SnapKit
class CNLiveDigitalSecCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource {
lazy var whiteView :UIView = {
let whiteView = UIView(frame: CGRect(x: 15, y:adapt_length(length: 15), width: KSreenWidth-30, height: adapt_length(length: 152)))
whiteView.backgroundColor = .white
whiteView.layer.cornerRadius = 12
whiteView.clipsToBounds = true
return whiteView
}()
lazy var myIdentityTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .center
titleLabel.text = "官方认证"
titleLabel.font = BoldFont_16
return titleLabel
}()
let kCNLiveDigitalSecCollectCellID = "kCNLiveDigitalSecCollectCellID"
lazy var threeCollectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSizeMake(adapt_length(length: 60), adapt_length(length: 60+3+17))
layout.minimumLineSpacing = (KSreenWidth-30-adapt_length(length: 60)*3-36)/2//22
layout.scrollDirection = .horizontal
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.backgroundColor = .white
collectionView.register(CNLiveDigitalSecCollectionCell.self, forCellWithReuseIdentifier: kCNLiveDigitalSecCollectCellID)
return collectionView
}()
var currSeleIndex = 0
var _digitalListModels : [MineAuthListModel]?
var digitalListModels : [MineAuthListModel]? {
get{
_digitalListModels
}
set{
_digitalListModels = newValue!
setupNewUI(models: _digitalListModels!)
}
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.contentView.backgroundColor = .clear
self.backgroundColor = .clear
self.selectionStyle = .none
self.contentView.addSubview(self.whiteView)
self.whiteView.addSubview(self.myIdentityTitleLabel)
self.myIdentityTitleLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(adapt_length(length: 15))
make.left.equalTo(adapt_length(length: 15))
}
self.whiteView.addSubview(self.threeCollectionView)
self.threeCollectionView.snp.makeConstraints { make in
make.left.right.equalToSuperview().offset(adapt_length(length: 18))
make.top.equalTo(adapt_length(length: 53))
make.height.equalTo(adapt_length(length: 60+7+17))
make.width.equalToSuperview().offset(adapt_length(length: -36))
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// @objc func zhengshuBtnAction(){
// self.show17Alert()
// }
// @objc func gongzuoBtnAction(){
// self.show17Alert()
// }
// @objc func shetuanBtnAction(){
// self.show17Alert()
// }
// @objc func huojiangBtnAction(){
// self.show17Alert()
// }
// // MARK: - 点击弹窗,按类型跳转
// @objc func alertBgImgViewClickAction() {
// self.hiden17Alert()
// }
// @objc func alertBgViewClickAction() {
// //点击蒙版隐藏view
// self.hiden17Alert()
// }
//
// //弹出弹窗
// func show17Alert(){
//
// delegate.window?.addSubview(self.alertBgView)
// delegate.window?.addSubview(self.alertBgImgView)
// alertBgImgView.snp.makeConstraints { make in
// make.centerX.equalToSuperview()
// make.centerY.equalToSuperview()
// make.width.equalTo(KSreenWidth-80)
// make.height.equalTo((KSreenWidth-80)*170.5/295)
// }
//
// self.alertBgImgView.image = UIImage(named: "auth_alert_unOpen")
// }
// func hiden17Alert(){
// delegate.window?.subviews.forEach({ view in
// if view.tag >= 20000{
// view.removeFromSuperview()
// }
// })
// }
//
func setupNewUI(models:[MineAuthListModel]){
self.threeCollectionView.reloadData()
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
self.digitalListModels?.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveDigitalSecCollectCellID, for: indexPath) as! CNLiveDigitalSecCollectionCell
cell.authListModel = self.digitalListModels?[indexPath.row]
if indexPath.row == currSeleIndex
{//
cell.cellIsSelected = true
}else{
//
cell.cellIsSelected = false
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
self.currSeleIndex = indexPath.row
self.threeCollectionView.reloadData()
}
}