瀏覽代碼

有评论的评论Cell -- finished

Chris 5 年之前
父節點
當前提交
51cd2f4f2f

+ 4 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -367,6 +367,7 @@
 		BD12204E22AFB07E0051C7C2 /* MessageThumbController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12204D22AFB07E0051C7C2 /* MessageThumbController.swift */; };
 		BD12204E22AFB07E0051C7C2 /* MessageThumbController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12204D22AFB07E0051C7C2 /* MessageThumbController.swift */; };
 		BD12205022AFB08B0051C7C2 /* MessageThumbTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12204F22AFB08B0051C7C2 /* MessageThumbTableCell.swift */; };
 		BD12205022AFB08B0051C7C2 /* MessageThumbTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12204F22AFB08B0051C7C2 /* MessageThumbTableCell.swift */; };
 		BD12B66922B47D4800AEB10B /* RecommendSubCommentCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B66822B47D4700AEB10B /* RecommendSubCommentCollectionCell.swift */; };
 		BD12B66922B47D4800AEB10B /* RecommendSubCommentCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B66822B47D4700AEB10B /* RecommendSubCommentCollectionCell.swift */; };
+		BD12B66B22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B66A22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift */; };
 		BD1DC6C5228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C3228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift */; };
 		BD1DC6C5228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C3228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift */; };
 		BD1DC6C6228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C4228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift */; };
 		BD1DC6C6228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C4228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift */; };
 		BD1DC6C9228D005000B89C57 /* OrderCreateParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */; };
 		BD1DC6C9228D005000B89C57 /* OrderCreateParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */; };
@@ -838,6 +839,7 @@
 		BD12204D22AFB07E0051C7C2 /* MessageThumbController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageThumbController.swift; sourceTree = "<group>"; };
 		BD12204D22AFB07E0051C7C2 /* MessageThumbController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageThumbController.swift; sourceTree = "<group>"; };
 		BD12204F22AFB08B0051C7C2 /* MessageThumbTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageThumbTableCell.swift; sourceTree = "<group>"; };
 		BD12204F22AFB08B0051C7C2 /* MessageThumbTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageThumbTableCell.swift; sourceTree = "<group>"; };
 		BD12B66822B47D4700AEB10B /* RecommendSubCommentCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSubCommentCollectionCell.swift; sourceTree = "<group>"; };
 		BD12B66822B47D4700AEB10B /* RecommendSubCommentCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSubCommentCollectionCell.swift; sourceTree = "<group>"; };
+		BD12B66A22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSubCommentCollectionFooter.swift; sourceTree = "<group>"; };
 		BD1DC6C3228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftMoyaNetWorkServiceOrder.swift; sourceTree = "<group>"; };
 		BD1DC6C3228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftMoyaNetWorkServiceOrder.swift; sourceTree = "<group>"; };
 		BD1DC6C4228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftMoyaServiceOrderApi.swift; sourceTree = "<group>"; };
 		BD1DC6C4228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftMoyaServiceOrderApi.swift; sourceTree = "<group>"; };
 		BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCreateParameterModel.swift; sourceTree = "<group>"; };
 		BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCreateParameterModel.swift; sourceTree = "<group>"; };
@@ -3471,6 +3473,7 @@
 				BDAF83B322B3B6DF0004BCC3 /* RecommendMajorCommentCell.swift */,
 				BDAF83B322B3B6DF0004BCC3 /* RecommendMajorCommentCell.swift */,
 				BDAF83B122B3B67D0004BCC3 /* RecommendCommentFooter.swift */,
 				BDAF83B122B3B67D0004BCC3 /* RecommendCommentFooter.swift */,
 				BD12B66822B47D4700AEB10B /* RecommendSubCommentCollectionCell.swift */,
 				BD12B66822B47D4700AEB10B /* RecommendSubCommentCollectionCell.swift */,
+				BD12B66A22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift */,
 			);
 			);
 			path = "全部评论的Cell";
 			path = "全部评论的Cell";
 			sourceTree = "<group>";
 			sourceTree = "<group>";
@@ -3825,6 +3828,7 @@
 				A72A72BB22321DE000B21995 /* Extension+UILabel.swift in Sources */,
 				A72A72BB22321DE000B21995 /* Extension+UILabel.swift in Sources */,
 				A70B2C372288177300B2449F /* ProductDetailProductLabelIconCollectionViewCell.swift in Sources */,
 				A70B2C372288177300B2449F /* ProductDetailProductLabelIconCollectionViewCell.swift in Sources */,
 				BDAF83A822B343C50004BCC3 /* RecommendBottomCommentView.swift in Sources */,
 				BDAF83A822B343C50004BCC3 /* RecommendBottomCommentView.swift in Sources */,
+				BD12B66B22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift in Sources */,
 				A77F2C9E2231FDDC001BD3F6 /* BaseViewController.swift in Sources */,
 				A77F2C9E2231FDDC001BD3F6 /* BaseViewController.swift in Sources */,
 				A7284A75225465DD000BAEC4 /* SwiftMoyaNetWorkServicePay.swift in Sources */,
 				A7284A75225465DD000BAEC4 /* SwiftMoyaNetWorkServicePay.swift in Sources */,
 				A77F2CC722320627001BD3F6 /* WRNavigationBar.swift in Sources */,
 				A77F2CC722320627001BD3F6 /* WRNavigationBar.swift in Sources */,

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/Controller/CommunityRecommendController.swift

@@ -47,7 +47,7 @@ class CommunityRecommendController: BaseViewController {
         tableView.backgroundColor = kf7f8faColor
         tableView.backgroundColor = kf7f8faColor
         tableView.dataSource = self
         tableView.dataSource = self
         tableView.delegate = self
         tableView.delegate = self
-        tableView.estimatedRowHeight = UITableView.automaticDimension
+        tableView.estimatedRowHeight = 200
         tableView.estimatedSectionFooterHeight = 0.000001
         tableView.estimatedSectionFooterHeight = 0.000001
         tableView.estimatedSectionHeaderHeight = 0.000001
         tableView.estimatedSectionHeaderHeight = 0.000001
         return tableView
         return tableView

+ 21 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/全部评论的Cell/RecommendMajorCommentCell.swift

@@ -175,7 +175,7 @@ extension RecommendMajorCommentCell: UICollectionViewDelegateFlowLayout,UICollec
     }
     }
     
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        let cell = RecommendSubCommentCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        let cell = RecommendSubCommentCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)                
         
         
         return cell
         return cell
     }
     }
@@ -183,5 +183,24 @@ extension RecommendMajorCommentCell: UICollectionViewDelegateFlowLayout,UICollec
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         print("点击了collection--\(indexPath.row)")
         print("点击了collection--\(indexPath.row)")
     }
     }
-        
+    
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
+        let cell = RecommendSubCommentCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        return CGSize(width:kScreenWidth - 62, height: cell.timeLabel.ly_maxY)
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
+        if kind == UICollectionView.elementKindSectionFooter {
+            let footerView = RecommendSubCommentCollectionFooter.footerWith(collectionView: collectionView, kind: UICollectionView.elementKindSectionFooter, indexPath: indexPath)
+            return footerView
+        }else {
+            return UICollectionReusableView()
+        }        
+    }
+    
+    // 返回FooterView的宽高
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
+        return CGSize(width:kScreenWidth - 62, height: 40)
+    }
+    
 }
 }

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/全部评论的Cell/RecommendSubCommentCollectionCell.swift

@@ -61,7 +61,7 @@ class RecommendSubCommentCollectionCell: UICollectionViewCell {
             make.top.equalTo(titleLabel.snp_bottom).offset(12)
             make.top.equalTo(titleLabel.snp_bottom).offset(12)
             make.left.equalTo(titleLabel.snp_left)
             make.left.equalTo(titleLabel.snp_left)
             make.right.equalToSuperview().offset(-10)
             make.right.equalToSuperview().offset(-10)
-            make.width.equalTo(kScreenWidth-62-54)            
+            make.width.equalTo(kScreenWidth-62-54)
         }
         }
         timeLabel.snp.makeConstraints { (make) in
         timeLabel.snp.makeConstraints { (make) in
             make.top.equalTo(contentLabel.snp_bottom).offset(8)
             make.top.equalTo(contentLabel.snp_bottom).offset(8)
@@ -97,7 +97,7 @@ class RecommendSubCommentCollectionCell: UICollectionViewCell {
         return contentLabel
         return contentLabel
     }()
     }()
     
     
-    private lazy var timeLabel: UILabel = {
+    lazy var timeLabel: UILabel = {
         let timeLabel = UILabel()
         let timeLabel = UILabel()
         timeLabel.text = "6个小时前"
         timeLabel.text = "6个小时前"
         timeLabel.textColor = kbbbbbbColor
         timeLabel.textColor = kbbbbbbColor

+ 71 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/全部评论的Cell/RecommendSubCommentCollectionFooter.swift

@@ -0,0 +1,71 @@
+//
+//  RecommendSubCommentCollectionFooter.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/15.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  推荐图文内容--次级评论のFooter
+
+import UIKit
+import RxSwift
+
+class RecommendSubCommentCollectionFooter: UICollectionReusableView {
+    
+    let disposeBag = DisposeBag()
+    
+    typealias UnfoldClosure = () -> Void
+    var unfoldClosure : UnfoldClosure?
+    
+    class func footerWith(collectionView:UICollectionView,kind: String,indexPath: IndexPath) -> RecommendSubCommentCollectionFooter {
+        let ID = "RecommendSubCommentCollectionFooter"
+        collectionView.register(RecommendSubCommentCollectionFooter.self, forSupplementaryViewOfKind: kind, withReuseIdentifier: ID)
+        let footerView : RecommendSubCommentCollectionFooter = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: ID, for: indexPath) as! RecommendSubCommentCollectionFooter
+        footerView.indexPath = indexPath
+        return footerView
+    }
+    
+    var indexPath : IndexPath? {
+        didSet {
+            
+        }
+    }
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        
+        setupViews()
+        setupLayouts()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    //MARK: - 设置View
+    private func setupViews() {
+        backgroundColor = kf7f8faColor
+        
+        addSubview(unfoldBtn)
+    }
+    
+    private func setupLayouts() {
+        unfoldBtn.snp.makeConstraints { (make) in
+            make.left.equalTo(44)
+            make.centerY.equalToSuperview()            
+            make.height.equalTo(30)
+        }
+    }
+    
+    private lazy var unfoldBtn: UIButton = {
+        let unfoldBtn = UIButton(type: UIButton.ButtonType.custom)
+        unfoldBtn.setTitle("展开3条回复", for: .normal)
+        unfoldBtn.setTitleColor(k62cc74Color, for: .normal)
+        unfoldBtn.titleLabel?.font = kRegularFont14
+        unfoldBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            if let unfoldClosure = self?.unfoldClosure {
+                unfoldClosure()
+            }
+        }).disposed(by: disposeBag)
+        
+        return unfoldBtn
+    }()
+}