Commit 15d26e9d cgx

完成部分正文页面

1 个父辈 1f60f29b
正在显示 26 个修改的文件 包含 620 行增加38 行删除
......@@ -198,6 +198,11 @@
D0B5ECC827F2E97A003EDFE3 /* MacroFuncUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECC727F2E97A003EDFE3 /* MacroFuncUtil.m */; };
D0B5ECD527F2F0B2003EDFE3 /* AdaptationUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */; };
D0B5ECD827F2F1B0003EDFE3 /* ServerAPIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */; };
D0B836EF28F100B3006E76C0 /* ComDetailViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B836EE28F100B3006E76C0 /* ComDetailViewModel.m */; };
D0B836F228F11C77006E76C0 /* CommentModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B836F128F11C77006E76C0 /* CommentModel.m */; };
D0B836F528F11CA0006E76C0 /* ReplyModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B836F428F11CA0006E76C0 /* ReplyModel.m */; };
D0B836F828F1232F006E76C0 /* ComReplyModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B836F728F1232F006E76C0 /* ComReplyModel.m */; };
D0B836FB28F1655E006E76C0 /* CommentCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0B836FA28F1655E006E76C0 /* CommentCell.m */; };
D0BB9AA4281626F200DB209E /* ExceptionDefaultView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BB9AA3281626F200DB209E /* ExceptionDefaultView.m */; };
D0BB9AA728164DFB00DB209E /* NickNameController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BB9AA628164DFB00DB209E /* NickNameController.m */; };
D0BDDFFC28618123006558D4 /* DisableAllTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0BDDFFB28618123006558D4 /* DisableAllTextView.m */; };
......@@ -658,6 +663,16 @@
D0B5ECD427F2F0B2003EDFE3 /* AdaptationUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AdaptationUtil.m; sourceTree = "<group>"; };
D0B5ECD627F2F1B0003EDFE3 /* ServerAPIUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ServerAPIUtil.h; sourceTree = "<group>"; };
D0B5ECD727F2F1B0003EDFE3 /* ServerAPIUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ServerAPIUtil.m; sourceTree = "<group>"; };
D0B836ED28F100B3006E76C0 /* ComDetailViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ComDetailViewModel.h; sourceTree = "<group>"; };
D0B836EE28F100B3006E76C0 /* ComDetailViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ComDetailViewModel.m; sourceTree = "<group>"; };
D0B836F028F11C77006E76C0 /* CommentModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommentModel.h; sourceTree = "<group>"; };
D0B836F128F11C77006E76C0 /* CommentModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CommentModel.m; sourceTree = "<group>"; };
D0B836F328F11CA0006E76C0 /* ReplyModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReplyModel.h; sourceTree = "<group>"; };
D0B836F428F11CA0006E76C0 /* ReplyModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReplyModel.m; sourceTree = "<group>"; };
D0B836F628F1232F006E76C0 /* ComReplyModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ComReplyModel.h; sourceTree = "<group>"; };
D0B836F728F1232F006E76C0 /* ComReplyModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ComReplyModel.m; sourceTree = "<group>"; };
D0B836F928F1655E006E76C0 /* CommentCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommentCell.h; sourceTree = "<group>"; };
D0B836FA28F1655E006E76C0 /* CommentCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CommentCell.m; sourceTree = "<group>"; };
D0BB9AA2281626F200DB209E /* ExceptionDefaultView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExceptionDefaultView.h; sourceTree = "<group>"; };
D0BB9AA3281626F200DB209E /* ExceptionDefaultView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExceptionDefaultView.m; sourceTree = "<group>"; };
D0BB9AA528164DFB00DB209E /* NickNameController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NickNameController.h; sourceTree = "<group>"; };
......@@ -1473,6 +1488,8 @@
D0A3BB9128D95A2B00F58781 /* CommunityView.m */,
D070A78928DEF2D30039C5A7 /* DynamicView.h */,
D070A78A28DEF2D30039C5A7 /* DynamicView.m */,
D0B836F928F1655E006E76C0 /* CommentCell.h */,
D0B836FA28F1655E006E76C0 /* CommentCell.m */,
D0078C5C28E13DC400054804 /* DynamicDetailView.h */,
D0078C5D28E13DC400054804 /* DynamicDetailView.m */,
D0078C6028E1425500054804 /* InteractView.h */,
......@@ -1514,6 +1531,12 @@
children = (
D02B7E5D28E2C89600218EF7 /* ComDynModel.h */,
D02B7E5E28E2C89600218EF7 /* ComDynModel.m */,
D0B836F028F11C77006E76C0 /* CommentModel.h */,
D0B836F128F11C77006E76C0 /* CommentModel.m */,
D0B836F328F11CA0006E76C0 /* ReplyModel.h */,
D0B836F428F11CA0006E76C0 /* ReplyModel.m */,
D0B836F628F1232F006E76C0 /* ComReplyModel.h */,
D0B836F728F1232F006E76C0 /* ComReplyModel.m */,
);
path = Model;
sourceTree = "<group>";
......@@ -1527,6 +1550,8 @@
D0A3BB9B28D9BA3500F58781 /* EvaluateRequestModel.m */,
D02B7E6228E2D76D00218EF7 /* ComListViewModel.h */,
D02B7E6328E2D76D00218EF7 /* ComListViewModel.m */,
D0B836ED28F100B3006E76C0 /* ComDetailViewModel.h */,
D0B836EE28F100B3006E76C0 /* ComDetailViewModel.m */,
D070A78C28DF02DE0039C5A7 /* DynamicViewModel.h */,
D070A78D28DF02DE0039C5A7 /* DynamicViewModel.m */,
);
......@@ -2388,6 +2413,7 @@
D0404A2B2870930A0062AD30 /* BeizerView.m in Sources */,
D053BEE9280F9E310028CCFC /* CloseAlertView.m in Sources */,
D0D00199282C9402004EAFA1 /* NoiseView.m in Sources */,
D0B836F228F11C77006E76C0 /* CommentModel.m in Sources */,
D062A0A128183FE000B4F48A /* FeedbackDetailController.m in Sources */,
D0FAC429281B865300D4B859 /* GKYYWebImageManager.m in Sources */,
D0691E1428801EF3008BFFAB /* ReadyTimeMarker.m in Sources */,
......@@ -2439,6 +2465,7 @@
D070A78E28DF02DE0039C5A7 /* DynamicViewModel.m in Sources */,
D0A1C49228C2084B000975DC /* ArticleRequestModel.m in Sources */,
D0DF90AE2814390000FC0F64 /* BannerModel.m in Sources */,
D0B836F528F11CA0006E76C0 /* ReplyModel.m in Sources */,
D0E65FFF2807AC5E006562F2 /* DSProgressHUD.m in Sources */,
D0496798283484CC00FB81E5 /* ProfileTableView.m in Sources */,
D0078C6F28E19C9F00054804 /* TextInputAlertView.m in Sources */,
......@@ -2466,6 +2493,8 @@
D0078C6228E1425500054804 /* InteractView.m in Sources */,
D0C50B4627FD66FB00DC68F0 /* DSConstUtil.m in Sources */,
D01DC95128701ECD0035B78B /* MyPointView.m in Sources */,
D0B836FB28F1655E006E76C0 /* CommentCell.m in Sources */,
D0B836EF28F100B3006E76C0 /* ComDetailViewModel.m in Sources */,
D091E66B283F120100D3279E /* MyScoreModel.m in Sources */,
D01BD428282C003900BA86B3 /* NoiseTypeModel.m in Sources */,
D01814D227FFCBAF00583D4E /* CWFlowLayout.m in Sources */,
......@@ -2582,6 +2611,7 @@
D0691E02287FB331008BFFAB /* XLCircleProgress.m in Sources */,
D07A4B27280E9BAA00BA0EC0 /* AccountController.m in Sources */,
D062A09E281838B800B4F48A /* FeedbackRequestModel.m in Sources */,
D0B836F828F1232F006E76C0 /* ComReplyModel.m in Sources */,
D0A72E3F282B89AD00EED7BE /* DSHomeView.m in Sources */,
D01814E8280020F900583D4E /* CWPageControl.m in Sources */,
D027EE3027FB52DA004BBA61 /* UIImage+Extras.m in Sources */,
......
......@@ -27,7 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
// 根据文本及字体计算UILabel的高度
+ (CGFloat)getHeightByWidth:(CGFloat)width text:(NSString *)text font:(UIFont *)font;
// 根据文本及字体计算UILabel的宽度
+ (CGFloat)getWidthWithText:(NSString *)text font:(UIFont *)font;
@end
NS_ASSUME_NONNULL_END
......@@ -10,6 +10,7 @@
#import "ComListViewModel.h"
#import "DynamicController.h"
#import "TestFlutterController.h"
#import "DynamicDetailController.h"
@interface CommunityController () <CommunityViewDelegate, DynamicControllerDelegate>
@property (nonatomic, strong) CommunityView *communityView;
......@@ -117,12 +118,14 @@
}
- (void)didSelectItem:(NSIndexPath *)indexPath {
- (void)didSelectItemWithModel:(ComDynModel *)comDynModel {
if (![LoginUtils getUserLoginData]) {
[LoginUtils jumpToLoginControllerWithTarget:self];
return;
}
[self.navigationController pushViewController:[NSClassFromString(@"DynamicDetailController") new] animated:YES];
DynamicDetailController *detailVC = [DynamicDetailController new];
detailVC.comDynModel = comDynModel;
[self.navigationController pushViewController:detailVC animated:YES];
}
- (void)didTapLikeItem:(ComDynModel *)comDynModel cell:(ComDynamicCell *)cell {
......
......@@ -6,12 +6,15 @@
//
#import <UIKit/UIKit.h>
#import "ComDynModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 动态详情页
@interface DynamicDetailController : UIViewController
@property (nonatomic, strong) ComDynModel *comDynModel;
@end
NS_ASSUME_NONNULL_END
......@@ -7,6 +7,7 @@
#import "DynamicDetailController.h"
#import "DynamicDetailView.h"
#import "ComDetailViewModel.h"
@interface DynamicDetailController () <DynamicDetailViewDelegate>
@property (nonatomic, strong) DynamicDetailView *detailView;
......@@ -22,6 +23,17 @@
[super viewDidLoad];
self.navigationItem.title = @"正文";
[self.detailView updateBottomView:self.comDynModel];
[ComDetailViewModel queryDynamicCommentListWithTalkID:self.comDynModel.dynamicID completion:^(ComDetailViewModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
DSLog(@"groupDatas:%@", requestModel.groupDatas.yy_modelDescription);
[self.detailView updateDetailView:requestModel.groupDatas];
} else {
}
}];
}
#pragma mark - DynamicDetailViewDelegate
......
......@@ -7,6 +7,11 @@
#import <Foundation/Foundation.h>
typedef NS_ENUM(int, DynModelType) {
DynModelTypeCom, // 社区动态cell
DynModelTypeDetail, // 社区动态详情cell
};
NS_ASSUME_NONNULL_BEGIN
/// 社区动态列表数据model
......@@ -33,11 +38,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) int remarkCount;
/// 文本显示高度
- (CGFloat)contentHeight;
- (CGFloat)contentHeight:(DynModelType)type;
/// 图片高度
- (CGFloat)imgHeight;
/// 动态cell高度
- (CGFloat)cellHeight;
- (CGFloat)cellHeight:(DynModelType)type;
- (NSArray *)getImgUrlsArr:(NSString *)imgUrls;
@end
......
......@@ -30,11 +30,11 @@
//}
#pragma mark - public
- (CGFloat)contentHeight {
- (CGFloat)contentHeight:(DynModelType)type {
CGFloat contentW = kScreenWidth - 60;
NSString *content = self.content;
CGFloat contentH = [UILabel getHeightByWidth:contentW text:content font:SysFont(14)];
return contentH > 100 ? 100 : contentH;
return type == DynModelTypeCom ? (contentH > 100 ? 100 : contentH) : contentH;
}
- (CGFloat)imgHeight {
......@@ -54,11 +54,11 @@
return 0;
}
- (CGFloat)cellHeight {
- (CGFloat)cellHeight:(DynModelType)type {
NSArray *imgUrls = [self getImgUrlsArr:self.imgUrls];
CGFloat topH = 67;
CGFloat bottomH = imgUrls.count ? 52 : 56;
CGFloat contentH = [self contentHeight];
CGFloat bottomH = type == DynModelTypeCom ? (imgUrls.count ? 52 : 56) : 10;
CGFloat contentH = [self contentHeight:type];
CGFloat imgTextSpace = imgUrls.count ? 12 : 0;
CGFloat imgH = [self imgHeight];
return topH + bottomH + contentH + imgTextSpace + imgH;
......
//
// ComReplyModel.h
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import <Foundation/Foundation.h>
#import "CommentModel.h"
#import "ReplyModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 评论回复model
@interface ComReplyModel : NSObject
/// 评论model
@property (nonatomic, strong) CommentModel *commentModel;
/// 回复model
@property (nonatomic, strong) ReplyModel *replyModel;
- (CGFloat)commentContentHeight;
- (CGFloat)replyViewHeight;
- (CGFloat)commentCellHeight;
@end
NS_ASSUME_NONNULL_END
//
// ComReplyModel.m
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import "ComReplyModel.h"
@implementation ComReplyModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"commentModel" : @"comment",
@"replyModel" : @"reply"
};
}
- (CGFloat)commentContentHeight {
CGFloat contentW = kScreenWidth - 84 - 30;
NSString *content = self.commentModel.content;
CGFloat commentH = [UILabel getHeightByWidth:contentW text:content font:SysFont(14)];
return commentH >= 40 ? 40 : commentH;
}
- (CGFloat)replyViewHeight {
CGFloat replayViewH = 0;
if (self.replyModel) {
CGFloat replayNickNameW = [UILabel getWidthWithText:self.replyModel.nick_name font:SysFont(15)];
replayNickNameW = replayNickNameW > 75 ? 75 : replayNickNameW;
CGFloat replayContentW = kScreenWidth - 84 - 30 - replayNickNameW - 16;
CGFloat replayContentH = [UILabel getHeightByWidth:replayContentW text:self.replyModel.content font:SysFont(14)];
replayContentH = replayContentH >= 40 ? 40 : replayContentH;
replayViewH = 9 + replayContentH + 37;
}
return replayViewH;
}
- (CGFloat)commentCellHeight {
CGFloat topH = 48;
CGFloat commentH = [self commentContentHeight];
CGFloat replayViewH = [self replyViewHeight] + (self.replyModel ? 12 : 0);
CGFloat bottomMargin = 15;
return topH + commentH + replayViewH + bottomMargin;
}
@end
//
// CommentModel.h
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 评论数据model
@interface CommentModel : NSObject
/// 总回复数
@property (nonatomic, assign) int total_replys;
/// 评论内容
@property (nonatomic, copy) NSString *content;
/// 昵称
@property (nonatomic, copy) NSString *nick_name;
/// 评论id
@property (nonatomic, assign) int comment_id;
/// 用户id
@property (nonatomic, assign) int user_id;
/// 头像
@property (nonatomic, copy) NSString *user_profile;
/// 发布时间
@property (nonatomic, copy) NSString *publish_time;
@end
NS_ASSUME_NONNULL_END
//
// CommentModel.m
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import "CommentModel.h"
@implementation CommentModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"comment_id" : @"id"
};
}
@end
//
// ReplyModel.h
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 回复数据model
@interface ReplyModel : NSObject
/// 昵称
@property (nonatomic, copy) NSString *nick_name;
/// 回复id
@property (nonatomic, assign) int reply_id;
/// 回复内容
@property (nonatomic, copy) NSString *content;
/// 用户id
@property (nonatomic, assign) int user_id;
/// 头像
@property (nonatomic, copy) NSString *user_profile;
@end
NS_ASSUME_NONNULL_END
//
// ReplyModel.m
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import "ReplyModel.h"
@implementation ReplyModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"reply_id" : @"id"
};
}
@end
......@@ -14,7 +14,7 @@ typedef void(^TapRemarkBlock)(void);
NS_ASSUME_NONNULL_BEGIN
/// 社区动态Cell
/// 社区动态列表及动态详情cell
@interface ComDynamicCell : UITableViewCell
@property (nonatomic, strong) ComDynModel *model;
......@@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)fireLikeAnimate;
/// 更新点赞UI
- (void)updateLikeUI;
- (instancetype)initWithCellType:(DynModelType)type style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier;
@end
NS_ASSUME_NONNULL_END
......@@ -10,6 +10,8 @@
#import "LikeButton.h"
@interface ComDynamicCell ()
@property (nonatomic, assign) DynModelType modelType;
@property (nonatomic, assign) CGFloat margin;
@property (nonatomic, strong) UIImageView *userIcon;
@property (nonatomic, strong) UILabel *userNameLab;
@property (nonatomic, strong) UILabel *timeLab;
......@@ -24,11 +26,11 @@
@implementation ComDynamicCell
#pragma mark - init
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- (instancetype)initWithCellType:(DynModelType)type style:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self cornerRadius:24.0];
self.modelType = type;
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, AlertDarkColor, DSWhite);
self.photos = [NSMutableArray array];
......@@ -41,8 +43,18 @@
[self.contentView addSubview:self.likeBtn];
[self.contentView addSubview:self.remarkCountBtn];
self.margin = 15;
if (type == DynModelTypeCom) {
[self cornerRadius:24.0];
self.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, CornerViewDarkColor, DSWhite);
} else {
self.margin = 30;
[self hideNeedlessView];
self.backgroundColor = DSClearColor;
}
[self.userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(15);
make.left.equalTo(self.contentView).offset(self.margin);
make.top.equalTo(self.contentView).offset(15);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
......@@ -82,6 +94,12 @@
[self.likeBtn updateLikeBtnState:self.model.isLike likeCount:self.model.likeCount];
}
- (void)hideNeedlessView {
self.informBtn.hidden = YES;
self.likeBtn.hidden = YES;
self.remarkCountBtn.hidden = YES;
}
#pragma mark - setter
- (void)setModel:(ComDynModel *)model {
_model = model;
......@@ -92,12 +110,12 @@
self.contentLab.text = model.content;
[self.likeBtn updateLikeBtnState:model.isLike likeCount:model.likeCount];
[self.remarkCountBtn setTitle:[NSString stringWithFormat:@"%d", model.remarkCount] forState:UIControlStateNormal];
[self.contentLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.userIcon.mas_bottom).offset(12);
make.left.equalTo(self.contentView).offset(15);
make.right.equalTo(self.contentView).offset(-15);
make.height.equalTo(@([model contentHeight]));
make.left.equalTo(self.contentView).offset(self.margin);
make.right.equalTo(self.contentView).offset(-self.margin);
make.height.equalTo(@([model contentHeight:self.modelType]));
}];
// 先移除
......@@ -109,8 +127,8 @@
CGFloat imgContainerViewH = [model imgHeight];
[self.imgContainerView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentLab.mas_bottom).offset(12);
make.left.equalTo(self.contentView).offset(15);
make.right.equalTo(self.contentView).offset(-15);
make.left.equalTo(self.contentView).offset(self.margin);
make.right.equalTo(self.contentView).offset(-self.margin);
make.height.equalTo(@(imgContainerViewH));
}];
if (imgContainerViewH > 0) {
......@@ -192,7 +210,7 @@
- (UILabel *)contentLab {
if (!_contentLab) {
_contentLab = [UILabel labWithFont:SysFont(14)];
_contentLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, SubTitleColor, DSWhite);
_contentLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, ColorFromHexA(0xFFFFFF, .5), DSWhite);
_contentLab.numberOfLines = 0;
}
return _contentLab;
......
//
// CommentCell.h
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import <UIKit/UIKit.h>
#import "ComReplyModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 评论、部分回复cell
@interface CommentCell : UITableViewCell
@property (nonatomic, strong) ComReplyModel *comReplyModel;
@end
NS_ASSUME_NONNULL_END
//
// CommentCell.m
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import "CommentCell.h"
@interface CommentCell ()
@property (nonatomic, strong) UIImageView *userIcon;
@property (nonatomic, strong) UILabel *userNameLab;
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, strong) UIView *replyView;
@end
@implementation CommentCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, DarkColor, DSWhite);
[self.contentView addSubview:self.userIcon];
[self.contentView addSubview:self.userNameLab];
[self.contentView addSubview:self.timeLab];
[self.contentView addSubview:self.contentLab];
[self.contentView addSubview:self.replyView];
[self.userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(30);
make.top.equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
[self.userNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userIcon.mas_right).offset(14);
make.top.equalTo(self.userIcon);
make.right.equalTo(self.contentView).offset(-30);
}];
[self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userNameLab);
make.bottom.equalTo(self.userIcon);
}];
}
return self;
}
- (void)setComReplyModel:(ComReplyModel *)comReplyModel {
_comReplyModel = comReplyModel;
[self.userIcon yy_setImageWithURL:[NSURL URLWithString:comReplyModel.commentModel.user_profile] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(40, 40)]];
self.userNameLab.text = comReplyModel.commentModel.nick_name;
self.timeLab.text = comReplyModel.commentModel.publish_time;
self.contentLab.text = comReplyModel.commentModel.content;
[self.contentLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.userIcon.mas_bottom).offset(8);
make.left.equalTo(self.contentView).offset(84);
make.right.equalTo(self.contentView).offset(-30);
make.height.equalTo(@([comReplyModel commentContentHeight]));
}];
[self.replyView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentLab.mas_bottom).offset(12);
make.left.right.equalTo(self.contentLab);
make.height.equalTo(@([comReplyModel replyViewHeight]));
}];
}
#pragma mark - lazy
- (UIImageView *)userIcon {
if (!_userIcon) {
_userIcon = [UIImageView new];
[_userIcon cornerRadius:20];
_userIcon.dk_alphaPicker = DKAlphaPickerWithAlphas(1.f, 0.5f, 0.1f);
}
return _userIcon;
}
- (UILabel *)userNameLab {
if (!_userNameLab) {
_userNameLab = [UILabel labWithFont:BoldFont(15)];
_userNameLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, DkTitleColor, DSWhite);
}
return _userNameLab;
}
- (UILabel *)timeLab {
if (!_timeLab) {
_timeLab = [UILabel labWithFont:SysFont(12)];
_timeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
}
return _timeLab;
}
- (UILabel *)contentLab {
if (!_contentLab) {
_contentLab = [UILabel labWithFont:SysFont(14)];
_contentLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, ColorFromHexA(0xFFFFFF, .5), DSWhite);
_contentLab.numberOfLines = 0;
}
return _contentLab;
}
- (UIView *)replyView {
if (!_replyView) {
_replyView = [UIView new];
[_replyView cornerRadius:12];
_replyView.dk_backgroundColorPicker = DKColorPickerWithColors(BGColor, CornerViewDarkColor, BGColor);
}
return _replyView;
}
@end
......@@ -22,8 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)publishLogicDeal;
/// 点击动态进入动态详情
/// @param indexPath indexPath
- (void)didSelectItem:(NSIndexPath *)indexPath;
/// @param comDynModel comDynModel
- (void)didSelectItemWithModel:(ComDynModel *)comDynModel;
/// 点赞按钮
/// @param comDynModel 动态数据model
......
......@@ -93,7 +93,7 @@
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
ComDynModel *model = self.listArr[indexPath.section];
return [model cellHeight];
return [model cellHeight:DynModelTypeCom];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
......@@ -114,6 +114,9 @@
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ComDynamicCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([ComDynamicCell class])];
if (!cell) {
cell = [[ComDynamicCell alloc] initWithCellType:DynModelTypeCom style:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([ComDynamicCell class])];
}
ComDynModel *model = self.listArr[indexPath.section];
cell.model = model;
WS(weakSelf);
......@@ -135,8 +138,9 @@
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectItem:)]) {
[self.delegate didSelectItem:indexPath];
ComDynModel *model = self.listArr[indexPath.section];
if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectItemWithModel:)]) {
[self.delegate didSelectItemWithModel:model];
}
}
......@@ -157,7 +161,6 @@
_listView.showsVerticalScrollIndicator = NO;
_listView.separatorStyle = UITableViewCellSeparatorStyleNone;
_listView.tableHeaderView = self.headView;
[_listView registerClass:[ComDynamicCell class] forCellReuseIdentifier:NSStringFromClass([ComDynamicCell class])];
_listView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
WS(weakSelf);
......
......@@ -6,6 +6,7 @@
//
#import <UIKit/UIKit.h>
#import "ComDynModel.h"
NS_ASSUME_NONNULL_BEGIN
......@@ -16,6 +17,14 @@ NS_ASSUME_NONNULL_BEGIN
@interface DynamicDetailView : UIView
@property (nonatomic, weak) id<DynamicDetailViewDelegate> delegate;
- (instancetype)initWithDelegate:(id<DynamicDetailViewDelegate>)delegate;
/// 更新评论框点赞和回复数
/// @param model 社区动态列表传递过来的model
- (void)updateBottomView:(ComDynModel *)model;
/// 更新动态详情页面
/// @param groupData 分组数据
- (void)updateDetailView:(NSArray *)groupData;
@end
NS_ASSUME_NONNULL_END
......@@ -7,9 +7,13 @@
#import "DynamicDetailView.h"
#import "InteractView.h"
#import "ComDynamicCell.h"
#import "CommentCell.h"
@interface DynamicDetailView ()
@interface DynamicDetailView () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *dynamicDetailView;
@property (nonatomic, strong) InteractView *interactView;
@property (nonatomic, strong) NSArray *detailListArr;
@end
@implementation DynamicDetailView
......@@ -17,21 +21,124 @@
- (instancetype)initWithDelegate:(id<DynamicDetailViewDelegate>)delegate {
if (self = [super init]) {
self.delegate = delegate;
self.detailListArr = [NSArray array];
self.backgroundColor = DSWhite;
self.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, DarkColor, DSWhite);
[self addSubview:self.interactView];
[self addSubview:self.dynamicDetailView];
[self.interactView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.height.equalTo(@62);
make.bottom.equalTo(self).offset(-Bottom_SafeArea_Height);
}];
[self.dynamicDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self);
make.bottom.equalTo(self.interactView.mas_top);
}];
}
return self;
}
#pragma mark - public
- (void)updateBottomView:(ComDynModel *)model {
[self.interactView updateLikeCount:model.likeCount remarkCount:model.remarkCount];
}
- (void)updateDetailView:(NSArray *)groupData {
if (groupData.count) {
self.detailListArr = groupData;
[self.dynamicDetailView reloadData];
}
}
#pragma mark - UITableViewDelegate, UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.detailListArr.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
return 1;
} else {
NSArray *comment_reply_arr = self.detailListArr[section];
return comment_reply_arr.count;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
ComDynModel *model = self.detailListArr[0];
return [model cellHeight:DynModelTypeDetail];
} else {
NSArray *comment_reply_arr = self.detailListArr[indexPath.section];
ComReplyModel *comReplyModel = comment_reply_arr[indexPath.row];
return [comReplyModel commentCellHeight];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return section == 0 ? CGFLOAT_MIN : 48;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, section == 0 ? 0 : 48)];
header.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, DarkColor, DSWhite);
UILabel *secLab = [UILabel dkLabWithFont:BoldFont(15)];
secLab.text = section == 0 ? @"" : @"全部评论(4)";
[secLab sizeToFit];
secLab.origin = CGPointMake(30, 15);
[header addSubview:secLab];
return header;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return section == self.detailListArr.count - 1 ? 0.01 : 8;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, section == self.detailListArr.count - 1 ? 0.01 : 8)];
footer.dk_backgroundColorPicker = DKColorPickerWithColors(BGColor, AlertDarkColor, DSWhite);
return footer;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
ComDynamicCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([ComDynamicCell class])];
if (!cell) {
cell = [[ComDynamicCell alloc] initWithCellType:DynModelTypeDetail style:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([ComDynamicCell class])];
}
cell.model = self.detailListArr[indexPath.section];
return cell;
} else {
CommentCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([CommentCell class]) forIndexPath:indexPath];
NSArray *comment_reply_arr = self.detailListArr[indexPath.section];
ComReplyModel *comReplyModel = comment_reply_arr[indexPath.row];
cell.comReplyModel = comReplyModel;
return cell;
}
}
#pragma mark - lazy
- (UITableView *)dynamicDetailView {
if (!_dynamicDetailView) {
_dynamicDetailView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_dynamicDetailView.delegate = self;
_dynamicDetailView.dataSource = self;
_dynamicDetailView.backgroundColor = DSClearColor;
_dynamicDetailView.showsVerticalScrollIndicator = NO;
_dynamicDetailView.separatorStyle = UITableViewCellSeparatorStyleNone;
[_dynamicDetailView registerClass:[CommentCell class] forCellReuseIdentifier:NSStringFromClass([CommentCell class])];
_dynamicDetailView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 0.1)];
_dynamicDetailView.tableFooterView = footView;
}
return _dynamicDetailView;
}
- (InteractView *)interactView {
if (!_interactView) {
_interactView = [InteractView new];
......
......@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 互动区域(点赞、评论)
@interface InteractView : UIView
- (void)updateLikeCount:(int)likeCount remarkCount:(int)remarkCount;
@end
NS_ASSUME_NONNULL_END
......@@ -19,7 +19,7 @@
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.dk_backgroundColorPicker = DKColorPickerWithColors(BGColor, AlertDarkColor, DSWhite);
[self addSubview:self.tapLab];
[self addSubview:self.likeBtn];
......@@ -49,13 +49,19 @@
[self.textInputAlertView showTextInputAlertView];
}
#pragma mark - public
- (void)updateLikeCount:(int)likeCount remarkCount:(int)remarkCount {
[self.likeBtn setTitle:[NSString stringWithFormat:@"%d", likeCount] forState:UIControlStateNormal];
[self.remarkCountBtn setTitle:[NSString stringWithFormat:@"%d", remarkCount] forState:UIControlStateNormal];
}
#pragma mark - lazy
- (UILabel *)tapLab {
if (!_tapLab) {
_tapLab = [UILabel labWithText:@" 回复楼主..." font:SysFont(12) fit:NO];
_tapLab = [UILabel labWithText:@" 说点什么..." font:SysFont(12) fit:NO];
[_tapLab cornerRadius:16.5];
_tapLab.userInteractionEnabled = YES;
_tapLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite);
_tapLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
_tapLab.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, CornerViewDarkColor, DSWhite);
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(popTextInputView)];
[_tapLab addGestureRecognizer:tapGR];
......@@ -65,8 +71,8 @@
- (UIButton *)likeBtn {
if (!_likeBtn) {
_likeBtn = [UIButton btnWithTitle:@"23" font:SysFont(12)];
[_likeBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite) forState:UIControlStateNormal];
_likeBtn = [UIButton btnWithTitle:@"" font:SysFont(12)];
[_likeBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite) forState:UIControlStateNormal];
[_likeBtn dk_setImage:DKImagePickerWithNames(@"ic_shequ_dianza", @"dk_ic_shequ_dianza", @"ic_shequ_dianza") forState:UIControlStateNormal];
_likeBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 9, 0, 0);
}
......@@ -75,9 +81,9 @@
- (UIButton *)remarkCountBtn {
if (!_remarkCountBtn) {
_remarkCountBtn = [UIButton btnWithTitle:@"23" font:SysFont(12)];
[_remarkCountBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite) forState:UIControlStateNormal];
[_remarkCountBtn setImage:[UIImage imageNamed:@"ic_shequ_pinlun"] forState:UIControlStateNormal];
_remarkCountBtn = [UIButton btnWithTitle:@"" font:SysFont(12)];
[_remarkCountBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite) forState:UIControlStateNormal];
[_remarkCountBtn dk_setImage:DKImagePickerWithNames(@"ic_shequ_pinlun", @"dk_ic_shequ_pinlun", @"ic_shequ_pinlun") forState:UIControlStateNormal];
_remarkCountBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 9, 0, 0);
}
return _remarkCountBtn;
......
//
// ComDetailViewModel.h
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import "DSNetworkTool.h"
NS_ASSUME_NONNULL_BEGIN
/// 查询动态评论、查询评论回复列表
@interface ComDetailViewModel : DSNetworkTool
/// 动态详情和评论回复分组数据
@property (nonatomic, strong) NSArray *groupDatas;
/// 查询动态评论列表接口
/// @param talkID 动态id
/// @param completion completion
+ (NSURLSessionDataTask *)queryDynamicCommentListWithTalkID:(int)talkID completion:(void (^)(ComDetailViewModel *requestModel))completion;
/// 用户-发布评论接口
/// @param talkID 动态id
/// @param content 评论内容
/// @param completion completion
+ (NSURLSessionDataTask *)userCommentDynamicWithTalkID:(int)talkID content:(NSString *)content completion:(void (^)(ComDetailViewModel *requestModel))completion;
@end
NS_ASSUME_NONNULL_END
//
// ComDetailViewModel.m
// DreamSleep
//
// Created by peter on 2022/10/8.
//
#import "ComDetailViewModel.h"
#import "ComDynModel.h"
#import "CommentModel.h"
#import "ReplyModel.h"
#import "ComReplyModel.h"
@implementation ComDetailViewModel
+ (NSURLSessionDataTask *)queryDynamicCommentListWithTalkID:(int)talkID completion:(void (^)(ComDetailViewModel *requestModel))completion {
ComDetailViewModel * requestModel = [[ComDetailViewModel alloc] init];
NSString *api = @"query_dynamic_comment_list";
NSString *argStr = [NSString stringWithFormat:@"query{%@(talk_id:%d)}", api, talkID];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"查询动态评论列表接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
NSDictionary *resultDic = apiDic[@"result"];
ComDynModel *talkModel = [ComDynModel yy_modelWithDictionary:resultDic[@"talk"]];
NSArray *comment_list = resultDic[@"comment_list"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < comment_list.count; i++) {
NSDictionary *comment_reply_dic = comment_list[i];
ComReplyModel *comReplyModel = [ComReplyModel yy_modelWithDictionary:comment_reply_dic];
[tmpArr addObject:comReplyModel];
}
requestModel.groupDatas = @[talkModel, tmpArr.copy];
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
requestModel.errMessage = failureInfo[@"errMessage"];
completion(requestModel);
}];
}
+ (NSURLSessionDataTask *)userCommentDynamicWithTalkID:(int)talkID content:(NSString *)content completion:(void (^)(ComDetailViewModel *requestModel))completion {
ComDetailViewModel * requestModel = [[ComDetailViewModel alloc] init];
NSString *api = @"user_comment_dynamic";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(talk_id:%d,content:%@)}", api, talkID, content];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户-发布评论接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
requestModel.errMessage = failureInfo[@"errMessage"];
completion(requestModel);
}];
}
@end
......@@ -9,6 +9,7 @@
NS_ASSUME_NONNULL_BEGIN
/// 社区动态列表、用户点赞
@interface ComListViewModel : DSNetworkTool
@property (nonatomic, assign) int offset;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!