fix
杨锴
2024-08-23 adc2db9bb29e7f316c46b6de679db1522ffc9cc8
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
//
//  CommentListVC.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/14.
//
 
import UIKit
import QMUIKit
import JQTools
 
class CommentListVC: BaseVC {
 
                @IBOutlet weak var view_content: UIView!
                @IBOutlet weak var tf_input: QMUITextField!
                @IBOutlet weak var label_questionNum: UILabel!
                @IBOutlet weak var tableView: UITableView!
                @IBOutlet weak var cons_height: NSLayoutConstraint!
                
    override func viewDidLoad() {
        super.viewDidLoad()
                                view.backgroundColor = .clear
                                tf_input.tintColor = Def_ThemeColor
                                tableView.separatorStyle = .none
                                tableView.delegate = self
                                tableView.dataSource = self
                                if #available(iOS 15.0, *) {
                                                tableView.sectionHeaderTopPadding = 0
                                }
 
                                cons_height.constant = JQ_ScreenH - 151 - JQ_NavBarHeight - UIDevice.jq_safeEdges.top - UIDevice.jq_safeEdges.bottom
                                tableView.register(CommentCommentHeaderView.self, forHeaderFooterViewReuseIdentifier: "_header")
                                tableView.register(CommentReplyTCell.self, forCellReuseIdentifier: "_CommentReplyTCell")
    }
 
                override func viewDidLayoutSubviews() {
                                super.viewDidLayoutSubviews()
                                view_content.jq_cornerPart(byRoundingCorners: [.topLeft,.topRight], radii: 20)
                }
 
                @IBAction func closeAction(_ sender: UIButton) {
                                self.dismiss(animated: true)
                }
                
                @IBAction func sendAction(_ sender: UIButton) {
 
                }
 
                @objc func longPressAction(_ gesture:UITapGestureRecognizer){
                                if gesture.state == .began {
                                                // 当长按开始时,你可以获取到 cell 的信息
                                                if let headerView = gesture.view as? CommentCommentHeaderView {
                                                                let index = headerView.tag - 1000
                                                                ChooseOptView.show(titles: ["举报提问","拉入黑名单"]) { _ in
                                                                                
                                                                }
                                                }
                                }
                }
}
 
extension CommentListVC:UITableViewDelegate & UITableViewDataSource{
 
                func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
                                let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "_header") as! CommentCommentHeaderView
                                headerView.tag = section + 1000
 
                                if headerView.gestureRecognizers == nil{
                                                let longPress    = UILongPressGestureRecognizer(target: self, action: #selector(longPressAction))
                                                longPress.minimumPressDuration = 0.5
                                                headerView.addGestureRecognizer(longPress)
                                }
 
                                return headerView
                }
 
                func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
                                return UITableView.automaticDimension
                }
 
                func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
                                return 0.001
                }
 
                func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
                                return UITableView.automaticDimension
                }
 
                func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                                var cell = tableView.dequeueReusableCell(withIdentifier: "_CommentReplyTCell", for: indexPath) as? CommentReplyTCell
 
                                cell?.setText(text: "助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。助力13亿女性及其家庭生命蜕变,幸福重生的伟大愿景。")
                                return cell!
                }
 
                func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
                                return 1
                }
 
                func numberOfSections(in tableView: UITableView) -> Int {
                                return 2
                }
}
 
class CommentReplyTCell:UITableViewCell{
 
                private lazy var label_content:UILabel = {
                                let label = UILabel()
                                label.textColor = UIColor(hexString: "#383838")
                                label.numberOfLines = 0
                                return label
 
                }()
 
                override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
                                super.init(style: .default, reuseIdentifier: reuseIdentifier)
                                if !self.contentView.subviews.contains(label_content){
                                                self.selectionStyle = .none
                                                self.contentView.addSubview(label_content)
                                                label_content.snp.makeConstraints { make in
                                                                make.top.equalToSuperview().offset(5)
                                                                make.left.equalTo(72.5)
                                                                make.right.equalTo(-28.5)
                                                                make.height.greaterThanOrEqualTo(0)
                                                                make.bottom.equalToSuperview().offset(0).priority(800)
                                                }
                                }
                }
 
                func setText(text:String){
                                label_content.attributedText = AttributedStringbuilder().add(string: "平台回复:", withFont: .systemFont(ofSize: 12.5, weight: .bold), withColor: UIColor(hexString: "#383838")!,lineSpace: 5)
                                                .add(string: text, withFont: .systemFont(ofSize: 12.5), withColor: UIColor(hexString: "#383838")!,lineSpace: 5).mutableAttributedString
 
                }
 
                required init?(coder: NSCoder) {
                                fatalError("init(coder:) has not been implemented")
                }
}