12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- //
- // YMDynamicDetailCommentCellViewModel.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/21.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMDynamicDetailCommentCellViewModel.h"
- #import "YMDynamicCommentModel.h"
- @interface YMDynamicDetailCommentCellViewModel ()
- /// 动态Id
- @property (nonatomic, assign, readwrite) NSInteger commentId;
- /// 用户Id
- @property (nonatomic, assign, readwrite) NSInteger userId;
- /// 用户头像
- @property (nonatomic, strong, readwrite) NSString *userAvatar;
- /// 用户昵称
- @property (nonatomic, strong, readwrite) NSString *userNickname;
- /// 动态消息日期
- @property (nonatomic, strong, readwrite) NSString *dynamicCommentDate;
- /// 动态消息内容
- @property (nonatomic, strong, readwrite) NSAttributedString *dynamicCommentContent;
- @end
- @implementation YMDynamicDetailCommentCellViewModel
- - (void)ym_initialize{
- [super ym_initialize];
- if ([self.params[ParamsModel] isKindOfClass:[YMDynamicCommentModel class]]) {
- YMDynamicCommentModel *model = self.params[ParamsModel];
- self.commentId = model.comment_id;
- self.userId = model.user_id;
- self.userAvatar = model.avatar;
- self.userNickname = model.nickname;
- self.dynamicCommentDate = model.create_time;
- NSString *content = @"";
- switch (model.is_type) {
- case 1:
- {
- if (model.comment_user_id != 0) {
- content = stringFormat(@"回复%@:%@",model.comment_nickname,model.content);
- }else{
- content = model.content;
- }
- }
- break;
- case 2:
- {
- content = stringFormat(@"%@回复了你:%@",model.nickname,model.content);
- }
- break;
- case 3:
- {
- content = stringFormat(@"%@评论了你:%@",model.nickname,model.content);
- }
- break;
- default:
- break;
- }
- NSMutableAttributedString *dynamicCommentContentAttributed = [[NSMutableAttributedString alloc]initWithString:content];
- dynamicCommentContentAttributed.yy_font = LCFont(13);
- dynamicCommentContentAttributed.yy_color = HexColorFromRGB(0x333333);
- dynamicCommentContentAttributed.yy_alignment = NSTextAlignmentLeft;
- dynamicCommentContentAttributed.yy_lineSpacing = 5;
- [dynamicCommentContentAttributed yy_setColor:HexColorFromRGB(0x7c69fe) range:[content rangeOfString:model.nickname]];
- self.dynamicCommentContent = dynamicCommentContentAttributed;
-
-
-
- }
-
- }
- @end
|