This commit is contained in:
2026-01-28 13:43:36 +08:00
parent 51b744ecd7
commit 7d583ceb1d
14 changed files with 152 additions and 36 deletions

View File

@@ -7,7 +7,6 @@
#import "KBAIReplyModel.h"
#import <MJExtension/MJExtension.h>
#import "KBAIReplyModel.h"
@implementation KBAIReplyModel
@@ -40,6 +39,31 @@
}
}
#pragma mark - MJExtension Hook
/// MJExtension
- (void)mj_didConvertToObjectWithKeyValues:(NSDictionary *)keyValues {
// null
if (!_replyId) {
_replyId = @"";
}
if (!_userId) {
_userId = @"";
}
if (!_userName) {
_userName = @"";
}
if (!_avatarUrl) {
_avatarUrl = @"";
}
if (!_content) {
_content = @"";
}
if (!_replyToUserName) {
_replyToUserName = @"";
}
}
- (NSString *)formattedTime {
NSDate *date = [NSDate dateWithTimeIntervalSince1970:self.createTime];
NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:date];
@@ -70,7 +94,7 @@
CGFloat contentWidth = maxWidth - 68 - 28 - 8 - 50;
// "回复 @xxx"
NSMutableString *userNameText = [NSMutableString stringWithString:self.userName];
NSMutableString *userNameText = [NSMutableString stringWithString:self.userName ?: @""];
if (self.replyToUserName.length > 0) {
[userNameText appendFormat:@" 回复 @%@", self.replyToUserName];
}
@@ -83,7 +107,8 @@
//
UIFont *contentFont = [UIFont systemFontOfSize:14];
CGRect contentRect = [self.content boundingRectWithSize:CGSizeMake(contentWidth, CGFLOAT_MAX)
NSString *contentText = self.content ?: @"";
CGRect contentRect = [contentText boundingRectWithSize:CGSizeMake(contentWidth, CGFLOAT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:@{NSFontAttributeName: contentFont}
context:nil];