修改了动态的分享 点赞 举报

This commit is contained in:
fengshuo
2022-06-24 18:51:04 +08:00
parent 365b8aa2da
commit 1a13c09723
30 changed files with 371 additions and 38 deletions

View File

@@ -59,6 +59,16 @@ NS_ASSUME_NONNULL_BEGIN
/// @param shareUid 分享者的uid
+ (void)userShareMonents:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid worldId:(NSString *)worldId shareUid:(NSString *)shareUid;
/// 点赞动态
/// @param completion 完成
/// @param dynamicId 动态的id
/// @param uid 用户的uid
/// @param status 0 取消点赞 1 点赞
/// @param likedUid 点赞人的uid
/// @param worldId 世界的id
+ (void)monentsLike:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid status:(NSString *)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId;
/// 动态详情
/// @param completion 完成
/// @param dynamicId 动态的id

View File

@@ -76,6 +76,17 @@
[self makeRequest:@"dynamic/share" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, uid, worldId, shareUid, nil];
}
///
/// @param completion
/// @param dynamicId id
/// @param uid uid
/// @param status 0 1
/// @param likedUid uid
/// @param worldId id
+ (void)monentsLike:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid status:(NSString *)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId {
[self makeRequest:@"dynamic/like" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, uid, status, likedUid, worldId, nil];
}
///
/// @param completion
/// @param dynamicId id
@@ -114,4 +125,6 @@
[self makeRequest:@"dynamic/comment/reply/list" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, uid, pageSize, commentId, timestamp, nil];
}
@end

View File

@@ -9,6 +9,8 @@
#import "MonentsCommentReplyModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface MonentsCommentModel : NSObject
///是否刷新高度
@property (nonatomic,assign) BOOL isReloadHeight;
///评论的高度
@property (nonatomic,assign) CGFloat commentRowHeight;
/// 昵称

View File

@@ -6,12 +6,9 @@
//
#import "MonentsCommentModel.h"
#import "NSString+Utils.h"
@implementation MonentsCommentModel
- (NSString *)publishTime {
return [NSString stringWithTimeStamp:_publishTime];
}
@end

View File

@@ -6,7 +6,6 @@
//
#import "MonentsCommentReplyModel.h"
#import "NSString+Utils.h"
#import "ThemeColor.h"
@implementation MonentsCommentReplyModel
@@ -17,11 +16,6 @@
@implementation MonentsReplyModel
- (NSString *)publishTime {
return [NSString stringWithTimeStamp:_publishTime];
}
- (void)createContentAttribute {
if (self.contentAttribute == nil) {
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];

View File

@@ -19,12 +19,6 @@
+ (NSDictionary *)objectClassInArray {
return @{@"dynamicResList":MonentsPicInfoModel.class};
}
- (NSString *)publishTime {
return [NSString stringWithTimeStamp:_publishTime];
}
@end

View File

@@ -15,6 +15,19 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getMonentsDetail:(NSString *)dynamicId;
- (void)getMonentsCommentList:(NSString *)dynamicId timestamp:(NSString *)timestamp status:(int)state;
/// 获取评论的回复列表
/// @param dynamicId 动态id
/// @param commentId 评论id
/// @param timestamp 最后一条评论的时间戳
- (void)getMonentsCommentReplyList:(NSString *)dynamicId commentId:(NSString *)commentId timestamp:(NSString *)timestamp;
/// 动态点赞
/// @param dynamicId 动态id
/// @param status yes 点赞 NO 取消
/// @param likedUid 点赞人的uid
/// @param worldId 话题的id
- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -11,6 +11,7 @@
#import "XPMonentsDetailProtocol.h"
#import "MonentsInfoModel.h"
#import "MonentsCommentModel.h"
#import "MonentsCommentReplyModel.h"
@implementation XPMonentDetailPresenter
///
@@ -23,6 +24,11 @@
}] dynamicId:dynamicId worldId:@"" uid:uid];
}
///
/// @param dynamicId id
/// @param timestamp
/// @param state
- (void)getMonentsCommentList:(NSString *)dynamicId timestamp:(NSString *)timestamp status:(int)state{
NSString * uid = [AccountInfoStorage instance].getUid;
[Api monentsCommentList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@@ -31,4 +37,31 @@
}] dynamicId:dynamicId uid:uid pageSize:@"10" timestamp:timestamp];
}
///
/// @param dynamicId id
/// @param commentId id
/// @param timestamp
- (void)getMonentsCommentReplyList:(NSString *)dynamicId commentId:(NSString *)commentId timestamp:(NSString *)timestamp {
NSString * uid = [AccountInfoStorage instance].getUid;
[Api monentsCommentReplyList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
MonentsCommentReplyModel * replyInfo = [MonentsCommentReplyModel modelWithDictionary:data.data];
[[self getView] getMonentsCommentReplyListSuccess:replyInfo commentId:commentId];
}] dynamicId:dynamicId uid:uid pageSize:@"5" commentId:commentId timestamp:timestamp];
}
///
/// @param dynamicId id
/// @param status yes NO
/// @param likedUid uid
/// @param worldId id
- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * statusStr = status ? @"1" : @"0";
[Api monentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] likeMonentsSuccess:dynamicId status:status];
} showLoading:YES] dynamicId:dynamicId uid:uid status:statusStr likedUid:likedUid worldId:worldId];
}
@end

View File

@@ -112,7 +112,7 @@
///
+ (CGFloat)commentCommentRowHeight:(MonentsCommentModel * )comment {
if (comment.commentRowHeight > 0) {
if (comment.commentRowHeight > 0 && !comment.isReloadHeight) {
return comment.commentRowHeight;
}
__block CGFloat rowHeight = 0;

View File

@@ -20,6 +20,13 @@ NS_ASSUME_NONNULL_BEGIN
/// @param page 当前的页数
/// @param pageSize 一页多少个
- (void)getMonentsTopicList:(NSInteger)page pageSize:(NSInteger)pageSize;
/// 动态点赞
/// @param dynamicId 动态id
/// @param status yes 点赞 NO 取消
/// @param likedUid 点赞人的uid
/// @param worldId 话题的id
- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -43,5 +43,17 @@
}] uid:uid page:pageStr pageSize:pageSizeStr worldTypeId:@"0"];
}
///
/// @param dynamicId id
/// @param status yes NO
/// @param likedUid uid
/// @param worldId id
- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * statusStr = status ? @"1" : @"0";
[Api monentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] likeMonentsSuccess:dynamicId status:status];
} showLoading:YES] dynamicId:dynamicId uid:uid status:statusStr likedUid:likedUid worldId:worldId];
}
@end

View File

@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class MonentsInfoModel, MonentsCommentListModel;
@class MonentsInfoModel, MonentsCommentListModel, MonentsCommentReplyModel;
@protocol XPMonentsDetailProtocol <NSObject>
///获取动态详情成功
- (void)getMonentsDetailSuccess:(MonentsInfoModel *)commentInfo;
@@ -16,6 +16,11 @@ NS_ASSUME_NONNULL_BEGIN
///获取动态 评论的列表
- (void)getMonentsCommentListSuccess:(MonentsCommentListModel *)replyList state:(int)state;
///评论回复成功
- (void)getMonentsCommentReplyListSuccess:(MonentsCommentReplyModel *)replyInfo commentId:(NSString *)commentId;
///点赞/取消动态成功
- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status;
@end
NS_ASSUME_NONNULL_END

View File

@@ -17,6 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getMonentsRecommendListFail:(NSString *)msg state:(int)state;
///获取话题列表成功
- (void)monentsTopicListSuccess:(NSArray *)array;
///点赞/取消动态成功
- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status;
@end

View File

@@ -8,9 +8,18 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class MonentsCommentModel;
@class MonentsCommentModel, XPMonentsCommentTableViewCell;
@protocol XPMonentsCommentTableViewCellDelegate <NSObject>
///点击了查看更多
- (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickMoreReply:(MonentsCommentModel *)commentInfo;
@end
@interface XPMonentsCommentTableViewCell : UITableViewCell
@property (nonatomic,strong) MonentsCommentModel *commentInfo;
///代理
@property (nonatomic,weak) id<XPMonentsCommentTableViewCellDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -12,13 +12,14 @@
#import "NetImageView.h"
#import "ThemeColor.h"
#import "XPMonentsLayoutConfig.h"
#import "NSString+Utils.h"
///Model
#import "MonentsCommentModel.h"
///View
#import "XPMonentsReplyTableViewCell.h"
#import "XPMonentsReplyMoreTableViewCell.h"
@interface XPMonentsCommentTableViewCell ()<UITableViewDelegate, UITableViewDataSource>
@interface XPMonentsCommentTableViewCell ()<UITableViewDelegate, UITableViewDataSource, XPMonentsReplyMoreTableViewCellDelegate>
///
@property (nonatomic,strong) UIStackView *stackView;
///
@@ -139,10 +140,18 @@
XPMonentsReplyMoreTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsReplyMoreTableViewCell class])];
cell.leftCount = self.commentInfo.replyInfo.leftCount;
cell.delegate = self;
return cell;
}
#pragma mark - XPMonentsReplyMoreTableViewCellDelegate
- (void)xPMonentsReplyMoreTableViewCellDidClickMoreReply:(XPMonentsReplyMoreTableViewCell *)view {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsCommentTableViewCell:didClickMoreReply:)]) {
[self.delegate xPMonentsCommentTableViewCell:self didClickMoreReply:self.commentInfo];
}
}
#pragma mark - Getters And Setters
- (void)setCommentInfo:(MonentsCommentModel *)commentInfo {
_commentInfo = commentInfo;
@@ -154,7 +163,7 @@
}
self.commentLabel.text = _commentInfo.content;
self.commentNickLabel.text = nick;
self.commentDateLabel.text = _commentInfo.publishTime;
self.commentDateLabel.text = [NSString stringWithTimeStamp:_commentInfo.publishTime];
self.tableView.hidden = _commentInfo.replyInfo.replyList.count <=0;
self.datasource = _commentInfo.replyInfo.replyList;
[self.tableView reloadData];

View File

@@ -14,6 +14,7 @@
#import "NetImageView.h"
#import "XPMacro.h"
#import "XPMonentsLayoutConfig.h"
#import "NSString+Utils.h"
///Model
#import "MonentsCommentReplyModel.h"
@@ -96,7 +97,7 @@
nick = [nick substringToIndex:8];
}
self.nickLabel.text = nick;
self.dateLabel.text = _replyInfo.publishTime;
self.dateLabel.text = [NSString stringWithTimeStamp:_replyInfo.publishTime];
self.contentLabel.attributedText = _replyInfo.contentAttribute;
}
}

View File

@@ -8,9 +8,18 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class MonentsInfoModel;
@class MonentsInfoModel, XPMonentsTableViewCell;
@protocol XPMonentsTableViewCellDelegate <NSObject>
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo;
@end
@interface XPMonentsTableViewCell : UITableViewCell
@property (nonatomic,strong) MonentsInfoModel *monentsInfo;
///代理
@property (nonatomic,weak) id<XPMonentsTableViewCellDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -22,7 +22,7 @@
#import "XPMoentsTopicView.h"
#import "XPMonentsContentView.h"
#import "XPMonentsLayoutConfig.h"
@interface XPMonentsTableViewCell ()
@interface XPMonentsTableViewCell ()<XPMonentsTooBarViewDelegate, XPMonentsTooBarViewDelegate>
/// stackView
@property (nonatomic,strong) UIView * backView;
///
@@ -91,6 +91,13 @@
}];
}
#pragma mark - XPMonentsTooBarViewDelegate
- (void)xPMonentsTooBarView:(XPMonentsTooBarView *)view didClickLike:(MonentsInfoModel *)monentsInfo {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsTableViewCell:didClickLike:)]) {
[self.delegate xPMonentsTableViewCell:self didClickLike:monentsInfo];
}
}
#pragma mark - Getters And Setters
- (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo {
_monentsInfo = monentsInfo;
@@ -170,6 +177,7 @@
- (XPMonentsTooBarView *)toolBarView {
if (!_toolBarView) {
_toolBarView = [[XPMonentsTooBarView alloc] init];
_toolBarView.delegate = self;
}
return _toolBarView;
}

View File

@@ -11,6 +11,7 @@
///Tool
#import "ThemeColor.h"
#import "UIImage+Utils.h"
#import "NSString+Utils.h"
///Model
#import "MonentsInfoModel.h"
@@ -77,7 +78,7 @@
} else {
self.topicImageView.hidden = YES;
}
self.timeLabel.text = _monentsInfo.publishTime;
self.timeLabel.text = [NSString stringWithTimeStamp:_monentsInfo.publishTime];
}
}

View File

@@ -8,9 +8,17 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class MonentsInfoModel;
@class MonentsInfoModel, XPMonentsTooBarView;
@protocol XPMonentsTooBarViewDelegate <NSObject>
- (void)xPMonentsTooBarView:(XPMonentsTooBarView *)view didClickLike:(MonentsInfoModel *)monentsInfo;
@end
@interface XPMonentsTooBarView : UIView
@property (nonatomic,strong) MonentsInfoModel *monentsInfo;
///代理
@property (nonatomic,weak) id<XPMonentsTooBarViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -10,10 +10,18 @@
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
#import "TTPopup.h"
#import "XPHtmlUrl.h"
#import "XPShareView.h"
#import "XCHUDTool.h"
#import "XPMacro.h"
///Model
#import "MonentsInfoModel.h"
///View
#import "XPWebViewController.h"
#import "XCCurrentVCStackManager.h"
@interface XPMonentsTooBarView ()
@interface XPMonentsTooBarView ()<XCShareViewDelegate>
///
@property (nonatomic,strong) UIButton *reportButton;
///
@@ -118,15 +126,49 @@
}
#pragma mark - Event Response
- (void)likeButtonAction:(UIButton *)sender {
//TODO:
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsTooBarView:didClickLike:)]) {
[self.delegate xPMonentsTooBarView:self didClickLike:self.monentsInfo];
}
}
- (void)reportButtonAction:(UIButton *)sender {
//TODO:
TTActionSheetConfig *report = [TTActionSheetConfig normalTitle:@"举报" clickAction:^{
NSString * url= [NSString stringWithFormat:@"%@?reportUid=%@&source=%@", URLWithType(kReportRoomURL),self.monentsInfo.uid, @"WORLDDYNAMIC"];
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.url = url;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
}];
[TTPopup actionSheetWithItems:@[report]];
}
- (void)shareButtonAction:(UIButton *)sender {
//TODO:
XPShareItem *friend = [XPShareItem itemWitTag:XPShareItemTagMoments title:@"好友" imageName:@"share_wechat_circle_normal" disableImageName:@"share_wechat_circle_disable"];
XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagMoments title:@"朋友圈" imageName:@"share_wechat_circle_normal" disableImageName:@"share_wechat_circle_disable"];
XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagWeChat title:@"微信好友" imageName:@"share_wechat_normal" disableImageName:@"share_wechat_disable"];
XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagQQ title:@"QQ好友" imageName:@"share_qq_normal" disableImageName:@"share_qq_disable"];
XPShareItem *qqzone = [XPShareItem itemWitTag:XPShareItemTagQQZone title:@"QQ空间" imageName:@"share_qqzone_normal" disableImageName:@"share_qqzone_disable"];
NSArray * items = @[friend,wechat,cycle, qq, qqzone];
CGFloat margin = 15;
CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65);
XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init];
XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo];
shareView.delegate = self;
[TTPopup popupView:shareView style:TTPopupStyleActionSheet];
}
#pragma mark - #pragma mark - XCShareViewDelegate
- (void)shareView:(XPShareView *)shareView shareFail:(NSString *)message {
[TTPopup dismiss];
[XCHUDTool showErrorWithMessage:message];
}
- (void)shareView:(XPShareView *)shareView didSuccess:(XPShareInfoModel *)shareInfo{
[TTPopup dismiss];
}
- (void)shareViewDidClickCancel:(XPShareView *)shareView {
[TTPopup dismiss];
}
#pragma mark - Getters And Setters
@@ -181,6 +223,7 @@
[_commentButton setImage:[UIImage imageNamed:@"monents_info_comment_count"] forState:UIControlStateNormal];
[_commentButton setImage:[UIImage imageNamed:@"monents_info_comment_count"] forState:UIControlStateSelected];
[_commentButton addTarget:self action:@selector(likeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_commentButton.userInteractionEnabled = NO;
}
return _commentButton;
}

View File

@@ -17,6 +17,13 @@ NS_ASSUME_NONNULL_BEGIN
/// @param state 状态
- (void)getMonentsAttentionListPageSize:(NSInteger)pageSize dynamicId:(NSString *)dynamicId state:(int)state;
/// 动态点赞
/// @param dynamicId 动态id
/// @param status yes 点赞 NO 取消
/// @param likedUid 点赞人的uid
/// @param worldId 话题的id
- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -9,6 +9,7 @@
#import "Api+Monents.h"
#import "MonentsListInfoModel.h"
#import "XPMonentsAttentionProtocol.h"
#import "AccountInfoStorage.h"
@implementation XPMonentsAttentionPresenter
///
@@ -28,4 +29,17 @@
}] dynamicId:dynamicId pageSize:pageSizeStr types:@"0,2"];
}
///
/// @param dynamicId id
/// @param status yes NO
/// @param likedUid uid
/// @param worldId id
- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * statusStr = status ? @"1" : @"0";
[Api monentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] likeMonentsSuccess:dynamicId status:status];
} showLoading:YES] dynamicId:dynamicId uid:uid status:statusStr likedUid:likedUid worldId:worldId];
}
@end

View File

@@ -14,6 +14,9 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getMonentsAttentionListSuccess:(MonentsListInfoModel *)listInfo state:(int)state;
///获取最新列表失败
- (void)getMonentsAttentionListFail:(NSString *)msg state:(int)state;
///点赞/取消动态成功
- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status;
@end
NS_ASSUME_NONNULL_END

View File

@@ -23,11 +23,15 @@
#import "XPMonentDetailPresenter.h"
#import "XPMonentsDetailProtocol.h"
@interface XPMonentsDetailViewController ()<UITableViewDelegate, UITableViewDataSource, XPMonentsDetailProtocol>
@interface XPMonentsDetailViewController ()<UITableViewDelegate, UITableViewDataSource, XPMonentsDetailProtocol, XPMonentsCommentTableViewCellDelegate>
///
@property (nonatomic,strong) UITableView *tableView;
///
@property (nonatomic,strong) NSMutableArray *datasource;
@property (nonatomic,strong) NSMutableArray<MonentsCommentModel *> *datasource;
///view
@property (nonatomic,strong) UIView * sectionView;
///
@property (nonatomic,strong) UILabel *commentLabel;
@end
@implementation XPMonentsDetailViewController
@@ -71,7 +75,7 @@
MonentsCommentModel * commentInfo = [self.datasource lastObject];
timestamp = commentInfo.publishTime;
}
[self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:timestamp status:0];
[self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:timestamp status:1];
}
@@ -79,12 +83,18 @@
- (void)initSubViews {
self.title = @"详情";
[self.view addSubview:self.tableView];
[self.sectionView addSubview:self.commentLabel];
}
- (void)initSubViewConstraints {
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.sectionView).offset(15);
make.centerY.mas_equalTo(self.sectionView);
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
@@ -114,6 +124,26 @@
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (section == 1) {
return 44;
}
return 0.0;;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
self.commentLabel.text = [NSString stringWithFormat:@"所有评论(%@)", self.monentsInfo.commentCount];
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) {
XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])];
@@ -123,6 +153,7 @@
if (self.datasource.count > 0) {
XPMonentsCommentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])];
cell.commentInfo = [self.datasource objectAtIndex:indexPath.row];
cell.delegate = self;
return cell;
} else {
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
@@ -131,6 +162,11 @@
}
}
#pragma mark - XPMonentsCommentTableViewCellDelegate
- (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickMoreReply:(MonentsCommentModel *)commentInfo {
[self.presenter getMonentsCommentReplyList:self.monentsInfo.dynamicId commentId:commentInfo.commentId timestamp:commentInfo.replyInfo.nextTimestamp];
}
#pragma mark - XPMonentsDetailProtocol
- (void)getMonentsDetailSuccess:(MonentsInfoModel *)commentInfo {
self.monentsInfo = commentInfo;
@@ -151,13 +187,36 @@
[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];
}
}
#pragma mark - Getters And Setters
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_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, *)) {
@@ -170,6 +229,23 @@
return _tableView;
}
- (UIView *)sectionView {
if (!_sectionView) {
_sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 44)];
_sectionView.backgroundColor = [UIColor clearColor];
}
return _sectionView;
}
- (UILabel *)commentLabel {
if (!_commentLabel) {
_commentLabel = [[UILabel alloc] init];
_commentLabel.font = [UIFont systemFontOfSize:14];
_commentLabel.textColor = [ThemeColor mainTextColor];
}
return _commentLabel;
}
- (NSMutableArray *)datasource {
if (!_datasource) {
_datasource = [NSMutableArray array];

View File

@@ -16,6 +16,13 @@ NS_ASSUME_NONNULL_BEGIN
/// @param pageSize 一页的个数
/// @param state 状态
- (void)getMonentsLatestListPageSize:(NSInteger)pageSize dynamicId:(NSString *)dynamicId state:(int)state;
/// 动态点赞
/// @param dynamicId 动态id
/// @param status yes 点赞 NO 取消
/// @param likedUid 点赞人的uid
/// @param worldId 话题的id
- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -9,6 +9,7 @@
#import "Api+Monents.h"
#import "MonentsListInfoModel.h"
#import "XPMonentsLatestProtocol.h"
#import "AccountInfoStorage.h"
@implementation XPMonentsLatestPresenter
///
@@ -28,5 +29,17 @@
}] dynamicId:dynamicId pageSize:pageSizeStr types:@"0,2"];
}
///
/// @param dynamicId id
/// @param status yes NO
/// @param likedUid uid
/// @param worldId id
- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * statusStr = status ? @"1" : @"0";
[Api monentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] likeMonentsSuccess:dynamicId status:status];
} showLoading:YES] dynamicId:dynamicId uid:uid status:statusStr likedUid:likedUid worldId:worldId];
}
@end

View File

@@ -14,6 +14,9 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getMonentsLatestListSuccess:(MonentsListInfoModel *)listInfo state:(int)state;
///获取最新列表从失败
- (void)getMonentsLatestListFail:(NSString *)msg state:(int)state;
///点赞/取消动态成功
- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status;;
@end
NS_ASSUME_NONNULL_END

View File

@@ -23,7 +23,7 @@
#import "XPMonentsEmptyTableViewCell.h"
#import "XPMonentsDetailViewController.h"
@interface XPMonentsLatestViewController ()<UITableViewDelegate, UITableViewDataSource,XPMonentsLatestProtocol>
@interface XPMonentsLatestViewController ()<UITableViewDelegate, UITableViewDataSource,XPMonentsLatestProtocol, XPMonentsTableViewCellDelegate>
///
@property (nonatomic,strong) UITableView *tableView;
///
@@ -116,6 +116,7 @@
XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])];
MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row];
cell.monentsInfo = monentsInfo;
cell.delegate = self;
return cell;
}
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
@@ -131,6 +132,11 @@
[self.navigationController pushViewController:detailVC animated:YES];
}
}
#pragma mark - XPMonentsTableViewCellDelegate
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo {
[self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.like likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]];
}
#pragma mark -JXCategoryListContainerViewDelegate
- (UIView *)listView {
return self.view;
@@ -168,6 +174,20 @@
}
}
- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status {
[self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj.dynamicId isEqualToString:dynamicId]) {
if (status) {
obj.like += 1;
} else {
obj.like -= 1;
}
*stop = YES;
}
}];
[self.tableView reloadData];
}
#pragma mark - Getters And Setters
- (UITableView *)tableView {
if (!_tableView) {

View File

@@ -24,7 +24,7 @@
#import "XPMonentsRecommendHeaderView.h"
#import "XPMonentsDetailViewController.h"
@interface XPMonentsRecommendViewController ()<UITableViewDelegate, UITableViewDataSource,XPMonentsRecommendProtocol>
@interface XPMonentsRecommendViewController ()<UITableViewDelegate, UITableViewDataSource,XPMonentsRecommendProtocol, XPMonentsTableViewCellDelegate>
///
@property (nonatomic,strong) UITableView *tableView;
///
@@ -119,6 +119,7 @@
XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])];
MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row];
cell.monentsInfo = monentsInfo;
cell.delegate = self;
return cell;
}
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
@@ -134,6 +135,11 @@
[self.navigationController pushViewController:detailVC animated:YES];
}
}
#pragma mark - XPMonentsTableViewCellDelegate
- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo {
[self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.like likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]];
}
#pragma mark -JXCategoryListContainerViewDelegate
- (UIView *)listView {
return self.view;
@@ -174,6 +180,20 @@
self.headerView.topicList = array;
}
- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status {
[self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj.dynamicId isEqualToString:dynamicId]) {
if (status) {
obj.like += 1;
} else {
obj.like -= 1;
}
*stop = YES;
}
}];
[self.tableView reloadData];
}
#pragma mark - Getters And Setters
- (UITableView *)tableView {
if (!_tableView) {