CNLivePlayletHomePageController.swift
3.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
//
// CNLivePlayletHomePageController.swift
// metaCode
//
// Created by zx on 2024/1/4.
// 短剧主页
import Foundation
class CNLivePlayletHomePageController:CNLiveBaseViewController, UITableViewDataSource, UITableViewDelegate{
var jianjieLblHeight:CGFloat = 36
let kCNLivePlayletCellIdentifier = "kCNLivePlayletCellIdentifier"
let kCNLivePlayletHeaderCellIdentifier = "kCNLivePlayletHeaderCellIdentifier"
///数据源
var albumModelArr:Array<CNLiveAlbumListModel>?
// MARK: - 懒加载
lazy var tableView : UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .none
tableView.tableFooterView = UIView.init()
tableView.register(CNLivePlayletHomePageCell.self, forCellReuseIdentifier: kCNLivePlayletCellIdentifier)
tableView.register(CNLivePlayletHomePageHeaderCell.self, forCellReuseIdentifier: kCNLivePlayletHeaderCellIdentifier)
return tableView
}()
init(albumModelArr:Array<CNLiveAlbumListModel>) {
self.albumModelArr = Array(albumModelArr)
super.init(nibName: nil, bundle: nil)
self.tableView.reloadData()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
self.setUI()
}
func setUI(){
navigationBarHidden = false
self.view.addSubview(self.tableView)
self.tableView.frame = CGRect(x: 0, y: KNavigationHeight, width: KSreenWidth, height: KSreenHeight-KNavigationHeight)
}
func numberOfSections(in tableView: UITableView) -> Int {
2
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 0{
return 1
}
return self.albumModelArr!.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0{
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLivePlayletHeaderCellIdentifier) as? CNLivePlayletHomePageHeaderCell
else {
let cell = CNLivePlayletHomePageHeaderCell()
return cell
}
cell.homePageHeaderCellChangedBlock = { headerCell,jianjieHeight in
self.jianjieLblHeight = jianjieHeight
self.tableView.reloadData()
}
let albumListModel = self.albumModelArr![0]
cell.albumListModel = albumListModel
return cell
}else{
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLivePlayletCellIdentifier) as? CNLivePlayletHomePageCell
else {
let cell = CNLivePlayletHomePageCell()
return cell
}
let albumListModel = self.albumModelArr![indexPath.row]
cell.albumListModel = albumListModel
return cell
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 0{
return 15+147+20+self.jianjieLblHeight+25+39+23.5+15.5
}else{
return 75+12*2
}
}
}