CNLiveMinePlayHistoryCell.swift
10.4 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
//
// CNLiveMinePlayHistoryCell.swift
// metaCode
//
// Created by zx on 2025/3/15.
// 播放记录
import Foundation
class CNLiveMinePlayHistoryCell : UITableViewCell ,UICollectionViewDelegate, UICollectionViewDataSource {
lazy var albumListArr: NSMutableArray = {
var albumListArr = NSMutableArray()
return albumListArr
}()
let kCNLiveMinePlayHistoryCollectionCellIdentifier = "kCNLiveMinePlayHistoryCollectionCellIdentifier"
lazy var realHotCollectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
layout.itemSize = CGSizeMake(165, 93+76)
layout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
layout.minimumLineSpacing = 5
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.delegate = self
cv.dataSource = self
cv.backgroundColor = .white
cv.showsHorizontalScrollIndicator = false
cv.register(CNLiveMinePlayHistoryCollectionCell.self, forCellWithReuseIdentifier: kCNLiveMinePlayHistoryCollectionCellIdentifier)
return cv
}()
//CNLiveHomeFollowModel
var _followModels : [CNLiveHomeFollowModel]?
var followModels : [CNLiveHomeFollowModel]? {
get{
_followModels
}
set{
_followModels = newValue!
self.setupNewUI(model: _followModels!)
}
}
lazy var mainView: UIView = {
let mainView = UIView.init()
mainView.backgroundColor = .white
mainView.layer.cornerRadius = 15
mainView.layer.masksToBounds = true
return mainView
}()
lazy var playIconView: UIImageView = {
let headerView = UIImageView.init()
headerView.backgroundColor = .clear
headerView.image = UIImage(named: "mine_playHistory")
headerView.contentMode = .scaleToFill
return headerView
}()
lazy var nameLabel: UILabel = {
let nameLabel = UILabel.init()
nameLabel.textColor = .black
nameLabel.font = BoldFont_16_Fit
nameLabel.text = "播放记录"
nameLabel.backgroundColor = .clear
return nameLabel
}()
lazy var moreBtn: UIButton = {
let moreBtn = UIButton.init(type: .custom)
moreBtn.setImage(UIImage(named: "mine_list_icon_right_more"), for: .normal)
moreBtn.layer.masksToBounds = true
moreBtn.layer.cornerRadius = 15
moreBtn.isUserInteractionEnabled = false
return moreBtn
}()
lazy var iconImgView1 :UIImageView = {
let imageView = UIImageView()
imageView.tag = 1000
imageView.layer.cornerRadius = 9
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
return imageView
}()
lazy var iconImgView2 :UIImageView = {
let imageView = UIImageView()
imageView.tag = 1001
imageView.layer.cornerRadius = 9
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
return imageView
}()
lazy var lineView :UIView = {
let bottomNavView = UIView(frame: CGRect(x: 35, y: 0, width: KSreenWidth-35*2, height: 0.5))
bottomNavView.backgroundColor = HexColor("#EAEAEA")
return bottomNavView
}()
lazy var collectionIconView: UIImageView = {
let headerView = UIImageView.init()
headerView.backgroundColor = .clear
headerView.image = UIImage(named: "mine_mineCollection")
headerView.contentMode = .scaleToFill
return headerView
}()
lazy var collectionNameLabel: UILabel = {
let nameLabel = UILabel.init()
nameLabel.textColor = .black
nameLabel.font = BoldFont_16_Fit
nameLabel.text = "我的收藏"
nameLabel.backgroundColor = .clear
return nameLabel
}()
lazy var collMoreBtn: UIButton = {
let moreBtn = UIButton.init(type: .custom)
moreBtn.setImage(UIImage(named: "mine_list_icon_right_more"), for: .normal)
moreBtn.layer.masksToBounds = true
moreBtn.layer.cornerRadius = 15
moreBtn.isUserInteractionEnabled = false
return moreBtn
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
self.backgroundColor = .clear
contentView.backgroundColor = .clear
addSubview(mainView)
mainView.addSubview(playIconView)
mainView.addSubview(nameLabel)
mainView.addSubview(moreBtn)
mainView.addSubview(iconImgView1)
mainView.addSubview(self.realHotCollectionView)
self.contentView.clipsToBounds = true
// realHotCollectionView.isHidden = true
mainView.addSubview(lineView)
mainView.addSubview(collectionIconView)
mainView.addSubview(collectionNameLabel)
mainView.addSubview(collMoreBtn)
mainView.addSubview(iconImgView2)
setupConstraints()
}
private func setupConstraints() {
mainView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.left.equalToSuperview().offset(15)
make.right.equalToSuperview().offset(-15)
make.top.bottom.equalToSuperview()
}
playIconView.snp.makeConstraints { make in
make.left.equalTo(15)
make.top.equalTo(15)
make.height.equalTo(19)
make.width.equalTo(19)
}
nameLabel.snp.makeConstraints { make in
make.centerY.equalTo(playIconView.snp.centerY)
make.left.equalTo(playIconView.snp.right).offset(10)
}
moreBtn.snp.makeConstraints { make in
make.top.equalTo(0)
make.right.equalToSuperview()
make.height.equalTo(12+30)
make.width.equalTo(12+30)
}
iconImgView1.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(50)
}
realHotCollectionView.snp.makeConstraints { make in
make.top.equalTo(50)
make.left.equalTo(15)
make.height.equalTo(56+93)
make.right.equalToSuperview()
}
lineView.snp.makeConstraints { make in
make.top.equalTo(self.realHotCollectionView.snp.bottom).offset(10)
make.right.equalToSuperview().offset(-15)
make.height.equalTo(0.5)
make.width.equalToSuperview().offset(-30)
}
collectionIconView.snp.makeConstraints { make in
make.left.equalTo(self.playIconView.snp.left)
make.top.equalTo(self.lineView.snp.bottom).offset(17)
make.height.equalTo(19)
make.width.equalTo(19)
}
collectionNameLabel.snp.makeConstraints { make in
make.centerY.equalTo(collectionIconView.snp.centerY)
make.left.equalTo(collectionIconView.snp.right).offset(10)
}
collMoreBtn.snp.makeConstraints { make in
make.centerY.equalTo(collectionIconView.snp.centerY)
make.right.equalToSuperview()
make.height.equalTo(12+30)
make.width.equalTo(12+30)
}
iconImgView2.snp.makeConstraints { make in
make.top.equalTo(self.lineView.snp.bottom)
make.left.right.bottom.equalToSuperview()
}
}
func setupNewUI(model:[CNLiveHomeFollowModel]){
if model.count > 0{
}else{
realHotCollectionView.snp.remakeConstraints({ make in
make.top.equalTo(40)
make.left.equalTo(15)
make.height.equalTo(0)
make.right.equalToSuperview()
})
}
self.albumListArr = NSMutableArray(array: model)
self.realHotCollectionView.reloadData()
}
@objc func imgTapAction(ges: UITapGestureRecognizer){
let imageView = ges.view as! UIImageView
let i = imageView.tag-1000
if i == 0{
//播放记录
let vc = CNLiveHomeMoreController()
vc.followModels = self.followModels
currentViewController()?.navigationController?.pushViewController(vc, animated: true)
}else if i == 1{
//我的收藏
if metaAppDelegate.isLogin{
let vc = CNLiveHomeMoreController()
currentViewController()?.navigationController?.pushViewController(vc, animated: true)
}else{
metaAppDelegate.pushLoginVC()
}
}
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
self.albumListArr.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveMinePlayHistoryCollectionCellIdentifier, for: indexPath) as! CNLiveMinePlayHistoryCollectionCell
cell.layer.cornerRadius = 9
cell.clipsToBounds = true
cell.num = indexPath.row
//获取当前选中集数
if indexPath.row == 0{
cell.isJiShuSelected = true
}else{
cell.isJiShuSelected = false
}
cell.followModel = self.albumListArr[indexPath.row] as? CNLiveHomeFollowModel
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let contentMdl = self.albumListArr[indexPath.row] as? CNLiveHomeFollowModel{
//看参数对不对
CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: contentMdl.modelId , contentId: contentMdl.contentId , pid: contentMdl.activeId , shareUrl: contentMdl.shareUrl , thirdUrl: contentMdl.shareUrl , title: contentMdl.title , s_to: "" ,trailerId: "" , controller: nil, slideModel: nil)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}