CNLiveMineMessageViewController.swift 2.31 KB
//
//  CNLiveMineMessageViewController.swift
//  metaCode
//
//  Created by open on 2023/6/20.
//

import Foundation

class CNLiveMineMessageViewController: CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource {
    
    let kCNLiveMineMessageIdentifier = "kCNLiveMineMessageIdentifier"
    var _listModel : NewsListModel!
    init(listModel: NewsListModel) {
        super.init(nibName: nil, bundle: nil)
        _listModel = listModel
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var tableView: UITableView = {
        let tableView = UITableView(frame: .zero, style: .plain)
        tableView.backgroundColor = HexColor("#F7F8FA")
        tableView.delegate = self
        tableView.dataSource = self
        tableView.separatorStyle = .none
        tableView.tableFooterView = UIView.init()
        tableView.tableHeaderView = UIView.init()
        tableView.register(MessageDescTableViewCell.self, forCellReuseIdentifier: kCNLiveMineMessageIdentifier)
        return tableView
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBarHidden = false
        titleName = _listModel.title
        
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.equalTo(get_system_nav_height())
            make.left.right.bottom.equalToSuperview()
        }
    }
    
}

extension CNLiveMineMessageViewController {
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveMineMessageIdentifier) as? MessageDescTableViewCell else {
            return MessageDescTableViewCell()
        }
        cell.setupWithDataSource(listModel: _listModel)
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 100 + _listModel.textHeight
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        showMessage(message: "跳转H5详情界面")
    }
}