动态评论

This commit is contained in:
fengshuo
2022-08-17 18:55:45 +08:00
parent f438c4c811
commit 30d4e2f354
244 changed files with 5586 additions and 15 deletions

View File

@@ -12,6 +12,8 @@
///Tool
#import "XPMonentsLayoutConfig.h"
#import "ThemeColor.h"
#import "QEmotionHelper.h"
#import "QKeyboardManager.h"
///Model
#import "MonentsInfoModel.h"
#import "MonentsCommentModel.h"
@@ -19,11 +21,14 @@
#import "XPMonentsTableViewCell.h"
#import "XPMonentsCommentTableViewCell.h"
#import "XPMonentsEmptyTableViewCell.h"
#import "QInputBarView.h"
#import "QKeyboardManager.h"
#import "QEmotionBoardView.h"
///P
#import "XPMonentDetailPresenter.h"
#import "XPMonentsDetailProtocol.h"
@interface XPMonentsDetailViewController ()<UITableViewDelegate, UITableViewDataSource, XPMonentsDetailProtocol, XPMonentsCommentTableViewCellDelegate, XPMonentsTableViewCellDelegate>
@interface XPMonentsDetailViewController ()<UITableViewDelegate, UITableViewDataSource, XPMonentsDetailProtocol, XPMonentsCommentTableViewCellDelegate, XPMonentsTableViewCellDelegate, QInputBarViewDelegate, QInputBarViewDataSource,InputBoardDataSource ,InputBoardDelegate , QEmotionBoardViewDelegate>
///
@property (nonatomic,strong) UITableView *tableView;
///
@@ -32,6 +37,10 @@
@property (nonatomic,strong) UIView * sectionView;
///
@property (nonatomic,strong) UILabel *commentLabel;
@property(nonatomic,strong)QInputBarView *inputBarView;
@property(nonatomic,strong)QKeyboardManager *keyboardManager;
///
@property (nonatomic,strong) MonentsCommentModel *selectCommonInfo;
@end
@implementation XPMonentsDetailViewController
@@ -80,15 +89,52 @@
#pragma mark - Private Method
- (void)initInputView {
// frameaddBottomInputBarViewframe
// ViewTextFieldViewController
_inputBarView = [[QInputBarView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,UIInputBarViewMinHeight)];
QInputBarViewConfiguration *inputBarViewConfiguration = [QInputBarViewConfiguration defaultInputBarViewConfiguration];
inputBarViewConfiguration.voiceButtonHidden = YES;//
inputBarViewConfiguration.extendButtonHidden = YES;//
[_inputBarView setupWithConfiguration:inputBarViewConfiguration];
_inputBarView.delegate = self;
//keyboard
_keyboardManager = [[QKeyboardManager alloc] initWithViewController:self];
_keyboardManager.dataSource = self;
//addBottomInputBarViewdelegatedelegate
_keyboardManager.delegate = self;
[_keyboardManager addBottomInputBarView:_inputBarView belowViewController:NO];
//
[_keyboardManager bindTextView:_inputBarView.inputTextView];
}
- (void)sendTextMessage:(NSString *)inputText {
if (inputText.length > 0) {
[_keyboardManager hideAllBoardView];
if (self.selectCommonInfo && self.selectCommonInfo.commentId.length > 0) {
[self.presenter replayCommon:self.selectCommonInfo.commentId dynamicId:self.monentsInfo.dynamicId content:inputText];
} else {
[self.presenter commontMonents:self.monentsInfo.dynamicId content:inputText];
}
self.inputBarView.inputTextView.text = nil;
} else {
[self showErrorToast:@"请输入您要评论的内容"];
}
}
- (void)initSubViews {
self.title = @"详情";
[self.view addSubview:self.tableView];
[self.sectionView addSubview:self.commentLabel];
[self initInputView];
}
- (void)initSubViewConstraints {
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
make.left.right.top.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.view).offset(-UIInputBarViewMinHeight);
}];
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -163,6 +209,22 @@
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.section == 1) {
if (self.datasource.count > 0) {
MonentsCommentModel* monent = [self.datasource objectAtIndex:indexPath.row];
self.selectCommonInfo = monent;
self.inputBarView.inputTextView.placeholder = [NSString stringWithFormat:@"回复: %@", monent.nick];
[self.inputBarView textViewBecomeFirstResponder];
}
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[_keyboardManager hideAllBoardView];
}
#pragma mark - XPMonentsCommentTableViewCellDelegate
- (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickMoreReply:(MonentsCommentModel *)commentInfo {
[self.presenter getMonentsCommentReplyList:self.monentsInfo.dynamicId commentId:commentInfo.commentId timestamp:commentInfo.replyInfo.nextTimestamp];
@@ -173,6 +235,92 @@
[self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]];
}
#pragma mark - InputBoardDataSource
//@return Viewframe
- (UIView *)keyboardManagerExtendBoardView:(QKeyboardManager *)keyboardManager {
UIView *boardView = [UIView new];
boardView.backgroundColor = UIColor.blueColor;
return boardView;
}
//@return Viewframe
- (UIView *)keyboardManagerEmotionBoardView:(QKeyboardManager *)keyboardManager {
QEmotionBoardView *emotionView = [[QEmotionBoardView alloc] init];
QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper];
emotionView.emotions = faceManager.emotionArray;
emotionView.delegate = self;
if (@available(iOS 11.0, *)) {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
emotionView.backgroundColor = [UIColor colorNamed:@"q_input_extend_bg" inBundle:bundle compatibleWithTraitCollection:nil];
} else {
emotionView.backgroundColor = [UIColor colorWithRed:(246)/255.0f green:(246)/255.0f blue:(246)/255.0f alpha:1];
}
return emotionView;
}
//@return View
- (CGFloat)keyboardManagerEmotionBoardHeight:(QKeyboardManager *)keyboardManager {
return 294;
}
//@return View
- (CGFloat)keyboardManagerExtendBoardHeight:(QKeyboardManager *)keyboardManager {
return 174;
}
- (QInputBarViewConfiguration *)inputBarViewConfiguration {
//
QInputBarViewConfiguration *inputBarViewConfiguration = [QInputBarViewConfiguration defaultInputBarViewConfiguration];
inputBarViewConfiguration.voiceButtonHidden = YES;//
inputBarViewConfiguration.extendButtonHidden = YES;//
return inputBarViewConfiguration;
}
//
- (void)inputBarView:(QInputBarView *)inputBarView onEmotionButtonClick:(UIButton *)emotionSwitchButton {
if (emotionSwitchButton.isSelected) {
[_keyboardManager switchToEmotionBoardKeyboard];
} else {
self.selectCommonInfo = nil;
_inputBarView.inputTextView.placeholder = @"发表评论";
[_inputBarView textViewBecomeFirstResponder];
}
}
#pragma mark - QEmotionBoardViewDelegate
/**
*
* @param index `emotions`
* @param emotion `QMUIEmotion`
*/
- (void)emotionView:(QEmotionBoardView *)emotionView didSelectEmotion:(QEmotion *)emotion atIndex:(NSInteger)index {
//😊
[_inputBarView insertEmotion:emotion.displayName];
}
//
- (void)emotionViewDidSelectDeleteButton:(QEmotionBoardView *)emotionView {
if (![_inputBarView deleteEmotion]){
//
[_inputBarView.inputTextView deleteBackward];
}
}
//
- (void)emotionViewDidSelectSendButton:(QEmotionBoardView *)emotionView {
[self sendTextMessage:[_inputBarView textViewInputNormalText]];
}
#pragma mark -
/**
*
* @param inputNormalText "害~你好啊[微笑]"
*/
- (void)inputBarView:(QInputBarView *)inputBarView onKeyboardSendClick:(NSString *)inputNormalText {
[self sendTextMessage:inputNormalText];
}
#pragma mark - XPMonentsDetailProtocol
- (void)getMonentsDetailSuccess:(MonentsInfoModel *)commentInfo {
self.monentsInfo = commentInfo;
@@ -229,6 +377,14 @@
}
}
- (void)replyMonentsSuccess {
[self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0];
}
- (void)commonMonentsSuccess {
[self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0];
}
#pragma mark - Getters And Setters
- (UITableView *)tableView {