动态详情
This commit is contained in:
@@ -22,6 +22,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
///数字转化为万
|
||||
+ (NSString *)getDealNumwithstring:(NSString *)string;
|
||||
|
||||
///时间戳转化为需要显示的内容
|
||||
+ (NSString *)stringWithTimeStamp:(NSString *)timeStamp;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -56,4 +56,59 @@
|
||||
return [NSString stringWithFormat:@"%@万", strResult];
|
||||
}
|
||||
|
||||
+ (NSString *)stringWithTimeStamp:(NSString *)timeStamp {
|
||||
// 转为秒为单位
|
||||
NSTimeInterval second = timeStamp.longLongValue / 1000;
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSince1970:second];
|
||||
|
||||
//把字符串转为NSdate
|
||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||
[dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
|
||||
// 时间 10点10分
|
||||
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
|
||||
[timeFormatter setDateFormat:@"HH:mm"];
|
||||
// 日期 2月18号
|
||||
NSDateFormatter *dayFormatter = [[NSDateFormatter alloc] init];
|
||||
[dayFormatter setDateFormat:@"MM月dd日"];
|
||||
// 日期 年月日
|
||||
NSDateFormatter *yearFormatter = [[NSDateFormatter alloc] init];
|
||||
[yearFormatter setDateFormat:@"YYYY年MM月dd日"];
|
||||
|
||||
//得到与当前时间差
|
||||
NSTimeInterval timeInterval = [date timeIntervalSinceNow];
|
||||
timeInterval = -timeInterval;
|
||||
|
||||
long temp = 0;
|
||||
NSString *result;
|
||||
|
||||
BOOL isSameDay = [[NSCalendar currentCalendar] isDateInToday:date]; // 是否是同一天
|
||||
|
||||
// A. 当天,且 timeInterval < 1分钟,显示“刚刚”;
|
||||
if (timeInterval < 60) {
|
||||
return [NSString stringWithFormat:@"刚刚"];
|
||||
|
||||
// B. 当天,且1分钟≤ timeInterval <60分钟,显示“n分钟前”;
|
||||
} else if((temp = timeInterval/60) < 60){
|
||||
return [NSString stringWithFormat:@"%ld分钟前",temp];
|
||||
|
||||
// C. 当天,且n≥60分钟,显示“xx:xx”;
|
||||
} else if((temp = temp/60) < 24 && isSameDay){
|
||||
return [timeFormatter stringFromDate:date];
|
||||
|
||||
// C. 非当天,且n≥60分钟,显示“xx:xx”;
|
||||
} else if((temp = temp/60) < 24 && !isSameDay){
|
||||
return [dayFormatter stringFromDate:date];
|
||||
|
||||
// D. 跨天,且未跨年,显示“mm-dd”;
|
||||
} else if((temp = temp/30) < 30){
|
||||
return [dayFormatter stringFromDate:date];
|
||||
|
||||
} else {
|
||||
// E. 跨年,显示“yyyy-mm-dd”;
|
||||
return [yearFormatter stringFromDate:date];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -58,6 +58,30 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param worldId 动态的话题id
|
||||
/// @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 worldId 话题的id
|
||||
/// @param uid 用户的uid
|
||||
+ (void)monentsDetail:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId worldId:(NSString *)worldId uid:(NSString *)uid;
|
||||
|
||||
/// 请求评论列表
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 动态id
|
||||
/// @param uid uid
|
||||
/// @param pageSize 一页多少个
|
||||
/// @param timestamp 上一个评论的时间戳
|
||||
+ (void)monentsCommentList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid pageSize:(NSString *)pageSize timestamp:(NSString *)timestamp;
|
||||
|
||||
/// 评论回复列表
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 动态id
|
||||
/// @param uid uid
|
||||
/// @param pageSize 每页多少个
|
||||
/// @param commentId 评论的id
|
||||
/// @param timestamp 上条回复的时间
|
||||
+ (void)monentsCommentReplyList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid pageSize:(NSString *)pageSize commentId:(NSString *)commentId timestamp:(NSString *)timestamp;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -76,4 +76,42 @@
|
||||
[self makeRequest:@"dynamic/share" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, uid, worldId, shareUid, nil];
|
||||
}
|
||||
|
||||
/// 动态详情
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 动态的id
|
||||
/// @param worldId 话题的id
|
||||
/// @param uid 用户的uid
|
||||
+ (void)monentsDetail:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId worldId:(NSString *)worldId uid:(NSString *)uid {
|
||||
[self makeRequest:@"dynamic/detail" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, worldId, uid, nil];
|
||||
}
|
||||
|
||||
|
||||
/// 请求评论列表
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 动态id
|
||||
/// @param uid uid
|
||||
/// @param pageSize 一页多少个
|
||||
/// @param timestamp 上一个评论的时间戳
|
||||
+ (void)monentsCommentList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid pageSize:(NSString *)pageSize timestamp:(NSString *)timestamp {
|
||||
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
|
||||
[dic setValue:dynamicId forKey:@"dynamicId"];
|
||||
[dic setValue:uid forKey:@"uid"];
|
||||
[dic setValue:pageSize forKey:@"pageSize"];
|
||||
if (timestamp.length > 0) {
|
||||
[dic setValue:timestamp forKey:@"timestamp"];
|
||||
}
|
||||
[HttpRequestHelper request:@"dynamic/comment/list" method:HttpRequestHelperMethodGET params:dic completion:completion];
|
||||
}
|
||||
|
||||
/// 评论回复列表
|
||||
/// @param completion 完成
|
||||
/// @param dynamicId 动态id
|
||||
/// @param uid uid
|
||||
/// @param pageSize 每页多少个
|
||||
/// @param commentId 评论的id
|
||||
/// @param timestamp 上条回复的时间
|
||||
+ (void)monentsCommentReplyList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid pageSize:(NSString *)pageSize commentId:(NSString *)commentId timestamp:(NSString *)timestamp {
|
||||
[self makeRequest:@"dynamic/comment/reply/list" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, uid, pageSize, commentId, timestamp, nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
38
xplan-ios/Main/Monents/Model/MonentsCommentModel.h
Normal file
38
xplan-ios/Main/Monents/Model/MonentsCommentModel.h
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// MonentsCommentModel.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MonentsCommentReplyModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@interface MonentsCommentModel : NSObject
|
||||
///评论的高度
|
||||
@property (nonatomic,assign) CGFloat commentRowHeight;
|
||||
/// 昵称
|
||||
@property (nonatomic,copy) NSString *nick;
|
||||
/// 头像
|
||||
@property (nonatomic,copy) NSString *avatar;
|
||||
/// 用户 uid
|
||||
@property (nonatomic,copy) NSString *uid;
|
||||
///评论内容
|
||||
@property (nonatomic,copy) NSString *content;
|
||||
///时间
|
||||
@property (nonatomic, copy) NSString *publishTime;
|
||||
/// 当前评论id
|
||||
@property (nonatomic, copy) NSString *commentId;
|
||||
///回复的内容
|
||||
@property (nonatomic,strong) MonentsCommentReplyModel *replyInfo;
|
||||
@end
|
||||
|
||||
|
||||
@interface MonentsCommentListModel : NSObject
|
||||
///评论的列表
|
||||
@property (nonatomic,strong) NSArray<MonentsCommentModel *> *commentList;
|
||||
///下一个评论的时间戳
|
||||
@property (nonatomic,copy) NSString *nextTimestamp;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
25
xplan-ios/Main/Monents/Model/MonentsCommentModel.m
Normal file
25
xplan-ios/Main/Monents/Model/MonentsCommentModel.m
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// MonentsCommentModel.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import "MonentsCommentModel.h"
|
||||
#import "NSString+Utils.h"
|
||||
@implementation MonentsCommentModel
|
||||
|
||||
- (NSString *)publishTime {
|
||||
return [NSString stringWithTimeStamp:_publishTime];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation MonentsCommentListModel
|
||||
|
||||
+ (NSDictionary *)objectClassInArray {
|
||||
return @{@"commentList": MonentsCommentModel.class};
|
||||
}
|
||||
|
||||
@end
|
51
xplan-ios/Main/Monents/Model/MonentsCommentReplyModel.h
Normal file
51
xplan-ios/Main/Monents/Model/MonentsCommentReplyModel.h
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// MonentsCommentReplyModel.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class MonentsReplyModel;
|
||||
@interface MonentsCommentReplyModel : NSObject
|
||||
@property (nonatomic, strong) NSMutableArray<MonentsReplyModel *> *replyList;// 剩余数量
|
||||
///剩余多少可以展开
|
||||
@property (nonatomic, assign) NSInteger leftCount;
|
||||
///下一个时间
|
||||
@property (nonatomic, copy) NSString *nextTimestamp;
|
||||
@end
|
||||
|
||||
|
||||
@interface MonentsReplyModel : NSObject
|
||||
///回复的高度
|
||||
@property (nonatomic,assign) CGFloat replyRowHeight;
|
||||
/// 头像
|
||||
@property (nonatomic,copy) NSString *avatar;
|
||||
/// 用户uid
|
||||
@property (nonatomic,copy) NSString *uid;
|
||||
/// 用户昵称
|
||||
@property (nonatomic,copy) NSString *nick;
|
||||
/// 回复评论的评论id
|
||||
@property (nonatomic,copy) NSString *toCommentId;
|
||||
/// 回复评论的uid
|
||||
@property (nonatomic,copy) NSString *toUid;
|
||||
/// 回复评论的昵称
|
||||
@property (nonatomic,copy) NSString *toNick;
|
||||
/// 评论内容
|
||||
@property (nonatomic,copy) NSString *content;
|
||||
/// 发布时间
|
||||
@property (nonatomic,copy) NSString *publishTime;
|
||||
/// 是否是楼主
|
||||
@property (nonatomic,assign) BOOL landLordFlag;
|
||||
/// 回复评论的评论id
|
||||
@property (nonatomic,copy) NSString *replyId;
|
||||
///显示的富文本
|
||||
@property (nonatomic,strong) NSAttributedString *contentAttribute;
|
||||
|
||||
- (void)createContentAttribute;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
36
xplan-ios/Main/Monents/Model/MonentsCommentReplyModel.m
Normal file
36
xplan-ios/Main/Monents/Model/MonentsCommentReplyModel.m
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// MonentsCommentReplyModel.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import "MonentsCommentReplyModel.h"
|
||||
#import "NSString+Utils.h"
|
||||
#import "ThemeColor.h"
|
||||
|
||||
@implementation MonentsCommentReplyModel
|
||||
+ (NSDictionary *)objectClassInArray {
|
||||
return @{@"replyList": MonentsReplyModel.class};
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation MonentsReplyModel
|
||||
|
||||
- (NSString *)publishTime {
|
||||
return [NSString stringWithTimeStamp:_publishTime];
|
||||
}
|
||||
|
||||
- (void)createContentAttribute {
|
||||
if (self.contentAttribute == nil) {
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||||
[attribute appendAttributedString:[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"@%@", _toNick] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15], NSForegroundColorAttributeName:[ThemeColor appMainColor]}]];
|
||||
if (self.content.length > 0) {
|
||||
[attribute appendAttributedString:[[NSMutableAttributedString alloc] initWithString:_content attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15], NSForegroundColorAttributeName:[ThemeColor mainTextColor]}]];
|
||||
}
|
||||
self.contentAttribute = attribute;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
@@ -63,10 +63,11 @@ typedef NS_ENUM(NSInteger, MonentsContentType) {
|
||||
///铭牌图片
|
||||
@property (nonatomic, copy) NSString *nameplatePic;
|
||||
///话题id
|
||||
@property (nonatomic, assign) long topicId;
|
||||
@property (nonatomic, assign) long worldId;
|
||||
///话题名字
|
||||
@property (nonatomic, copy) NSString *topicName;
|
||||
|
||||
@property (nonatomic, copy) NSString *worldName;
|
||||
///动态的id
|
||||
@property (nonatomic,copy) NSString *dynamicId;
|
||||
///是否是折叠起来的
|
||||
@property (nonatomic,assign) BOOL isFold;
|
||||
///cell的高度
|
||||
|
@@ -6,8 +6,7 @@
|
||||
//
|
||||
|
||||
#import "MonentsInfoModel.h"
|
||||
|
||||
#define aMinute 60
|
||||
#import "NSString+Utils.h"
|
||||
|
||||
@implementation MonentsInfoModel
|
||||
- (instancetype)init {
|
||||
@@ -23,62 +22,7 @@
|
||||
|
||||
|
||||
- (NSString *)publishTime {
|
||||
return [self stringWithTimeStamp:_publishTime];
|
||||
}
|
||||
|
||||
- (NSString *)stringWithTimeStamp:(NSString *)timeStamp {
|
||||
// 转为秒为单位
|
||||
NSTimeInterval second = timeStamp.longLongValue / 1000;
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSince1970:second];
|
||||
|
||||
//把字符串转为NSdate
|
||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||
[dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
|
||||
// 时间 10点10分
|
||||
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
|
||||
[timeFormatter setDateFormat:@"HH:mm"];
|
||||
// 日期 2月18号
|
||||
NSDateFormatter *dayFormatter = [[NSDateFormatter alloc] init];
|
||||
[dayFormatter setDateFormat:@"MM月dd日"];
|
||||
// 日期 年月日
|
||||
NSDateFormatter *yearFormatter = [[NSDateFormatter alloc] init];
|
||||
[yearFormatter setDateFormat:@"YYYY年MM月dd日"];
|
||||
|
||||
//得到与当前时间差
|
||||
NSTimeInterval timeInterval = [date timeIntervalSinceNow];
|
||||
timeInterval = -timeInterval;
|
||||
|
||||
long temp = 0;
|
||||
NSString *result;
|
||||
|
||||
BOOL isSameDay = [[NSCalendar currentCalendar] isDateInToday:date]; // 是否是同一天
|
||||
|
||||
// A. 当天,且 timeInterval < 1分钟,显示“刚刚”;
|
||||
if (timeInterval < aMinute) {
|
||||
return [NSString stringWithFormat:@"刚刚"];
|
||||
|
||||
// B. 当天,且1分钟≤ timeInterval <60分钟,显示“n分钟前”;
|
||||
} else if((temp = timeInterval/aMinute) < 60){
|
||||
return [NSString stringWithFormat:@"%ld分钟前",temp];
|
||||
|
||||
// C. 当天,且n≥60分钟,显示“xx:xx”;
|
||||
} else if((temp = temp/60) < 24 && isSameDay){
|
||||
return [timeFormatter stringFromDate:date];
|
||||
|
||||
// C. 非当天,且n≥60分钟,显示“xx:xx”;
|
||||
} else if((temp = temp/60) < 24 && !isSameDay){
|
||||
return [dayFormatter stringFromDate:date];
|
||||
|
||||
// D. 跨天,且未跨年,显示“mm-dd”;
|
||||
} else if((temp = temp/30) < 30){
|
||||
return [dayFormatter stringFromDate:date];
|
||||
|
||||
} else {
|
||||
// E. 跨年,显示“yyyy-mm-dd”;
|
||||
return [yearFormatter stringFromDate:date];
|
||||
}
|
||||
|
||||
return result;
|
||||
return [NSString stringWithTimeStamp:_publishTime];
|
||||
}
|
||||
|
||||
@end
|
||||
|
20
xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.h
Normal file
20
xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// XPMonentDetailPresenter.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/23.
|
||||
//
|
||||
|
||||
#import "BaseMvpPresenter.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPMonentDetailPresenter : BaseMvpPresenter
|
||||
/// 获取动态相亲
|
||||
/// @param dynamicId 动态ID
|
||||
- (void)getMonentsDetail:(NSString *)dynamicId;
|
||||
|
||||
- (void)getMonentsCommentList:(NSString *)dynamicId timestamp:(NSString *)timestamp status:(int)state;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
34
xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.m
Normal file
34
xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.m
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// XPMonentDetailPresenter.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/23.
|
||||
//
|
||||
|
||||
#import "XPMonentDetailPresenter.h"
|
||||
#import "Api+Monents.h"
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "XPMonentsDetailProtocol.h"
|
||||
#import "MonentsInfoModel.h"
|
||||
#import "MonentsCommentModel.h"
|
||||
@implementation XPMonentDetailPresenter
|
||||
|
||||
/// 获取动态相亲
|
||||
/// @param dynamicId 动态ID
|
||||
- (void)getMonentsDetail:(NSString *)dynamicId {
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
[Api monentsDetail:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
MonentsInfoModel * monentsInfo = [MonentsInfoModel modelWithDictionary:data.data];
|
||||
[[self getView] getMonentsDetailSuccess:monentsInfo];
|
||||
}] dynamicId:dynamicId worldId:@"" uid:uid];
|
||||
}
|
||||
|
||||
- (void)getMonentsCommentList:(NSString *)dynamicId timestamp:(NSString *)timestamp status:(int)state{
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
[Api monentsCommentList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
MonentsCommentListModel * info = [MonentsCommentListModel modelWithDictionary:data.data];
|
||||
[[self getView] getMonentsCommentListSuccess:info state:state];
|
||||
}] dynamicId:dynamicId uid:uid pageSize:@"10" timestamp:timestamp];
|
||||
}
|
||||
|
||||
@end
|
@@ -18,11 +18,24 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
#define kMONENTS_CONTENT_SPACAE_HEIGHT 12 /// 每个内容之间下面的间隙的高度
|
||||
#define kMONENTS_TEXT_TOPIC_HEIGHT 20 /// 话题的高度
|
||||
#define kMONENTS_FOLD_HEIGHT 20 /// 展开 关闭的高度
|
||||
@class MonentsInfoModel;
|
||||
#pragma mark - 评论的配置
|
||||
#define kMONENTS_COMMENT_LEFT_PADDING 15 ///评论左的间隙
|
||||
#define kMONENTS_COMMENT_RIGHT_PADDING 25 ///评论右的间隙
|
||||
#define kMONENTS_COMMENT_AVATAR_NICK_PADDING 10 ///头像昵称之间的间隙
|
||||
#define KMONENTS_COMMENT_AVATAR_WIDTH 45 ///评论的头像大小
|
||||
#define KMONENTS_COMMENT_MAX_WIDTH (KScreenWidth - KMONENTS_COMMENT_AVATAR_WIDTH - kMONENTS_COMMENT_LEFT_PADDING - kMONENTS_COMMENT_RIGHT_PADDING - kMONENTS_COMMENT_AVATAR_NICK_PADDING) ///评论内容的最大宽度
|
||||
#pragma mark - 评论回复的配置
|
||||
#define KMONENTS_COMMENT_REPLY_AVATAR_WIDTH 30 ///评论回复的头像大小
|
||||
#define kMONENTS_COMMENT_REPLY_LEFT_PADDING (kMONENTS_COMMENT_LEFT_PADDING + kMONENTS_COMMENT_RIGHT_PADDING + kMONENTS_COMMENT_AVATAR_NICK_PADDING) ///回复这左边的间隙
|
||||
#define KMONENTS_COMMENT_REPLY_MAX_WIDTH (KMONENTS_COMMENT_MAX_WIDTH - KMONENTS_COMMENT_REPLY_AVATAR_WIDTH - kMONENTS_COMMENT_AVATAR_NICK_PADDING) ///评论回复内容的最大宽度
|
||||
|
||||
@class MonentsInfoModel, MonentsCommentModel;
|
||||
@interface XPMonentsLayoutConfig : NSObject
|
||||
+ (void)layoutMonentsModel:(MonentsInfoModel *)monents;
|
||||
+ (CGFloat)monentsPicHeight:(MonentsInfoModel *)monents;
|
||||
+ (CGFloat)monentsContentHeight:(MonentsInfoModel *)monents;
|
||||
///计算评论的高度
|
||||
+ (CGFloat)commentCommentRowHeight:(MonentsCommentModel * )comment;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#import "ThemeColor.h"
|
||||
///Model
|
||||
#import "MonentsInfoModel.h"
|
||||
#import "MonentsCommentModel.h"
|
||||
|
||||
@implementation XPMonentsLayoutConfig
|
||||
|
||||
@@ -109,4 +110,51 @@
|
||||
return realLayout.textBoundingSize.height + foldHeight;
|
||||
}
|
||||
|
||||
///计算评论的高度
|
||||
+ (CGFloat)commentCommentRowHeight:(MonentsCommentModel * )comment {
|
||||
if (comment.commentRowHeight > 0) {
|
||||
return comment.commentRowHeight;
|
||||
}
|
||||
__block CGFloat rowHeight = 0;
|
||||
CGFloat commentTopHeight = 10 + 15 + 10;///10顶部的间隙 15 昵称的高度
|
||||
NSString * content = comment.content.length > 0 ? comment.content : @"";
|
||||
CGFloat commentHeight = [content boundingRectWithSize:CGSizeMake(KMONENTS_COMMENT_MAX_WIDTH, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size.height + 5;
|
||||
commentHeight = MAX(commentHeight, 15);
|
||||
rowHeight += commentTopHeight;
|
||||
rowHeight += commentHeight;
|
||||
|
||||
///展开剩余的回复
|
||||
if (comment.replyInfo.leftCount > 0) {
|
||||
rowHeight += 44;
|
||||
}
|
||||
|
||||
if (comment.replyInfo.replyList.count > 0) {
|
||||
rowHeight += 10 * 2;
|
||||
} else {
|
||||
rowHeight += 10;
|
||||
}
|
||||
|
||||
///评论的高度
|
||||
[comment.replyInfo.replyList enumerateObjectsUsingBlock:^(MonentsReplyModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if (obj.content.length > 0) {
|
||||
[obj createContentAttribute];
|
||||
CGFloat replayHeight = 0;
|
||||
CGFloat commentTopHeight = 10 + 15 + 10;///10顶部的间隙 15 昵称的高度
|
||||
CGFloat commentBottomHeight = 10;
|
||||
YYTextContainer *container = [YYTextContainer new];
|
||||
container.size = CGSizeMake(KMONENTS_COMMENT_REPLY_MAX_WIDTH, CGFLOAT_MAX);
|
||||
container.maximumNumberOfRows = 0;
|
||||
YYTextLayout *realLayout = [YYTextLayout layoutWithContainer:container text:obj.contentAttribute];
|
||||
CGFloat replyContentHeight = realLayout.textBoundingSize.height;
|
||||
replayHeight += commentTopHeight;
|
||||
replayHeight += replyContentHeight;
|
||||
replayHeight += commentBottomHeight;
|
||||
obj.replyRowHeight = replayHeight;
|
||||
rowHeight += replayHeight;
|
||||
}
|
||||
}];
|
||||
comment.commentRowHeight = rowHeight;
|
||||
return rowHeight;
|
||||
}
|
||||
|
||||
@end
|
||||
|
21
xplan-ios/Main/Monents/Protocol/XPMonentsDetailProtocol.h
Normal file
21
xplan-ios/Main/Monents/Protocol/XPMonentsDetailProtocol.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// XPMonentsDetailProtocol.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/23.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class MonentsInfoModel, MonentsCommentListModel;
|
||||
@protocol XPMonentsDetailProtocol <NSObject>
|
||||
///获取动态详情成功
|
||||
- (void)getMonentsDetailSuccess:(MonentsInfoModel *)commentInfo;
|
||||
|
||||
///获取动态 评论的列表
|
||||
- (void)getMonentsCommentListSuccess:(MonentsCommentListModel *)replyList state:(int)state;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPMonentsCommentTableViewCell.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class MonentsCommentModel;
|
||||
@interface XPMonentsCommentTableViewCell : UITableViewCell
|
||||
@property (nonatomic,strong) MonentsCommentModel *commentInfo;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
267
xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.m
Normal file
267
xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.m
Normal file
@@ -0,0 +1,267 @@
|
||||
//
|
||||
// XPMonentsCommentTableViewCell.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import "XPMonentsCommentTableViewCell.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "NetImageView.h"
|
||||
#import "ThemeColor.h"
|
||||
#import "XPMonentsLayoutConfig.h"
|
||||
///Model
|
||||
#import "MonentsCommentModel.h"
|
||||
///View
|
||||
#import "XPMonentsReplyTableViewCell.h"
|
||||
#import "XPMonentsReplyMoreTableViewCell.h"
|
||||
|
||||
@interface XPMonentsCommentTableViewCell ()<UITableViewDelegate, UITableViewDataSource>
|
||||
///容器
|
||||
@property (nonatomic,strong) UIStackView *stackView;
|
||||
///评论者
|
||||
@property (nonatomic,strong) UIView * commentUserView;
|
||||
///评论者的头像
|
||||
@property (nonatomic,strong) NetImageView *commentAvatarView;
|
||||
///评论者的昵称
|
||||
@property (nonatomic,strong) UILabel *commentNickLabel;
|
||||
///评论的内容
|
||||
@property (nonatomic,strong) UILabel *commentLabel;
|
||||
///时间
|
||||
@property (nonatomic,strong) UILabel *commentDateLabel;
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
///容器
|
||||
@property (nonatomic,strong) UIView * lineContainerView;
|
||||
///分割线
|
||||
@property (nonatomic,strong) UIView * lineView;
|
||||
///数据源
|
||||
@property (nonatomic,strong) NSArray *datasource;
|
||||
@end
|
||||
|
||||
@implementation XPMonentsCommentTableViewCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
|
||||
- (void)initSubViews {
|
||||
self.backgroundColor = [ThemeColor appCellBackgroundColor];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.contentView addSubview:self.stackView];
|
||||
[self.stackView addArrangedSubview:self.commentUserView];
|
||||
[self.stackView addArrangedSubview:self.tableView];
|
||||
[self.stackView addArrangedSubview:self.lineContainerView];
|
||||
|
||||
[self.lineContainerView addSubview:self.lineView];
|
||||
|
||||
[self.commentUserView addSubview:self.commentAvatarView];
|
||||
[self.commentUserView addSubview:self.commentNickLabel];
|
||||
[self.commentUserView addSubview:self.commentLabel];
|
||||
[self.commentUserView addSubview:self.commentDateLabel];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.left.mas_equalTo(self.contentView).inset(15);
|
||||
make.top.bottom.mas_equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
[self.lineContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(1);
|
||||
}];
|
||||
|
||||
|
||||
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.commentNickLabel);
|
||||
make.top.bottom.right.mas_equalTo(self.lineContainerView);
|
||||
}];
|
||||
|
||||
[self.commentAvatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(KMONENTS_COMMENT_AVATAR_WIDTH, KMONENTS_COMMENT_AVATAR_WIDTH));
|
||||
make.left.mas_equalTo(self.commentUserView);
|
||||
make.top.mas_equalTo(self.commentUserView).offset(10);
|
||||
}];
|
||||
|
||||
[self.commentNickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.commentAvatarView.mas_right).offset(10);
|
||||
make.top.mas_equalTo(self.commentUserView).offset(10);
|
||||
make.height.mas_equalTo(15);
|
||||
make.right.mas_lessThanOrEqualTo(self.commentDateLabel.mas_left).offset(-10);
|
||||
}];
|
||||
|
||||
[self.commentDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.commentUserView);
|
||||
make.centerY.mas_equalTo(self.commentNickLabel);
|
||||
}];
|
||||
|
||||
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.commentNickLabel);
|
||||
make.top.mas_equalTo(self.commentNickLabel.mas_bottom).offset(10);
|
||||
make.right.mas_equalTo(self.commentUserView).offset(-kMONENTS_COMMENT_RIGHT_PADDING);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
if (section == 0) {
|
||||
return self.datasource.count;
|
||||
}
|
||||
return self.commentInfo.replyInfo.leftCount > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (indexPath.section == 0) {
|
||||
MonentsReplyModel * replayinfo = [self.datasource objectAtIndex:indexPath.row];
|
||||
return replayinfo.replyRowHeight;
|
||||
}
|
||||
return 44;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (indexPath.section == 0) {
|
||||
XPMonentsReplyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsReplyTableViewCell class])];
|
||||
cell.replyInfo = [self.datasource objectAtIndex:indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
XPMonentsReplyMoreTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsReplyMoreTableViewCell class])];
|
||||
cell.leftCount = self.commentInfo.replyInfo.leftCount;
|
||||
return cell;
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setCommentInfo:(MonentsCommentModel *)commentInfo {
|
||||
_commentInfo = commentInfo;
|
||||
if (_commentInfo) {
|
||||
self.commentAvatarView.imageUrl = _commentInfo.avatar;
|
||||
NSString * nick = _commentInfo.nick;
|
||||
if (nick.length > 8) {
|
||||
nick = [nick substringToIndex:8];
|
||||
}
|
||||
self.commentLabel.text = _commentInfo.content;
|
||||
self.commentNickLabel.text = nick;
|
||||
self.commentDateLabel.text = _commentInfo.publishTime;
|
||||
self.tableView.hidden = _commentInfo.replyInfo.replyList.count <=0;
|
||||
self.datasource = _commentInfo.replyInfo.replyList;
|
||||
[self.tableView reloadData];
|
||||
if (_commentInfo.replyInfo.replyList.count > 0) {
|
||||
NSString * content = _commentInfo.content.length > 0 ? _commentInfo.content : @"";
|
||||
CGFloat commentHeight = [content boundingRectWithSize:CGSizeMake(KMONENTS_COMMENT_MAX_WIDTH, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size.height + 5;
|
||||
commentHeight = MAX(commentHeight, 15);
|
||||
[self.commentUserView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(commentHeight + 10 + 15 + 10);
|
||||
}];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (UIStackView *)stackView {
|
||||
if (!_stackView) {
|
||||
_stackView = [[UIStackView alloc] init];
|
||||
_stackView.axis = UILayoutConstraintAxisVertical;
|
||||
_stackView.distribution = UIStackViewDistributionFill;
|
||||
_stackView.alignment = UIStackViewAlignmentFill;
|
||||
_stackView.spacing = 10;
|
||||
}
|
||||
return _stackView;
|
||||
}
|
||||
|
||||
- (UIView *)commentUserView {
|
||||
if (!_commentUserView) {
|
||||
_commentUserView = [[UIView alloc] init];
|
||||
_commentUserView.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return _commentUserView;
|
||||
}
|
||||
|
||||
- (NetImageView *)commentAvatarView {
|
||||
if (!_commentAvatarView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_commentAvatarView = [[NetImageView alloc] initWithConfig:config];
|
||||
_commentAvatarView.layer.masksToBounds = YES;
|
||||
_commentAvatarView.layer.cornerRadius = 45/2.0;
|
||||
}
|
||||
return _commentAvatarView;
|
||||
}
|
||||
|
||||
- (UILabel *)commentNickLabel {
|
||||
if (!_commentNickLabel) {
|
||||
_commentNickLabel = [[UILabel alloc] init];
|
||||
_commentNickLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
|
||||
_commentNickLabel.textColor = [ThemeColor mainTextColor];
|
||||
[_commentNickLabel sizeToFit];
|
||||
}
|
||||
return _commentNickLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)commentLabel {
|
||||
if (!_commentLabel) {
|
||||
_commentLabel = [[UILabel alloc] init];
|
||||
_commentLabel.font = [UIFont systemFontOfSize:15];
|
||||
_commentLabel.numberOfLines = 0;
|
||||
_commentLabel.textColor = [ThemeColor secondTextColor];
|
||||
}
|
||||
return _commentLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)commentDateLabel {
|
||||
if (!_commentDateLabel) {
|
||||
_commentDateLabel = [[UILabel alloc] init];
|
||||
_commentDateLabel.font = [UIFont systemFontOfSize:12];
|
||||
_commentDateLabel.textColor = [ThemeColor textThirdColor];
|
||||
}
|
||||
return _commentDateLabel;
|
||||
}
|
||||
|
||||
- (UITableView *)tableView {
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
_tableView.tableFooterView = [UIView new];
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
_tableView.backgroundColor = [UIColor clearColor];
|
||||
_tableView.scrollEnabled = NO;
|
||||
if (@available(iOS 11.0, *)) {
|
||||
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[_tableView registerClass:[XPMonentsReplyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsReplyTableViewCell class])];
|
||||
[_tableView registerClass:[XPMonentsReplyMoreTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsReplyMoreTableViewCell class])];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
|
||||
- (UIView *)lineView {
|
||||
if (!_lineView) {
|
||||
_lineView = [[UIView alloc] init];
|
||||
_lineView.backgroundColor = [ThemeColor dividerColor];
|
||||
}
|
||||
return _lineView;
|
||||
}
|
||||
|
||||
- (UIView *)lineContainerView {
|
||||
if (!_lineContainerView) {
|
||||
_lineContainerView = [[UIView alloc] init];
|
||||
_lineContainerView.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return _lineContainerView;
|
||||
}
|
||||
|
||||
@end
|
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// XPMonentsReplyMoreTableViewCell.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/23.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class XPMonentsReplyMoreTableViewCell;
|
||||
@protocol XPMonentsReplyMoreTableViewCellDelegate <NSObject>
|
||||
|
||||
- (void)xPMonentsReplyMoreTableViewCellDidClickMoreReply:(XPMonentsReplyMoreTableViewCell *)view;
|
||||
|
||||
@end
|
||||
@interface XPMonentsReplyMoreTableViewCell : UITableViewCell
|
||||
///代理
|
||||
@property (nonatomic,weak) id<XPMonentsReplyMoreTableViewCellDelegate> delegate;
|
||||
|
||||
///剩余的个数
|
||||
@property (nonatomic,assign) NSInteger leftCount;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// XPMonentsReplyMoreTableViewCell.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/23.
|
||||
//
|
||||
|
||||
#import "XPMonentsReplyMoreTableViewCell.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "XPMonentsLayoutConfig.h"
|
||||
|
||||
@interface XPMonentsReplyMoreTableViewCell ()
|
||||
///查看更多
|
||||
@property (nonatomic,strong) UILabel *moreLabel;
|
||||
|
||||
@end
|
||||
@implementation XPMonentsReplyMoreTableViewCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.contentView addSubview:self.moreLabel];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.top.bottom.mas_equalTo(self.contentView);
|
||||
make.left.mas_equalTo(self.contentView).offset(kMONENTS_COMMENT_REPLY_LEFT_PADDING + KMONENTS_COMMENT_REPLY_AVATAR_WIDTH + kMONENTS_COMMENT_AVATAR_NICK_PADDING);
|
||||
}];
|
||||
}
|
||||
#pragma mark - Event Response
|
||||
- (void)moreLabelTapRecognizer {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsReplyMoreTableViewCellDidClickMoreReply:)]) {
|
||||
[self.delegate xPMonentsReplyMoreTableViewCellDidClickMoreReply:self];
|
||||
}
|
||||
}
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setLeftCount:(NSInteger)leftCount {
|
||||
_leftCount = leftCount;
|
||||
if (_leftCount) {
|
||||
self.moreLabel.text = [NSString stringWithFormat:@"展开%ld条回复", _leftCount];
|
||||
}
|
||||
}
|
||||
|
||||
- (UILabel *)moreLabel {
|
||||
if (!_moreLabel) {
|
||||
_moreLabel = [[UILabel alloc] init];
|
||||
_moreLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightBold];
|
||||
_moreLabel.textColor = [ThemeColor appEmphasizeColor];
|
||||
_moreLabel.userInteractionEnabled = YES;
|
||||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreLabelTapRecognizer)];
|
||||
[_moreLabel addGestureRecognizer:tap];
|
||||
}
|
||||
return _moreLabel;
|
||||
}
|
||||
|
||||
|
||||
@end
|
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPMonentsReplyTableViewCell.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class MonentsReplyModel;
|
||||
@interface XPMonentsReplyTableViewCell : UITableViewCell
|
||||
@property (nonatomic,strong) MonentsReplyModel *replyInfo;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
153
xplan-ios/Main/Monents/View/Cell/XPMonentsReplyTableViewCell.m
Normal file
153
xplan-ios/Main/Monents/View/Cell/XPMonentsReplyTableViewCell.m
Normal file
@@ -0,0 +1,153 @@
|
||||
//
|
||||
// XPMonentsReplyTableViewCell.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import "XPMonentsReplyTableViewCell.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <YYText/YYLabel.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "NetImageView.h"
|
||||
#import "XPMacro.h"
|
||||
#import "XPMonentsLayoutConfig.h"
|
||||
///Model
|
||||
#import "MonentsCommentReplyModel.h"
|
||||
|
||||
@interface XPMonentsReplyTableViewCell ()
|
||||
///头像
|
||||
@property (nonatomic,strong) NetImageView *avatarImageView;
|
||||
///自己的名字
|
||||
@property (nonatomic,strong) UILabel *nickLabel;
|
||||
///内容
|
||||
@property (nonatomic,strong) YYLabel *contentLabel;
|
||||
///时间
|
||||
@property (nonatomic,strong) UILabel *dateLabel;
|
||||
///分割线
|
||||
@property (nonatomic,strong) UIView * lineView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPMonentsReplyTableViewCell
|
||||
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.contentView addSubview:self.avatarImageView];
|
||||
[self.contentView addSubview:self.nickLabel];
|
||||
[self.contentView addSubview:self.contentLabel];
|
||||
[self.contentView addSubview:self.dateLabel];
|
||||
[self.contentView addSubview:self.lineView];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(KMONENTS_COMMENT_REPLY_AVATAR_WIDTH, KMONENTS_COMMENT_REPLY_AVATAR_WIDTH));
|
||||
make.top.mas_equalTo(self.contentView).offset(10);
|
||||
make.left.mas_equalTo(self.contentView).offset(kMONENTS_COMMENT_REPLY_LEFT_PADDING);
|
||||
}];
|
||||
|
||||
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.avatarImageView.mas_right).offset(kMONENTS_COMMENT_AVATAR_NICK_PADDING);
|
||||
make.top.mas_equalTo(self.contentView).offset(10);
|
||||
make.height.mas_equalTo(15);
|
||||
make.right.mas_lessThanOrEqualTo(self.dateLabel).offset(-5);
|
||||
}];
|
||||
|
||||
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nickLabel);
|
||||
make.top.mas_equalTo(self.nickLabel.mas_bottom).offset(10);
|
||||
make.right.mas_equalTo(self.contentView).offset(-15);
|
||||
}];
|
||||
|
||||
[self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView).offset(-10);
|
||||
make.centerY.mas_equalTo(self.nickLabel);
|
||||
}];
|
||||
|
||||
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nickLabel);
|
||||
make.right.mas_equalTo(self.contentView).offset(-10);
|
||||
make.height.mas_equalTo(0.5);
|
||||
make.bottom.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setReplyInfo:(MonentsReplyModel *)replyInfo {
|
||||
_replyInfo = replyInfo;
|
||||
if (_replyInfo) {
|
||||
self.avatarImageView.imageUrl = _replyInfo.avatar;
|
||||
NSString * nick = _replyInfo.nick;
|
||||
if (nick.length > 8) {
|
||||
nick = [nick substringToIndex:8];
|
||||
}
|
||||
self.nickLabel.text = nick;
|
||||
self.dateLabel.text = _replyInfo.publishTime;
|
||||
self.contentLabel.attributedText = _replyInfo.contentAttribute;
|
||||
}
|
||||
}
|
||||
|
||||
- (NetImageView *)avatarImageView {
|
||||
if (!_avatarImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_avatarImageView.layer.masksToBounds = YES;
|
||||
_avatarImageView.layer.cornerRadius = 30/2.0;
|
||||
_avatarImageView.layer.borderColor = [ThemeColor appMainColor].CGColor;
|
||||
}
|
||||
return _avatarImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)nickLabel {
|
||||
if (!_nickLabel) {
|
||||
_nickLabel = [[UILabel alloc] init];
|
||||
_nickLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
|
||||
_nickLabel.textColor = [ThemeColor mainTextColor];
|
||||
}
|
||||
return _nickLabel;
|
||||
}
|
||||
|
||||
- (YYLabel *)contentLabel {
|
||||
if (!_contentLabel) {
|
||||
_contentLabel = [[YYLabel alloc] init];
|
||||
_contentLabel.preferredMaxLayoutWidth = KMONENTS_COMMENT_REPLY_MAX_WIDTH;
|
||||
_contentLabel.numberOfLines = 0;
|
||||
}
|
||||
return _contentLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)dateLabel {
|
||||
if (!_dateLabel) {
|
||||
_dateLabel = [[UILabel alloc] init];
|
||||
_dateLabel.font = [UIFont systemFontOfSize:12];
|
||||
_dateLabel.textColor = [ThemeColor textThirdColor];
|
||||
}
|
||||
return _dateLabel;
|
||||
}
|
||||
|
||||
- (UIView *)lineView {
|
||||
if (!_lineView) {
|
||||
_lineView = [[UIView alloc] init];
|
||||
_lineView.backgroundColor = [ThemeColor dividerColor];
|
||||
}
|
||||
return _lineView;
|
||||
}
|
||||
|
||||
|
||||
@end
|
@@ -71,9 +71,9 @@
|
||||
- (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo {
|
||||
_monentsInfo = monentsInfo;
|
||||
if (_monentsInfo) {
|
||||
if (_monentsInfo.topicId > 0) {
|
||||
if (_monentsInfo.worldId > 0) {
|
||||
self.topicImageView.hidden = NO;
|
||||
self.topicLabel.text = _monentsInfo.topicName;
|
||||
self.topicLabel.text = _monentsInfo.worldName;
|
||||
} else {
|
||||
self.topicImageView.hidden = YES;
|
||||
}
|
||||
|
16
xplan-ios/Main/Monents/View/XPMonentsDetailViewController.h
Normal file
16
xplan-ios/Main/Monents/View/XPMonentsDetailViewController.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPMonentsDetailViewController.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import "MvpViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class MonentsInfoModel;
|
||||
@interface XPMonentsDetailViewController : MvpViewController
|
||||
@property (nonatomic,strong) MonentsInfoModel *monentsInfo;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
180
xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m
Normal file
180
xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m
Normal file
@@ -0,0 +1,180 @@
|
||||
//
|
||||
// XPMonentsDetailViewController.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/6/22.
|
||||
//
|
||||
|
||||
#import "XPMonentsDetailViewController.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <MJRefresh/MJRefresh.h>
|
||||
///Tool
|
||||
#import "XPMonentsLayoutConfig.h"
|
||||
#import "ThemeColor.h"
|
||||
///Model
|
||||
#import "MonentsInfoModel.h"
|
||||
#import "MonentsCommentModel.h"
|
||||
///View
|
||||
#import "XPMonentsTableViewCell.h"
|
||||
#import "XPMonentsCommentTableViewCell.h"
|
||||
#import "XPMonentsEmptyTableViewCell.h"
|
||||
///P
|
||||
#import "XPMonentDetailPresenter.h"
|
||||
#import "XPMonentsDetailProtocol.h"
|
||||
|
||||
@interface XPMonentsDetailViewController ()<UITableViewDelegate, UITableViewDataSource, XPMonentsDetailProtocol>
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
///数据源
|
||||
@property (nonatomic,strong) NSMutableArray *datasource;
|
||||
@end
|
||||
|
||||
@implementation XPMonentsDetailViewController
|
||||
|
||||
- (__kindof id)createPresenter {
|
||||
return [[XPMonentDetailPresenter alloc] init];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[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 = [ThemeColor secondTextColor];
|
||||
header.lastUpdatedTimeLabel.textColor = [ThemeColor secondTextColor];
|
||||
self.tableView.mj_header = header;
|
||||
|
||||
MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
|
||||
footer.stateLabel.textColor = [ThemeColor 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:0];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.title = @"详情";
|
||||
[self.view addSubview:self.tableView];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.view);
|
||||
}];
|
||||
}
|
||||
|
||||
#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 layoutMonentsModel:self.monentsInfo];
|
||||
return self.monentsInfo.rowHeight;
|
||||
} else if(indexPath.section == 1) {
|
||||
if (self.datasource.count > 0) {
|
||||
MonentsCommentModel * commentInfo = [self.datasource objectAtIndex:indexPath.row];
|
||||
return [XPMonentsLayoutConfig commentCommentRowHeight:commentInfo];
|
||||
} else {
|
||||
return 400;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (indexPath.section ==0) {
|
||||
XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])];
|
||||
cell.monentsInfo = self.monentsInfo;
|
||||
return cell;
|
||||
} else {
|
||||
if (self.datasource.count > 0) {
|
||||
XPMonentsCommentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])];
|
||||
cell.commentInfo = [self.datasource objectAtIndex:indexPath.row];
|
||||
return cell;
|
||||
} else {
|
||||
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - XPMonentsDetailProtocol
|
||||
- (void)getMonentsDetailSuccess:(MonentsInfoModel *)commentInfo {
|
||||
self.monentsInfo = commentInfo;
|
||||
[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];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UITableView *)tableView {
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
_tableView.tableFooterView = [UIView new];
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
_tableView.backgroundColor = [UIColor clearColor];
|
||||
if (@available(iOS 11.0, *)) {
|
||||
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
[_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])];
|
||||
[_tableView registerClass:[XPMonentsCommentTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])];
|
||||
[_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)datasource {
|
||||
if (!_datasource) {
|
||||
_datasource = [NSMutableArray array];
|
||||
}
|
||||
return _datasource;
|
||||
}
|
||||
|
||||
@end
|
@@ -21,6 +21,7 @@
|
||||
///View
|
||||
#import "XPMonentsTableViewCell.h"
|
||||
#import "XPMonentsEmptyTableViewCell.h"
|
||||
#import "XPMonentsDetailViewController.h"
|
||||
|
||||
@interface XPMonentsLatestViewController ()<UITableViewDelegate, UITableViewDataSource,XPMonentsLatestProtocol>
|
||||
///列表
|
||||
@@ -120,6 +121,16 @@
|
||||
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
if (self.datasource.count > 0) {
|
||||
XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init];
|
||||
MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row];
|
||||
detailVC.monentsInfo = monentsInfo;
|
||||
[self.navigationController pushViewController:detailVC animated:YES];
|
||||
}
|
||||
}
|
||||
#pragma mark -JXCategoryListContainerViewDelegate
|
||||
- (UIView *)listView {
|
||||
return self.view;
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#import "XPMonentsTableViewCell.h"
|
||||
#import "XPMonentsEmptyTableViewCell.h"
|
||||
#import "XPMonentsRecommendHeaderView.h"
|
||||
#import "XPMonentsDetailViewController.h"
|
||||
|
||||
@interface XPMonentsRecommendViewController ()<UITableViewDelegate, UITableViewDataSource,XPMonentsRecommendProtocol>
|
||||
///列表
|
||||
@@ -123,6 +124,16 @@
|
||||
XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
if (self.datasource.count > 0) {
|
||||
XPMonentsDetailViewController * detailVC = [[XPMonentsDetailViewController alloc] init];
|
||||
MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row];
|
||||
detailVC.monentsInfo = monentsInfo;
|
||||
[self.navigationController pushViewController:detailVC animated:YES];
|
||||
}
|
||||
}
|
||||
#pragma mark -JXCategoryListContainerViewDelegate
|
||||
- (UIView *)listView {
|
||||
return self.view;
|
||||
|
Reference in New Issue
Block a user