CNLiveTotalHotListController.swift
4.48 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
//
// CNLiveTotalHotListController.swift
// metaCode
//
// Created by zx on 2024/5/22.
// 实时热榜详情页
import Foundation
class CNLiveTotalHotListController:CNLiveBaseViewController, UICollectionViewDelegate, UICollectionViewDataSource{
var slideModel:CNLiveDownSlideModel?
//实时热榜的列表
lazy var realHotArr: NSMutableArray = {
var realHotArr = NSMutableArray()
return realHotArr
}()
let kRealHotListCollectionViewCellIdentifier = "kRealHotListCollectionViewCellIdentifier"
let kRealHotListCollectionViewImageCellIdentifier = "kRealHotListCollectionViewImageCellIdentifier"
lazy var realHotCollectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .vertical
layout.itemSize = CGSizeMake(KSreenWidth, 138+15)
layout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
layout.minimumLineSpacing = 15
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.delegate = self
cv.dataSource = self
cv.backgroundColor = .white
cv.register(CNLiveRealHotListDetailCell.self, forCellWithReuseIdentifier: kRealHotListCollectionViewCellIdentifier)
cv.register(CNLiveRealHotListDetailImageCell.self, forCellWithReuseIdentifier: kRealHotListCollectionViewImageCellIdentifier)
return cv
}()
lazy var closeBtn: UIButton = {
let closeBtn = UIButton(type: .custom)
closeBtn.frame = CGRect(x: 0, y: KStatusBarHeight, width: 50, height: 30)
closeBtn.centerY = self.titleLabel.centerY
closeBtn.setImage(UIImage(named: "mine_header_icon_white_back"), for: .normal)
closeBtn.addTarget(self, action: #selector(changeCancelAction), for: .touchUpInside)
return closeBtn
}()
/// 初始化播放器,第多少集
init(slideModel:CNLiveDownSlideModel?) {
super.init(nibName:nil, bundle:nil)
self.slideModel = slideModel
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .white
self.view.addSubview(self.realHotCollectionView)
self.realHotCollectionView.frame = CGRect(x: 0, y: 0, width: KSreenWidth, height: KSreenHeight)
self.realHotArr = NSMutableArray(array: self.slideModel!.contents)
self.realHotCollectionView.reloadData()
self.view.addSubview(self.closeBtn)
}
func initUI(){
self.view.addSubview(self.realHotCollectionView)
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
self.realHotArr.count+1
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.row == 0{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kRealHotListCollectionViewImageCellIdentifier, for: indexPath) as! CNLiveRealHotListDetailImageCell
// 加载和设置图片到 cell.imageView
cell.iconImgView.kf.setImage(with: URL(string: self.slideModel?.background ?? ""))
return cell
}else{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kRealHotListCollectionViewCellIdentifier, for: indexPath) as! CNLiveRealHotListDetailCell
cell.num = indexPath.row
// 加载和设置图片到 cell.imageView
cell.contentsModel = self.realHotArr[indexPath.row-1] as? CNLiveDownSlideContentsModel
return cell
}
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if indexPath.row == 0{
}else{
if let contentMdl = self.realHotArr[indexPath.row-1] as? CNLiveDownSlideContentsModel{
//实时热榜点击短剧
CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl.model , contentId: contentMdl.contentId , pid: contentMdl.pid , shareUrl: contentMdl.shareUrl , thirdUrl: contentMdl.thirdUrl , title: contentMdl.title , s_to: contentMdl.s_to ,trailerId: contentMdl.trailerId , controller: nil, slideModel: self.slideModel)
}
}
}
@objc func changeCancelAction() {
self.navigationController?.popViewController(animated: true)
}
deinit {
}
}