Files
peko-ios/YuMi/Modules/YMMonents/View/XPMomentsSimpleDetailViewController.m
QQQ 56104ee021 移除 A/B 相关代码。
移除 XPMineSimpleUserInfoViewController
2024-05-22 19:24:04 +08:00

598 lines
25 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// YMMomentsSimpleDetailViewController.m
// YUMI
//
// Created by XY on 2023/2/22.
//
#import "XPMomentsSimpleDetailViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <MJRefresh/MJRefresh.h>
///Tool
#import "XPMonentsLayoutConfig.h"
#import "DJDKMIMOMColor.h"
#import "QEmotionHelper.h"
#import "QKeyboardManager.h"
#import "TTPopup.h"
#import "NSArray+Safe.h"
#import "AccountInfoStorage.h"
#import "YUMIHtmlUrl.h"
#import "ClientConfig.h"
#import "XNDJTDDLoadingTool.h"
///Model
#import "MonentsInfoModel.h"
#import "MonentsCommentModel.h"
#import "MonentsCommentReplyModel.h"
///View
#import "XPMonentsTableViewCell.h"
#import "XPMonentsCommentTableViewCell.h"
#import "XPMonentsEmptyTableViewCell.h"
#import "QInputBarView.h"
#import "QKeyboardManager.h"
#import "QEmotionBoardView.h"
#import "XPMineUserInfoViewController.h"
#import "XPMomentsSimpleDetailNav.h"
#import "XPWebViewController.h"
///P
#import "XPMonentDetailPresenter.h"
#import "XPMonentsDetailProtocol.h"
@interface XPMomentsSimpleDetailViewController ()<UITableViewDelegate, UITableViewDataSource, XPMonentsDetailProtocol, XPMonentsCommentTableViewCellDelegate, XPMonentsTableViewCellDelegate, QInputBarViewDelegate, QInputBarViewDataSource,InputBoardDataSource ,InputBoardDelegate , QEmotionBoardViewDelegate, XPMomentsSimpleDetailNavDelegate>
///导航栏
@property(nonatomic,strong) XPMomentsSimpleDetailNav *detailNav;
///列表
@property (nonatomic,strong) UITableView *tableView;
///数据源
@property (nonatomic,strong) NSMutableArray<MonentsCommentModel *> *datasource;
///头部view
@property (nonatomic,strong) UIView * sectionView;
///评论的个数
@property (nonatomic,strong) UILabel *commentLabel;
@property (nonatomic,strong) UIButton *likeBtn;
@property(nonatomic,strong)QInputBarView *inputBarView;
@property(nonatomic,strong)QKeyboardManager *keyboardManager;
///当前选中的评论信息
@property (nonatomic,strong) NSString *commentId;
@end
@implementation XPMomentsSimpleDetailViewController
- (__kindof id)createPresenter {
return [[XPMonentDetailPresenter alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = UIColor.whiteColor;
[self initHeaderAndFooterRrfresh];
[self initSubViews];
[self initSubViewConstraints];
}
#pragma mark - 下拉刷新
- (void)initHeaderAndFooterRrfresh {
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
header.stateLabel.font = [UIFont systemFontOfSize:10.0];
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:10.0];
header.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
header.lastUpdatedTimeLabel.textColor = [DJDKMIMOMColor secondTextColor];
self.tableView.mj_header = header;
MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
footer.stateLabel.textColor = [DJDKMIMOMColor secondTextColor];
footer.stateLabel.font = [UIFont systemFontOfSize:10.0];
self.tableView.mj_footer = footer;
[self headerRefresh];
}
- (void)headerRefresh {
[self.presenter getMonentsDetail:self.monentsInfo.dynamicId];
[self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0];
}
- (void)footerRefresh {
NSString *timestamp = @"";
if (self.datasource.count > 0) {
MonentsCommentModel * commentInfo = [self.datasource lastObject];
timestamp = commentInfo.publishTime;
}
[self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:timestamp status:1];
}
#pragma mark - Private Method
- (void)initInputView {
// 初始化输入工具条frame可以先这样临时设置下面的addBottomInputBarView方法会重置输入条frame
// 如果你想要自定义输入条View请参考TextFieldViewController代码
_inputBarView = [[QInputBarView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,UIInputBarViewMinHeight)];
QInputBarViewConfiguration *inputBarViewConfiguration = [QInputBarViewConfiguration defaultInputBarViewConfiguration];
inputBarViewConfiguration.voiceButtonHidden = YES;//隐藏语音按钮
inputBarViewConfiguration.extendButtonHidden = YES;//隐藏拓展按钮
inputBarViewConfiguration.rightSendButton = self.likeBtn;
inputBarViewConfiguration.emotionButtonHidden = YES;
[_inputBarView setupWithConfiguration:inputBarViewConfiguration];
_inputBarView.delegate = self;
//keyboard管理类用来管理键盘各大面板的切换
_keyboardManager = [[QKeyboardManager alloc] initWithViewController:self];
_keyboardManager.dataSource = self;
//因为addBottomInputBarView方法会立刻触发delegate所以这里需要先设置delegate
_keyboardManager.delegate = self;
[_keyboardManager addBottomInputBarView:_inputBarView belowViewController:NO];
//把输入框(如果有的话)绑定给管理类
[_keyboardManager bindTextView:_inputBarView.inputTextView];
_inputBarView.inputTextView.placeholder = YMLocalizedString(@"XPMomentsSimpleDetailViewController0");
_inputBarView.inputTextView.font = [UIFont systemFontOfSize:12];
}
- (void)sendTextMessage:(NSString *)inputText {
if (inputText.length > 0) {
[_keyboardManager hideAllBoardView];
if (self.commentId && self.commentId.length > 0) {
[self.presenter replayCommon:self.commentId dynamicId:self.monentsInfo.dynamicId content:inputText];
} else {
[self.presenter commontMonents:self.monentsInfo.dynamicId content:inputText];
}
self.inputBarView.inputTextView.text = nil;
} else {
[self showErrorToast:YMLocalizedString(@"XPMomentsSimpleDetailViewController1")];
}
}
- (void)initSubViews {
[self.view addSubview:self.detailNav];
[self.view addSubview:self.tableView];
[self.sectionView addSubview:self.commentLabel];
[self initInputView];
}
- (void)initSubViewConstraints {
[self.detailNav mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kStatusBarHeight);
make.leading.trailing.mas_equalTo(0);
make.height.mas_equalTo(44);
}];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.detailNav.mas_bottom);
make.leading.trailing.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.inputBarView.mas_top);
}];
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.sectionView).offset(15);
make.top.mas_equalTo(6);
make.bottom.mas_equalTo(0);
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return 1;
}
return self.datasource.count > 0 ? self.datasource.count : 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
[XPMonentsLayoutConfig layoutSimpleMonentsModel:self.monentsInfo];
return self.monentsInfo.rowHeight+20;
} else if(indexPath.section == 1) {
if (self.datasource.count > 0) {
MonentsCommentModel * commentInfo = [self.datasource safeObjectAtIndex1:indexPath.row];
return [XPMonentsLayoutConfig commentCommentRowHeight:commentInfo];
} else {
return 400;
}
}
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (section == 1) {
return 44;
}
return 0.0;;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
NSString *commentText = YMLocalizedString(@"XPMomentsSimpleDetailViewController2");
NSMutableAttributedString *commentStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@",commentText,self.monentsInfo.commentCount]];
[commentStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12 weight:UIFontWeightMedium] range:NSMakeRange(commentText.length, commentStr.length-commentText.length)];
[commentStr addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor textThirdColor] range:NSMakeRange(commentText.length, commentStr.length-commentText.length)];
self.commentLabel.attributedText = commentStr;
return self.sectionView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0.0f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return [UIView new];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section ==0) {
NSString *identifier = [NSString stringWithFormat:@"%@_Simple",NSStringFromClass([XPMonentsTableViewCell class])];
XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
cell.delegate = self;
cell.monentsInfo = self.monentsInfo;
return cell;
} else {
if (self.datasource.count > 0) {
XPMonentsCommentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])];
cell.commentInfo = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.delegate = self;
return cell;
} else {
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
return cell;
}
}
}
- (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 safeObjectAtIndex1:indexPath.row];
self.commentId = monent.commentId;
self.inputBarView.inputTextView.placeholder = [NSString stringWithFormat:@"%@: %@",YMLocalizedString(@"XPMonentsDetailViewController3"), monent.nick];
[self.inputBarView textViewBecomeFirstResponder];
}
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[_keyboardManager hideAllBoardView];
}
// 点赞
- (void)likeBtnAction {
[self.presenter likeMonent:self.monentsInfo.dynamicId status:!self.monentsInfo.isLike likedUid:self.monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", self.monentsInfo.worldId]];
}
#pragma mark - XPMomentsSimpleDetailNavDelegate
/// 点击返回
- (void)momentsSimpleDetailNavBackAction {
[self.navigationController popViewControllerAnimated:YES];
}
/// 点击头像
- (void)momentsSimpleDetailNavAvatarAction {
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = self.monentsInfo.uid.integerValue;
[self.navigationController pushViewController:userInfoVC animated:YES];
}
/// 点击更多
- (void)momentsSimpleDetailNavMoreAction {
TTActionSheetConfig *action;
@kWeakify(self);
if (self.monentsInfo.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) {
action = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMomentsSimpleDetailViewController4") clickAction:^{
[TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsTopicLatestViewController1") confirmHandler:^{
@kStrongify(self);
[self.presenter deleteMonents:self.monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", self.monentsInfo.worldId]];
} cancelHandler:^{}];
}];
} else {
action = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMomentsSimpleDetailViewController6") clickAction:^{
@kStrongify(self);
NSString * url= [NSString stringWithFormat:@"%@?reportUid=%@&source=%@", URLWithType(kReportRoomURL),self.monentsInfo.uid, @"WORLDDYNAMIC"];
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.url = url;
[self.navigationController pushViewController:webVC animated:YES];
}];
}
[TTPopup actionSheetWithItems:@[action]];
}
#pragma mark - XPMonentsCommentTableViewCellDelegate
- (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickMoreReply:(MonentsCommentModel *)commentInfo {
[self.presenter getMonentsCommentReplyList:self.monentsInfo.dynamicId commentId:commentInfo.commentId timestamp:commentInfo.replyInfo.nextTimestamp];
}
- (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickCommon:(MonentsReplyModel *)commentInfo {
if (commentInfo) {
self.commentId = commentInfo.replyId;
self.inputBarView.inputTextView.placeholder = [NSString stringWithFormat:@"%@: %@",YMLocalizedString(@"XPMonentsDetailViewController3"), commentInfo.nick];
[self.inputBarView textViewBecomeFirstResponder];
}
}
- (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickAvatar:(NSString *)commentInfo {
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = commentInfo.integerValue;
[self.navigationController pushViewController:userInfoVC animated:YES];
}
#pragma mark - XPMonentsTableViewCellDelegate
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo {
[self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]];
}
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicDelete:(MonentsInfoModel *)monentsInfo {
[TTPopup alertWithMessage:YMLocalizedString(@"XPMonentsTopicLatestViewController1") confirmHandler:^{
[self.presenter deleteMonents:monentsInfo.dynamicId worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]];
} cancelHandler:^{
}];
}
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicCommon:(MonentsInfoModel *)monentsInfo {
if (monentsInfo) {
self.commentId = nil;
self.inputBarView.inputTextView.placeholder = YMLocalizedString(@"XPMomentsSimpleDetailViewController10");
[self.inputBarView textViewBecomeFirstResponder];
}
}
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClicFold:(MonentsInfoModel *)monentsInfo {
self.monentsInfo = monentsInfo;
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
}
#pragma mark - InputBoardDataSource
//@return 点加号按钮弹出的拓展面板View且无需设置frame
- (UIView *)keyboardManagerExtendBoardView:(QKeyboardManager *)keyboardManager {
UIView *boardView = [UIView new];
boardView.backgroundColor = UIColor.blueColor;
return boardView;
}
//@return 点表情按钮弹出的表情面板View且无需设置frame
- (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.commentId = nil;
_inputBarView.inputTextView.placeholder = YMLocalizedString(@"XPMomentsSimpleDetailViewController11");
[_inputBarView textViewBecomeFirstResponder];
}
}
#pragma mark - QEmotionBoardViewDelegate
/**
* 选中表情时的回调
* @param index 被选中的表情在`emotions`里的索引
* @param emotion 被选中的表情对应的`QMUIEmotion`对象
*/
- (void)emotionView:(QEmotionBoardView *)emotionView didSelectEmotion:(QEmotion *)emotion atIndex:(NSInteger)index {
//把😊插入到输入栏
UIFont *font = [UIFont systemFontOfSize:17.5];
NSTextAttachment * emotionAtt = [[NSTextAttachment alloc] init];
UIImage *iconImage = emotion.image;
emotionAtt.bounds = CGRectMake(0, roundf(font.capHeight - emotion.image.size.width)/2.f, emotion.image.size.width, emotion.image.size.height);
emotionAtt.image = iconImage;
emotionAtt.imageName = emotion.displayName;
NSAttributedString *emotionAttribute = [NSMutableAttributedString attributedStringWithAttachment:(NSTextAttachment *)emotionAtt];
[_inputBarView insertEmotionAttributedString:emotionAttribute];
}
// 删除按钮的点击事件回调
- (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;
[self.likeBtn setTitle:self.monentsInfo.likeCount forState:UIControlStateNormal];
self.likeBtn.selected = self.monentsInfo.isLike;
[self.tableView reloadData];
}
- (void)getMonentsCommentListSuccess:(MonentsCommentListModel *)commentInfo state:(int)state{
if (state == 0) {
[self.datasource removeAllObjects];
[self.tableView.mj_header endRefreshing];
} else {
[self.tableView.mj_footer endRefreshing];
}
if (commentInfo.commentList.count > 0) {
[self.datasource addObjectsFromArray:commentInfo.commentList];
}
[self.tableView reloadData];
}
- (void)getMonentsCommentReplyListSuccess:(MonentsCommentReplyModel *)replyInfo commentId:(nonnull NSString *)commentId {
if (commentId) {
__block MonentsCommentModel * commentInfo;
[self.datasource enumerateObjectsUsingBlock:^(MonentsCommentModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj.commentId isEqualToString:commentId]) {
commentInfo = obj;
*stop = YES;
}
}];
if (commentInfo) {
NSMutableArray * replyList= commentInfo.replyInfo.replyList.mutableCopy;
[replyList addObjectsFromArray:replyInfo.replyList];
commentInfo.replyInfo.replyList = replyList.copy;
commentInfo.replyInfo.leftCount = replyInfo.leftCount;
commentInfo.replyInfo.nextTimestamp = replyInfo.nextTimestamp;
commentInfo.isReloadHeight = YES;
}
[self.tableView reloadData];
}
}
- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status {
if ([self.monentsInfo.dynamicId isEqualToString:dynamicId]) {
NSInteger count = self.monentsInfo.likeCount.integerValue;
self.monentsInfo.isLike = status;
if (status) {
count += 1;
} else {
count -= 1;
}
self.monentsInfo.likeCount = [NSString stringWithFormat:@"%ld", count];
[self.likeBtn setTitle:self.monentsInfo.likeCount forState:UIControlStateNormal];
self.likeBtn.selected = self.monentsInfo.isLike;
}
}
- (void)replyMonentsSuccess {
[self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0];
}
- (void)commonMonentsSuccess {
[self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:@"" status:0];
}
- (void)deleteMonentsSuccess:(NSString *)monentsInfo {
[self showSuccessToast:YMLocalizedString(@"XPMomentsSimpleDetailViewController12")];
[self.navigationController popViewControllerAnimated:YES];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsDetailViewController:deleteMonents:)]) {
[self.delegate xPMonentsDetailViewController:self deleteMonents:self.monentsInfo.dynamicId];
}
}
#pragma mark - Getters And Setters
- (XPMomentsSimpleDetailNav *)detailNav {
if (!_detailNav) {
_detailNav = [[XPMomentsSimpleDetailNav alloc] init];
_detailNav.delegate = self;
_detailNav.infoModel = self.monentsInfo;
}
return _detailNav;
}
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableFooterView = [UIView new];
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
NSString *identifier = [NSString stringWithFormat:@"%@_Simple",NSStringFromClass([XPMonentsTableViewCell class])];
[_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:identifier];
[_tableView registerClass:[XPMonentsCommentTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])];
[_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
}
return _tableView;
}
- (UIView *)sectionView {
if (!_sectionView) {
_sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 44)];
_sectionView.backgroundColor = UIColorFromRGB(0xF6F7F9);
UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, 6, _sectionView.bounds.size.width, _sectionView.bounds.size.height-6)];
whiteView.backgroundColor = UIColor.whiteColor;
[_sectionView addSubview:whiteView];
}
return _sectionView;
}
- (UILabel *)commentLabel {
if (!_commentLabel) {
_commentLabel = [[UILabel alloc] init];
_commentLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
_commentLabel.textColor = [DJDKMIMOMColor mainTextColor];
}
return _commentLabel;
}
- (UIButton *)likeBtn {
if (!_likeBtn) {
_likeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_likeBtn.frame = CGRectMake(0, 0, 80, 36);
[_likeBtn setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal];
_likeBtn.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
// _likeBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[_likeBtn setImage:[UIImage imageNamed:@"monents_info_like_count_normal"] forState:UIControlStateNormal];
[_likeBtn setImage:[UIImage imageNamed:@"monents_info_like_count_select"] forState:UIControlStateSelected];
[_likeBtn addTarget:self action:@selector(likeBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _likeBtn;
}
- (NSMutableArray *)datasource {
if (!_datasource) {
_datasource = [NSMutableArray array];
}
return _datasource;
}
@end