123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- //
- // CircleCommentListCommentReplyTableViewCell.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/10/17.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- class CircleCommentListCommentReplyTableViewCell: UITableViewCell {
- class func cellWith(tableView:UITableView,indexPath:IndexPath) -> CircleCommentListCommentReplyTableViewCell {
- let ID = "CircleCommentListCommentReplyTableViewCell"
- tableView.register(CircleCommentListCommentReplyTableViewCell.self, forCellReuseIdentifier: ID)
- let cell : CircleCommentListCommentReplyTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! CircleCommentListCommentReplyTableViewCell
- cell.indexPath = indexPath
- return cell
- }
-
- override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
- super.init(style: style, reuseIdentifier: reuseIdentifier)
- setupViews()
- setupLayouts()
- }
-
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- var indexPath: IndexPath? {
- didSet {
-
- }
- }
-
- func setupViews() {
- self.selectionStyle = .none
- backgroundColor = UIColor.white
- addSubview(tableView)
- }
-
- func setupLayouts() {
- tableView.snp.makeConstraints { (make) in
- make.top.bottom.equalToSuperview()
- make.left.equalTo(62)
- make.right.equalTo(-14)
- }
- }
-
- private lazy var tableView: UITableView = {
- let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
- tableView.separatorStyle = .none
- tableView.backgroundColor = kf7f8faColor
- tableView.dataSource = self
- tableView.delegate = self
- tableView.isScrollEnabled = false
- tableView.cornerRadius = 4
- tableView.masksToBounds = true
- return tableView
- }()
-
- private lazy var footerView: CircleCommnetListRepleyFooterView = {
- let footerView = CircleCommnetListRepleyFooterView(frame: CGRect(x: 0, y: 0, width: kScreenWidth - 101 - 21, height: 40))
- return footerView
- }()
-
- var communityCircleCommentListModel : CommunityCircleCommentListModel? {
- didSet {
- if communityCircleCommentListModel?.replyCount ?? 0 > 2 {
- footerView.communityCircleCommentListModel = communityCircleCommentListModel
- tableView.tableFooterView = footerView
- }
- tableView.reloadData()
- }
- }
- }
- extension CircleCommentListCommentReplyTableViewCell : UITableViewDelegate,UITableViewDataSource {
- func numberOfSections(in tableView: UITableView) -> Int {
- return communityCircleCommentListModel?.reply?.isEmpty ?? true ? 0 : 1
- }
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return communityCircleCommentListModel?.reply?.isEmpty ?? true ? 0 : communityCircleCommentListModel?.reply?.prefix(2).count ?? 0
-
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = CircleCommentListReplyTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
- cell.communityCircleCommentReplyListModel = communityCircleCommentListModel?.reply?[indexPath.row]
- return cell
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- // if communityCircleCommentListModel?.isDelete == 1 {
- // SwiftProgressHUD.shared().showText("该评论已删除,暂时不能评论")
- // }else {
- let vc = CircleCommentReplyListViewController()
- vc.communityCircleCommentListModel = communityCircleCommentListModel
- UIViewController.topMost?.navigationController?.pushViewController(vc, animated: true)
- // }
- }
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- let communityCircleCommentReplyListModel = communityCircleCommentListModel?.reply?[indexPath.row]
- let contentHeight = 17.0 + (communityCircleCommentReplyListModel?.contentHeight ?? 0.0) + 15.0
- let spacingHeight : CGFloat = 10.0 + 8.0 + 7.0
- let strHeight = contentHeight + spacingHeight
- return strHeight
- }
-
-
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 0.000001
- }
-
- func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
- return 0.000001
- }
-
- func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
- return nil
-
- }
-
- func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
- return nil
- }
- }
|