南鑫林 %!s(int64=5) %!d(string=hai) anos
pai
achega
5103fdafae

+ 2 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/ViewController/CommunitySubCommentController.swift

@@ -45,6 +45,7 @@ class CommunitySubCommentController: BaseViewController {
             make.left.right.equalTo(0)
             make.bottom.equalTo(commentInputView.snp.top)
         }
+
         
     }
     
@@ -145,7 +146,6 @@ extension CommunitySubCommentController {
             }
             self?.communityPostReplyModels.insert(communityPostReplyModel, at: 0)
             self?.tableView.reloadSections([1], with: UITableView.RowAnimation.none)
-            complete()
             if self?.communityPostReplyModel != nil {
                 VirusViewModel.shared.comment(communityPostDetailModel: (self?.communityPostDetailModel)!, id: communityPostCommentIdModel?.id ?? 0, communityPostCommentModel: (self?.communityPostCommentModel)!, communityPostReplyModel: (self?.communityPostReplyModel)!)
                 
@@ -153,6 +153,7 @@ extension CommunitySubCommentController {
                 VirusViewModel.shared.comment(communityPostDetailModel: (self?.communityPostDetailModel)!, id: communityPostCommentIdModel?.id ?? 0, communityPostCommentModel: (self?.communityPostCommentModel)!)
 
             }
+            complete()
             
         }
     }

+ 27 - 24
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityAllCommentView.swift

@@ -10,7 +10,6 @@ import UIKit
 import FWPopupView
 import RxSwift
 import RxCocoa
-import IQKeyboardManagerSwift
 
 class CommunityAllCommentView: FWPopupView {
     
@@ -39,8 +38,6 @@ class CommunityAllCommentView: FWPopupView {
     
     override init(frame: CGRect) {
         super.init(frame: frame)
-        IQKeyboardManager.shared.enable = false
-        IQKeyboardManager.shared.enableAutoToolbar = false
         self.backgroundColor = kf7f8faColor
         
         addSubview(topView)
@@ -89,7 +86,7 @@ class CommunityAllCommentView: FWPopupView {
         }
         commentInputView.snp.makeConstraints { (make) in
             make.top.equalTo(tableView.snp_bottom)
-            make.height.equalTo(48)
+            make.height.equalTo(48 + kSafeTabBarHeight)
             make.left.right.equalToSuperview()
         }
     }
@@ -106,6 +103,7 @@ class CommunityAllCommentView: FWPopupView {
         commentInputView.commentInputViewClosure = {
             [weak self]  in
             self?.showKeyBoardCommentView(placeholder:"添加评论...")
+            self?.hiddenKeyBoardCommentView()
         }
     }
     
@@ -160,10 +158,10 @@ class CommunityAllCommentView: FWPopupView {
     
     /// 显示键盘
     func showKeyBoardCommentView(placeholder:String) {
-        keyBoardCommentView = KeyBoardCommentView.keyBoardCommentView(placeholder:placeholder,sendClosure: {
+        keyBoardCommentView = KeyBoardCommentView.keyBoardCommentView(showView:self,placeholder:placeholder,sendClosure: {
             [weak self] text in
             self?.communityPostCommentApi(text: text, complete: {
-                self?.keyBoardCommentView?.dismisskeyBoardCommentView()
+                self?.keyBoardCommentView?.removeFromSuperview()
             })
         })
     }
@@ -200,10 +198,8 @@ extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
         if !communityPostCommentModels.isEmpty {
             communityPostCommentModel = self.communityPostCommentModels[indexPath.row]
-            
-            self.commentInputView.inputTextView.becomeFirstResponder()
-            self.communityPostCommentModel = self.communityPostCommentModels[indexPath.row]
-            self.commentInputView.inputTextView.placeholder = "回复:@\(self.communityPostCommentModel?.username ?? "")"
+            showKeyBoardCommentView(placeholder:"回复:@\(self.communityPostCommentModel?.username ?? "")")
+            hiddenKeyBoardCommentView()
         }
         
     }
@@ -243,16 +239,9 @@ extension CommunityAllCommentView {
     func communityPostCommentApi(page:Int) {
         SwiftMoyaNetWorkServiceCommunity.shared().communityPostCommentsApi(postId: postId ?? 0, page: page) {
             [weak self] (communityPostCommentsModel) -> (Void) in
-            let commentsMdl = communityPostCommentsModel as? CommunityPostCommentsModel
-            self?.communityPostCommentsModel = commentsMdl
-            
-            if self?.communityPostCommentsModel?.pagination?.currentPage == 1{
-                self?.communityPostCommentModels.removeAll()
-            }
-            self?.communityPostCommentModels = (self?.communityPostCommentModels)! + (self?.communityPostCommentsModel?.data!)!
-            self?.tableView.reloadData()
-            
-            let totalComments: Int = commentsMdl?.pagination?.total ?? 0
+            let communityPostCommentsModel = communityPostCommentsModel as? CommunityPostCommentsModel
+            self?.communityPostCommentsModel = communityPostCommentsModel
+            let totalComments: Int = communityPostCommentsModel?.pagination?.total ?? 0
             self?.titleLabel.text = "全部评论 \(totalComments)"
             if totalComments == 0 {
                 self?.tableView.isHidden = true
@@ -261,6 +250,19 @@ extension CommunityAllCommentView {
                 self?.tableView.isHidden = false
                 self?.noCommentsLabel.isHidden = true
             }
+            
+            if self?.communityPostCommentsModel?.pagination?.currentPage ?? 1  <= self?.communityPostCommentsModel?.pagination?.totalPages ?? 1 {
+                if self?.communityPostCommentsModel?.pagination?.currentPage == 1{
+                    self?.communityPostCommentModels.removeAll()
+                }
+                self?.communityPostCommentModels = (self?.communityPostCommentModels)! + (self?.communityPostCommentsModel?.data!)!
+                self?.tableView.reloadData()
+                if  self?.communityPostCommentModels.count ?? 0 >= self?.communityPostCommentsModel?.pagination?.total ?? 0 {
+                    self?.tableView.endFooterNoMoreData()
+                }
+            }else {
+                self?.tableView.endFooterNoMoreData()
+            }
         }
     }
     
@@ -280,8 +282,7 @@ extension CommunityAllCommentView {
             
             let communityPostCommentIdModel = communityPostCommentIdModel as? CommunityPostCommentIdModel
             
-            
-            if self?.communityPostCommentModel == nil { //评
+            if self?.communityPostCommentModel == nil { //评论
                 let communityPostCommentModel = CommunityPostCommentModel()
                 communityPostCommentModel.avatar = UserModel.shared().getModel()?.avatarurl
                 communityPostCommentModel.content = text
@@ -290,8 +291,9 @@ extension CommunityAllCommentView {
                 communityPostCommentModel.username = UserModel.shared().getModel()?.username
                 communityPostCommentModel.uid = UserModel.shared().getModel()?.uid
                 self?.communityPostCommentModels.insert(communityPostCommentModel, at: 0)
-                
-                
+                let count = 1 + (self?.communityPostCommentsModel?.pagination?.total ?? 0)
+                self?.communityPostCommentsModel?.pagination?.total = count
+                self?.titleLabel.text = "全部评论 \(count)"
                 VirusViewModel.shared.comment(communityVideoItemModel: (self?.videoItemModel)!, id: communityPostCommentIdModel?.id ?? 0)
                 
                 self?.tableView.reloadData()
@@ -310,6 +312,7 @@ extension CommunityAllCommentView {
                     self?.communityPostCommentModel?.reply = Array<CommunityPostReplyModel>()
                 }
                 self?.communityPostCommentModel?.reply?.insert(communityPostReplyModel, at: 0)
+                self?.communityPostCommentModel?.replyCount = 1 +  (self?.communityPostCommentModel?.replyCount ?? 0)
                 
                 VirusViewModel.shared.comment(communityVideoItemModel: (self?.videoItemModel)!, id: communityPostCommentIdModel?.id ?? 0, communityPostCommentModel: self?.communityPostCommentModel)
                 

+ 28 - 9
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/ViewController/CommunityVideoSubCommentController.swift

@@ -16,6 +16,8 @@ class CommunityVideoSubCommentController: BaseViewController {
     
     var communityPostReplyModels = Array<CommunityPostReplyModel>()
     var communityPostReplyModel : CommunityPostReplyModel?
+    var keyBoardCommentView:KeyBoardCommentView?
+
     
     
     override func viewDidLoad() {
@@ -40,6 +42,10 @@ class CommunityVideoSubCommentController: BaseViewController {
             make.left.right.equalTo(0)
             make.bottom.equalTo(commentInputView.snp.top)
         }
+        commentInputView.snp.makeConstraints { (make) in
+            make.bottom.left.right.equalToSuperview()
+            make.height.equalTo(48 + kSafeTabBarHeight)
+        }
     }
     
     lazy var tableView: UITableView = {
@@ -55,7 +61,7 @@ class CommunityVideoSubCommentController: BaseViewController {
     }()
     
     lazy var commentInputView: CommentInputView = {
-        let commentInputView = CommentInputView(isHidden: false)
+        let commentInputView = CommentInputView()
         return commentInputView
     }()
     
@@ -68,10 +74,24 @@ class CommunityVideoSubCommentController: BaseViewController {
             self?.communityPostReplyApi(page: page)
         }
         commentInputView.commentInputViewClosure = {
-            [weak self] text in
-            self?.communityPostCommentApi(text: text)
+            [weak self]  in
+            self?.showKeyBoardCommentView(placeholder: "添加评论")
+            self?.hiddenKeyBoardCommentView()
         }
-        commentInputView.keyboardWillHideNotificationClosure = {
+    }
+    
+    /// 显示键盘
+    func showKeyBoardCommentView(placeholder:String) {
+        keyBoardCommentView = KeyBoardCommentView.keyBoardCommentView(placeholder: placeholder,sendClosure: {
+            [weak self] text in
+            self?.communityPostCommentApi(text: text, complete: {
+                self?.keyBoardCommentView?.dismisskeyBoardCommentView()
+            })
+        })
+    }
+    /// 隐藏键盘
+    func hiddenKeyBoardCommentView() {
+        keyBoardCommentView?.hiddenViewClosure =  {
             [weak self] in
             self?.communityPostReplyModel = nil
         }
@@ -101,7 +121,7 @@ extension CommunityVideoSubCommentController {
         }
     }
     
-    func communityPostCommentApi(text:String) {
+    func communityPostCommentApi(text:String,complete:@escaping () -> ()) {
         let communityCustomCommnetModel = CommunityCustomCommnetModel()
         communityCustomCommnetModel.postId = communityVideoItemModel?.id ?? 0
         communityCustomCommnetModel.content = text
@@ -124,7 +144,6 @@ extension CommunityVideoSubCommentController {
             }
             self?.communityPostReplyModels.insert(communityPostReplyModel, at: 0)
             self?.tableView.reloadSections([1], with: UITableView.RowAnimation.none)
-            self?.commentInputView.sendSuccess()
             
             if self?.communityPostReplyModel != nil {
                 VirusViewModel.shared.comment(communityVideoItemModel: (self?.communityVideoItemModel)!, id: communityPostCommentIdModel?.id ?? 0, communityPostCommentModel: (self?.communityPostCommentModel)!, communityPostReplyModel: (self?.communityPostReplyModel)!)
@@ -133,6 +152,7 @@ extension CommunityVideoSubCommentController {
                 VirusViewModel.shared.comment(communityVideoItemModel: (self?.communityVideoItemModel)!, id: communityPostCommentIdModel?.id ?? 0, communityPostCommentModel: (self?.communityPostCommentModel)!)
                 
             }
+            complete()
             
         }
     }
@@ -183,9 +203,8 @@ extension CommunityVideoSubCommentController: UITableViewDataSource, UITableView
             communityPostReplyModel = communityPostReplyModels[indexPath.row]
             AlertSheetView.sheetCommentReplyView(userName: communityPostReplyModel?.username ?? "", content: communityPostReplyModel?.content ?? "") {
                 [weak self] in
-                self?.commentInputView.inputTextView.becomeFirstResponder()
-                self?.communityPostReplyModel = self?.communityPostReplyModels[indexPath.row]
-                self?.commentInputView.inputTextView.placeholder = "回复:@\(self?.communityPostReplyModel?.username ?? "")"
+                self?.showKeyBoardCommentView(placeholder: "回复:@\(self?.communityPostReplyModel?.username ?? "")")
+                self?.hiddenKeyBoardCommentView()
             }
             break
         }

+ 4 - 4
RainbowPlanet/RainbowPlanet/Tools/EmptyView/DIYEmptyView.swift

@@ -25,9 +25,9 @@ class DIYEmptyView: LYEmptyView {
     /// tableView上的默认图
     ///
     /// - Parameter tableView: UITableView
-    class func emptyTableView(tableView:UITableView) {
+    class func emptyTableView(tableView:UITableView,contentViewY : CGFloat = kScaleValue(value: 164)) {
         let emptyView = DIYEmptyView.empty(withImageStr: "default_page_content", titleStr: nil, detailStr: "暂时没有内容哦")
-        emptyView?.contentViewY = kScaleValue(value: 164)
+        emptyView?.contentViewY = contentViewY
         tableView.ly_emptyView = emptyView
         tableView.ly_startLoading()
     }
@@ -35,9 +35,9 @@ class DIYEmptyView: LYEmptyView {
     /// collectionView上的默认图
     ///
     /// - Parameter collectionView: UICollectionView
-    class func emptyTableView(collectionView:UICollectionView) {
+    class func emptyTableView(collectionView:UICollectionView,contentViewY : CGFloat = kScaleValue(value: 164)) {
         let emptyView = DIYEmptyView.empty(withImageStr: "default_page_content", titleStr: nil, detailStr: "暂时没有内容哦")
-        emptyView?.contentViewY = kScaleValue(value: 164)
+        emptyView?.contentViewY = contentViewY
         collectionView.ly_emptyView = emptyView
         collectionView.ly_startLoading()
     }

+ 13 - 2
RainbowPlanet/RainbowPlanet/Tools/KeyBoardCommentView/KeyBoardCommentView.swift

@@ -23,6 +23,9 @@ class KeyBoardCommentView: FWPopupView {
     /// 动画时长
     var duration : Double = 0
     
+    /// 显示的View
+    var showView : UIView?
+    
     override init(frame: CGRect) {
         super.init(frame: frame)
         setupViews()
@@ -131,9 +134,13 @@ class KeyBoardCommentView: FWPopupView {
     }
     
     /// 初始化
-    class func keyBoardCommentView(placeholder:String = "添加评论...",sendClosure :SendClosure? = nil) -> KeyBoardCommentView {
+    class func keyBoardCommentView(showView:UIView? = nil, placeholder:String = "添加评论...",sendClosure :SendClosure? = nil) -> KeyBoardCommentView {
         let view = KeyBoardCommentView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 48))
         view.showkeyBoardCommentView()
+        if showView != nil{
+            view.attachedView = showView
+            view.showView = showView
+        }
         view.withKeyboard = true
         view.inputTextView.placeholder = placeholder
         if sendClosure != nil {
@@ -171,7 +178,11 @@ extension KeyBoardCommentView : UITextViewDelegate {
             textView.height = 28
         }
         self.height = textView.height + 20
-        self.y = kScreenHeight - self.height
+        if showView != nil {
+            self.y = (attachedView?.height ?? 0) - keyboardH - self.height
+        }else {
+            self.y = kScreenHeight -  self.height
+        }
         sendButton.y = textView.height + 20 - 38
 
     }