//
|
// 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")
|
}
|
}
|