CNLiveMineViewController.swift
4.93 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
//
// CNLiveMineViewController.swift
// metaCode
//
// Created by open on 2023/6/6.
//
import Foundation
class CNLiveMineViewController : CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource{
let kCNLiveMineOneViewCellIdentifier = "kCNLiveMineOneViewCellIdentifier"
let kCNLiveMineTwoViewCellIdentifier = "kCNLiveMineTwoViewCellIdentifier"
lazy var tableView : UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.dataSource = self
tableView.delegate = self
tableView.backgroundColor = .clear
tableView.tableFooterView = UIView.init()
tableView.separatorStyle = .none
tableView.register(MineBodyOneListViewCell.self, forCellReuseIdentifier: kCNLiveMineOneViewCellIdentifier)
tableView.register(MineBodyTwoListViewCell.self, forCellReuseIdentifier: kCNLiveMineTwoViewCellIdentifier)
return tableView
}()
lazy var mainView: UIImageView = {
let mainView = UIImageView.init()
mainView.backgroundColor = .clear
mainView.image = UIImage(named: "mine_header_icon_back")
mainView.contentMode = .scaleAspectFill
return mainView
}()
lazy var dataArray: NSMutableArray = {
let dataArray = NSMutableArray()
let array00 : [Dictionary] = [["name":"我的身份","icon":"mine_header_icon_identity"]]
dataArray.add(array00)
let array01 : [Dictionary] = [["name":"添加身份","icon":"mine_list_icon_add_identity"]]
dataArray.add(array01)
let array02 : [Dictionary] = [["name":"帮助与反馈","icon":"mine_list_icon_help_feedback"],
["name":"更多设置","icon":"mine_list_icon_set_more"]]
dataArray.add(array02)
return dataArray
}()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = HexColor("#f9f9f9")
setNeedsStatusBarAppearanceUpdate()
view.addSubview(mainView)
mainView.snp.makeConstraints { make in
make.left.top.right.equalToSuperview()
make.height.equalTo(KSreenHeight * 0.4)
}
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
deinit {
}
}
extension CNLiveMineViewController {
func numberOfSections(in tableView: UITableView) -> Int {
return dataArray.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return (dataArray[section] as AnyObject).count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineOneViewCellIdentifier) as! MineBodyOneListViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineTwoViewCellIdentifier) as! MineBodyTwoListViewCell
let array = dataArray[indexPath.section]
let sub_dict = (array as! Array<Any>)[indexPath.row]
cell.setupWithDataSource(show_type: .feedback,dict: sub_dict as! Dictionary<String, Any>)
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 0 {
return 120
}
return 60
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section == 1 {
self.navigationController?.pushViewController(CNLiveMineAddInfoViewController.init(show_type: .add), animated: true)
}
if indexPath.section == 2 && indexPath.row == 0 {
self.navigationController?.pushViewController(CNLiveHelpFeedBackViewController.init(), animated: true)
}
if indexPath.section == 2 && indexPath.row == 1 {
self.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .setting), animated: true)
}
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return 150
}
return 0.001
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 0 {
let headerView = MineHeaderView.init(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: 80))
return headerView
}
return UIView.init()
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offsetY = scrollView.contentOffset.y
mainView.height = offsetY < 0 ? (KSreenHeight * 0.4) + abs(offsetY) : KSreenHeight * 0.4;
}
}