|
@@ -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)
|
|
|
|