|
@@ -11,6 +11,7 @@ import IQKeyboardManagerSwift
|
|
|
|
|
|
class CommunitySubCommentController: BaseViewController {
|
|
|
|
|
|
+ var postId : Int?
|
|
|
var communityPostCommentModel : CommunityPostCommentModel?
|
|
|
var communityPostReplyModels = Array<CommunityPostReplyModel>()
|
|
|
var communityPostReplyModel : CommunityPostReplyModel?
|
|
@@ -19,7 +20,6 @@ class CommunitySubCommentController: BaseViewController {
|
|
|
override func viewDidLoad() {
|
|
|
|
|
|
super.viewDidLoad()
|
|
|
- IQKeyboardManager.shared.enable = true
|
|
|
setupViews()
|
|
|
setupLayouts()
|
|
|
setupData()
|
|
@@ -31,7 +31,6 @@ class CommunitySubCommentController: BaseViewController {
|
|
|
|
|
|
view.addSubview(tableView)
|
|
|
view.addSubview(commentInputView)
|
|
|
-// view.addSubview(cmtKeyboard)
|
|
|
}
|
|
|
|
|
|
override func setupLayouts() {
|
|
@@ -71,7 +70,10 @@ class CommunitySubCommentController: BaseViewController {
|
|
|
[weak self] text in
|
|
|
self?.communityPostCommentApi(text: text)
|
|
|
}
|
|
|
-
|
|
|
+ commentInputView.keyboardWillHideNotificationClosure = {
|
|
|
+ [weak self] in
|
|
|
+ self?.communityPostReplyModel = nil
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -100,24 +102,28 @@ extension CommunitySubCommentController {
|
|
|
|
|
|
func communityPostCommentApi(text:String) {
|
|
|
let communityCustomCommnetModel = CommunityCustomCommnetModel()
|
|
|
- communityCustomCommnetModel.postId = communityPostCommentModel?.id ?? 0
|
|
|
+ communityCustomCommnetModel.postId = postId ?? 0
|
|
|
communityCustomCommnetModel.content = text
|
|
|
- communityCustomCommnetModel.parentId = communityPostReplyModel?.id
|
|
|
+ communityCustomCommnetModel.parentId = communityPostCommentModel?.id
|
|
|
communityCustomCommnetModel.replyUid = communityPostReplyModel?.uid
|
|
|
communityCustomCommnetModel.replyUsername = communityPostReplyModel?.username
|
|
|
SwiftMoyaNetWorkServiceCommunity.shared().communityPostCommentApi(communityCustomCommnetModel: communityCustomCommnetModel) {
|
|
|
- [weak self] (data) -> (Void) in
|
|
|
-// var createdAt : String?
|
|
|
-// var replyUsername : String?
|
|
|
-// var uid : Int?
|
|
|
-// var username : String?
|
|
|
-// var id : Int?
|
|
|
-// var height : CGFloat?
|
|
|
-// var communityPostReplyModel = CommunityPostReplyModel()
|
|
|
-// communityPostReplyModel.avatar = UserModel.shared().getModel()?.avatarurl
|
|
|
-// communityPostReplyModel.content = text
|
|
|
-// self?.communityPostReplyModels.insert(communityPostReplyModel, at: 0)
|
|
|
- self?.commentInputView.inputTextView.endEditing(true)
|
|
|
+ [weak self] (communityPostCommentIdModel) -> (Void) in
|
|
|
+
|
|
|
+ let communityPostCommentIdModel = communityPostCommentIdModel as? CommunityPostCommentIdModel
|
|
|
+ let communityPostReplyModel = CommunityPostReplyModel()
|
|
|
+ communityPostReplyModel.avatar = UserModel.shared().getModel()?.avatarurl
|
|
|
+ communityPostReplyModel.content = text
|
|
|
+ communityPostReplyModel.createdAt = "刚刚"
|
|
|
+ communityPostReplyModel.id = communityPostCommentIdModel?.id
|
|
|
+ communityPostReplyModel.username = UserModel.shared().getModel()?.username
|
|
|
+ communityPostReplyModel.uid = UserModel.shared().getModel()?.uid
|
|
|
+ if self?.communityPostReplyModel != nil {
|
|
|
+ communityPostReplyModel.replyUsername = self?.communityPostReplyModel?.username
|
|
|
+ }
|
|
|
+ self?.communityPostReplyModels.insert(communityPostReplyModel, at: 0)
|
|
|
+ self?.tableView.reloadSections([1], with: UITableView.RowAnimation.none)
|
|
|
+ self?.commentInputView.sendSuccess()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -164,11 +170,13 @@ extension CommunitySubCommentController: UITableViewDataSource, UITableViewDeleg
|
|
|
case 0:
|
|
|
break
|
|
|
default:
|
|
|
-// communityPostReplyModel = communityPostReplyModels[indexPath.row]
|
|
|
-// if !commentInputView.iskeyboardVisable {
|
|
|
-// commentInputView.inputTextView.becomeFirstResponder()
|
|
|
-// commentInputView.inputTextView.placeholder = "回复:@\(communityPostReplyModel?.username ?? "")"
|
|
|
-// }
|
|
|
+ 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 ?? "")"
|
|
|
+ }
|
|
|
break
|
|
|
}
|
|
|
}
|