提交
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TUIFileReplyQuoteViewData.h
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIVoiceReplyQuoteViewData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIFileReplyQuoteViewData : TUIVoiceReplyQuoteViewData
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// TUIFileReplyQuoteViewData.m
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIFileReplyQuoteViewData.h"
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
#import "TUIFileMessageCellData.h"
|
||||
|
||||
@implementation TUIFileReplyQuoteViewData
|
||||
|
||||
+ (instancetype)getReplyQuoteViewData:(TUIMessageCellData *)originCellData {
|
||||
if (originCellData == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (![originCellData isKindOfClass:TUIFileMessageCellData.class]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
TUIFileReplyQuoteViewData *myData = [[TUIFileReplyQuoteViewData alloc] init];
|
||||
myData.text = [(TUIFileMessageCellData *)originCellData fileName];
|
||||
myData.icon = TUIChatCommonBundleImage(@"msg_file");
|
||||
myData.originCellData = originCellData;
|
||||
return myData;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// TUIImageReplyQuoteViewData.h
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIReplyMessageCellData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
typedef NS_ENUM(NSUInteger, TUIImageReplyQuoteStatus) {
|
||||
TUIImageReplyQuoteStatusInit,
|
||||
TUIImageReplyQuoteStatusDownloading,
|
||||
TUIImageReplyQuoteStatusSuccess,
|
||||
TUIImageReplyQuoteStatusFailed,
|
||||
};
|
||||
|
||||
@interface TUIImageReplyQuoteViewData : TUIReplyQuoteViewData
|
||||
|
||||
@property(nonatomic, assign) TUIImageReplyQuoteStatus imageStatus;
|
||||
|
||||
@property(nonatomic, strong) UIImage *image;
|
||||
|
||||
@property(nonatomic, assign) CGSize imageSize;
|
||||
|
||||
+ (CGSize)displaySizeWithOriginSize:(CGSize)originSize;
|
||||
- (void)downloadImage;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// TUIImageReplyQuoteViewData.m
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIImageReplyQuoteViewData.h"
|
||||
#import "TUIImageMessageCellData.h"
|
||||
|
||||
@implementation TUIImageReplyQuoteViewData
|
||||
|
||||
+ (instancetype)getReplyQuoteViewData:(TUIMessageCellData *)originCellData {
|
||||
if (originCellData == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (![originCellData isKindOfClass:TUIImageMessageCellData.class]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
TUIImageReplyQuoteViewData *myData = [[TUIImageReplyQuoteViewData alloc] init];
|
||||
V2TIMImage *thumb = nil;
|
||||
for (V2TIMImage *image in originCellData.innerMessage.imageElem.imageList) {
|
||||
if (image.type == V2TIM_IMAGE_TYPE_THUMB) {
|
||||
thumb = image;
|
||||
break;
|
||||
}
|
||||
}
|
||||
myData.imageSize = [TUIImageReplyQuoteViewData displaySizeWithOriginSize:CGSizeMake(thumb ? thumb.width : 60, thumb ? thumb.height : 60)];
|
||||
myData.originCellData = originCellData;
|
||||
myData.imageStatus = TUIImageReplyQuoteStatusInit;
|
||||
return myData;
|
||||
}
|
||||
|
||||
- (CGSize)contentSize:(CGFloat)maxWidth {
|
||||
return self.imageSize;
|
||||
}
|
||||
|
||||
+ (CGSize)displaySizeWithOriginSize:(CGSize)originSize {
|
||||
if (originSize.width == 0 || originSize.width == 0) {
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
CGFloat max = 60;
|
||||
CGFloat w = 0, h = 0;
|
||||
if (originSize.width > originSize.height) {
|
||||
w = max;
|
||||
h = max * originSize.height / originSize.width;
|
||||
} else {
|
||||
w = max * originSize.width / originSize.height;
|
||||
h = max;
|
||||
}
|
||||
return CGSizeMake(w, h);
|
||||
}
|
||||
|
||||
- (void)downloadImage {
|
||||
@weakify(self);
|
||||
self.imageStatus = TUIImageReplyQuoteStatusDownloading;
|
||||
if ([self.originCellData isKindOfClass:TUIImageMessageCellData.class]) {
|
||||
TUIImageMessageCellData *imageData = (TUIImageMessageCellData *)self.originCellData;
|
||||
[imageData downloadImage:TImage_Type_Thumb
|
||||
finish:^{
|
||||
@strongify(self);
|
||||
self.image = imageData.thumbImage;
|
||||
self.imageStatus = TUIImageReplyQuoteStatusSuccess;
|
||||
if (self.onFinish) {
|
||||
self.onFinish();
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TUIMergeReplyQuoteViewData.h
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIReplyMessageCellData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIMergeReplyQuoteViewData : TUIReplyQuoteViewData
|
||||
|
||||
@property(nonatomic, copy) NSString *title;
|
||||
@property(nonatomic, copy) NSString *abstract;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// TUIMergeReplyQuoteViewData.m
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIMergeReplyQuoteViewData.h"
|
||||
#import <TIMCommon/NSString+TUIEmoji.h>
|
||||
#import "TUIMergeMessageCellData.h"
|
||||
|
||||
@implementation TUIMergeReplyQuoteViewData
|
||||
|
||||
+ (instancetype)getReplyQuoteViewData:(TUIMessageCellData *)originCellData {
|
||||
if (originCellData == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (![originCellData isKindOfClass:TUIMergeMessageCellData.class]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
TUIMergeReplyQuoteViewData *myData = [[TUIMergeReplyQuoteViewData alloc] init];
|
||||
myData.title = [(TUIMergeMessageCellData *)originCellData title];
|
||||
NSAttributedString *abstract = [(TUIMergeMessageCellData *)originCellData abstractAttributedString];
|
||||
myData.abstract = abstract.string;
|
||||
myData.originCellData = originCellData;
|
||||
return myData;
|
||||
}
|
||||
|
||||
- (CGSize)contentSize:(CGFloat)maxWidth {
|
||||
CGFloat singleHeight = [UIFont systemFontOfSize:10.0].lineHeight;
|
||||
NSAttributedString *titleAttributeString = [self.title getFormatEmojiStringWithFont:[UIFont systemFontOfSize:10.0] emojiLocations:nil];
|
||||
CGRect titleRect = [titleAttributeString boundingRectWithSize:CGSizeMake(maxWidth, singleHeight)
|
||||
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
|
||||
context:nil];
|
||||
CGFloat width = titleRect.size.width;
|
||||
CGFloat height = titleRect.size.height;
|
||||
return CGSizeMake(MIN(width, maxWidth), height);
|
||||
}
|
||||
|
||||
@end
|
||||
107
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyMessageCellData.h
Normal file
107
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyMessageCellData.h
Normal file
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// TUIReplyMessageCellData.h
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/11.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <ImSDK_Plus/ImSDK_Plus.h>
|
||||
#import <TIMCommon/TUIBubbleMessageCellData.h>
|
||||
#import "TUIChatDefine.h"
|
||||
#import "TUIReplyQuoteViewData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TUIReplyMessageCellData;
|
||||
|
||||
@interface TUIReplyMessageCellData : TUIBubbleMessageCellData
|
||||
|
||||
/**
|
||||
* The original message ID
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *__nullable originMsgID;
|
||||
|
||||
/**
|
||||
* The default abstract of original message
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *__nullable msgAbstract;
|
||||
|
||||
/**
|
||||
* The sender of original message
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *__nullable sender;
|
||||
|
||||
/**
|
||||
* The sender of original message
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *__nullable faceURL;
|
||||
|
||||
/**
|
||||
* The type of original message
|
||||
*/
|
||||
@property(nonatomic, assign) V2TIMElemType originMsgType;
|
||||
|
||||
/**
|
||||
*
|
||||
* Original message
|
||||
*/
|
||||
@property(nonatomic, strong) V2TIMMessage *__nullable originMessage;
|
||||
@property(nonatomic, strong) TUIMessageCellData *originCellData;
|
||||
@property(nonatomic, strong) TUIReplyQuoteViewData *quoteData;
|
||||
@property(nonatomic, assign) BOOL showRevokedOriginMessage;
|
||||
|
||||
/**
|
||||
* The content of replying the original message
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *content;
|
||||
@property(nonatomic, strong, readonly) NSAttributedString *attributeString;
|
||||
|
||||
/**
|
||||
* The size of quote view, including @senderSize and @quotePlaceholderSize
|
||||
*/
|
||||
@property(nonatomic, assign) CGSize quoteSize;
|
||||
|
||||
/**
|
||||
* The size of label which displays the sender displayname
|
||||
*/
|
||||
@property(nonatomic, assign) CGSize senderSize;
|
||||
|
||||
/**
|
||||
* The size of customize quote view
|
||||
*/
|
||||
@property(nonatomic, assign) CGSize quotePlaceholderSize;
|
||||
|
||||
/**
|
||||
* The size of label which displays the content of replying the original message.
|
||||
*/
|
||||
@property(nonatomic, assign) CGSize replyContentSize;
|
||||
|
||||
@property(nonatomic, copy) TUIReplyAsyncLoadFinish onFinish;
|
||||
|
||||
/**
|
||||
* The message ID of the root message which is replyed at first.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *messageRootID;
|
||||
|
||||
@property(nonatomic) UIColor *textColor;
|
||||
|
||||
@property(nonatomic, strong) NSString *selectContent;
|
||||
@property(nonatomic, strong) NSMutableArray<NSDictionary<NSValue *, NSAttributedString *> *> *emojiLocations;
|
||||
|
||||
// Deprecated
|
||||
// Search `loadOriginMessageFromReplyData` in TUIMessageDataProvider+MessageDeal
|
||||
//- (void)loadOriginMessage:(void(^)(void))callback;
|
||||
|
||||
- (TUIReplyQuoteViewData *)getQuoteData:(TUIMessageCellData *)originCellData;
|
||||
- (CGSize)quotePlaceholderSizeWithType:(V2TIMElemType)type data:(TUIReplyQuoteViewData *)data;
|
||||
|
||||
@end
|
||||
|
||||
@interface TUIReferenceMessageCellData : TUIReplyMessageCellData
|
||||
|
||||
@property(nonatomic, assign) CGSize textSize;
|
||||
@property(nonatomic, assign) CGPoint textOrigin;
|
||||
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
173
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyMessageCellData.m
Normal file
173
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyMessageCellData.m
Normal file
@@ -0,0 +1,173 @@
|
||||
//
|
||||
// TUIReplyMessageCellData.m
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/11.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
/**
|
||||
The protocol format of the custom field cloudMessageData of the message
|
||||
|
||||
{
|
||||
"messageReply":{
|
||||
"messageID": "xxxx0xxx=xx",
|
||||
"messageAbstract":"origin message abstract..."
|
||||
"messageSender":"NickName/99618",
|
||||
"messageType": "1/2/..",
|
||||
"version":"1",
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#import "TUIReplyMessageCellData.h"
|
||||
#import <TIMCommon/NSString+TUIEmoji.h>
|
||||
#import "TUIFileMessageCellData.h"
|
||||
#import "TUIImageMessageCellData.h"
|
||||
#import "TUIMergeMessageCellData.h"
|
||||
#import "TUITextMessageCellData.h"
|
||||
#import "TUIVideoMessageCellData.h"
|
||||
#import "TUIVoiceMessageCellData.h"
|
||||
|
||||
#import "TUICloudCustomDataTypeCenter.h"
|
||||
#import "TUIFileReplyQuoteViewData.h"
|
||||
#import "TUIImageReplyQuoteViewData.h"
|
||||
#import "TUIMergeReplyQuoteViewData.h"
|
||||
#import "TUIReplyPreviewData.h"
|
||||
#import "TUITextReplyQuoteViewData.h"
|
||||
#import "TUIVideoReplyQuoteViewData.h"
|
||||
#import "TUIVoiceReplyQuoteViewData.h"
|
||||
|
||||
@implementation TUIReplyMessageCellData
|
||||
{
|
||||
NSString *_sender;
|
||||
}
|
||||
|
||||
- (void)setSender:(NSString *)sender {
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
- (NSString *__nullable)sender {
|
||||
if (self.originMessage) {
|
||||
return self.originMessage.nameCard ? : (self.originMessage.friendRemark ? : (self.originMessage.nickName ? : self.originMessage.sender));
|
||||
}
|
||||
return _sender;
|
||||
}
|
||||
|
||||
+ (TUIMessageCellData *)getCellData:(V2TIMMessage *)message {
|
||||
if (message.cloudCustomData == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
__block TUIReplyMessageCellData *replyData = nil;
|
||||
[message doThingsInContainsCloudCustomOfDataType:TUICloudCustomDataType_MessageReply
|
||||
callback:^(BOOL isContains, id obj) {
|
||||
if (isContains) {
|
||||
if (obj && [obj isKindOfClass:NSDictionary.class]) {
|
||||
NSDictionary *reply = (NSDictionary *)obj;
|
||||
// This message is a "reply message"
|
||||
replyData = [[TUIReplyMessageCellData alloc]
|
||||
initWithDirection:(message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming)];
|
||||
replyData.reuseId = TReplyMessageCell_ReuseId;
|
||||
replyData.originMsgID = reply[@"messageID"];
|
||||
replyData.msgAbstract = reply[@"messageAbstract"];
|
||||
replyData.sender = reply[@"messageSender"];
|
||||
replyData.originMsgType = (V2TIMElemType)[reply[@"messageType"] integerValue];
|
||||
replyData.content = message.textElem.text;
|
||||
replyData.messageRootID = reply[@"messageRootID"];
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
return replyData;
|
||||
}
|
||||
|
||||
- (instancetype)initWithDirection:(TMsgDirection)direction {
|
||||
self = [super initWithDirection:direction];
|
||||
if (self) {
|
||||
if (direction == MsgDirectionIncoming) {
|
||||
self.cellLayout = [TUIMessageCellLayout incommingTextMessageLayout];
|
||||
} else {
|
||||
self.cellLayout = [TUIMessageCellLayout outgoingTextMessageLayout];
|
||||
}
|
||||
_emojiLocations = [NSMutableArray array];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CGSize)quotePlaceholderSizeWithType:(V2TIMElemType)type data:(TUIReplyQuoteViewData *)data {
|
||||
if (data == nil) {
|
||||
return CGSizeMake(20, 20);
|
||||
}
|
||||
|
||||
return [data contentSize:TReplyQuoteView_Max_Width - 12];
|
||||
}
|
||||
|
||||
- (TUIReplyQuoteViewData *)getQuoteData:(TUIMessageCellData *)originCellData {
|
||||
TUIReplyQuoteViewData *quoteData = nil;
|
||||
Class class = [originCellData getReplyQuoteViewDataClass];
|
||||
BOOL hasRiskContent = originCellData.innerMessage.hasRiskContent;
|
||||
if (hasRiskContent && [TIMConfig isClassicEntrance]){
|
||||
// Return text reply data in default
|
||||
TUITextReplyQuoteViewData *myData = [[TUITextReplyQuoteViewData alloc] init];
|
||||
myData.text = [TUIReplyPreviewData displayAbstract:self.originMsgType abstract:self.msgAbstract withFileName:NO isRisk:hasRiskContent];
|
||||
quoteData = myData;
|
||||
}
|
||||
else if (class && [class respondsToSelector:@selector(getReplyQuoteViewData:)]) {
|
||||
quoteData = [class getReplyQuoteViewData:originCellData];
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
if (quoteData == nil) {
|
||||
//
|
||||
// Return text reply data in default
|
||||
TUITextReplyQuoteViewData *myData = [[TUITextReplyQuoteViewData alloc] init];
|
||||
myData.text = [TUIReplyPreviewData displayAbstract:self.originMsgType abstract:self.msgAbstract withFileName:NO isRisk:hasRiskContent];
|
||||
quoteData = myData;
|
||||
}
|
||||
|
||||
quoteData.originCellData = originCellData;
|
||||
@weakify(self);
|
||||
quoteData.onFinish = ^{
|
||||
@strongify(self);
|
||||
if (self.onFinish) {
|
||||
self.onFinish();
|
||||
}
|
||||
};
|
||||
return quoteData;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation TUIReferenceMessageCellData
|
||||
|
||||
+ (TUIMessageCellData *)getCellData:(V2TIMMessage *)message {
|
||||
if (message.cloudCustomData == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
__block TUIReplyMessageCellData *replyData = nil;
|
||||
[message doThingsInContainsCloudCustomOfDataType:TUICloudCustomDataType_MessageReference
|
||||
callback:^(BOOL isContains, id obj) {
|
||||
if (isContains) {
|
||||
if (obj && [obj isKindOfClass:NSDictionary.class]) {
|
||||
NSDictionary *reply = (NSDictionary *)obj;
|
||||
if ([reply isKindOfClass:NSDictionary.class]) {
|
||||
// This message is 「quote message」which indicating the original message
|
||||
replyData = [[TUIReferenceMessageCellData alloc]
|
||||
initWithDirection:(message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming)];
|
||||
replyData.reuseId = TUIReferenceMessageCell_ReuseId;
|
||||
replyData.originMsgID = reply[@"messageID"];
|
||||
replyData.msgAbstract = reply[@"messageAbstract"];
|
||||
replyData.sender = reply[@"messageSender"];
|
||||
replyData.originMsgType = (V2TIMElemType)[reply[@"messageType"] integerValue];
|
||||
replyData.content = message.textElem.text; // text only
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
return replyData;
|
||||
}
|
||||
|
||||
@end
|
||||
55
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyPreviewData.h
Normal file
55
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyPreviewData.h
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// TUIReplyPreviewData.h
|
||||
// TUIChat
|
||||
//
|
||||
// Created by wyl on 2022/3/22.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TUIChatDefine.h"
|
||||
|
||||
@class V2TIMMessage;
|
||||
|
||||
@interface TUIReplyPreviewData : NSObject
|
||||
|
||||
/**
|
||||
* The message ID of the replyed original message
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *msgID;
|
||||
|
||||
/**
|
||||
* The abstract of the replyed original message
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *msgAbstract;
|
||||
|
||||
/**
|
||||
* The sender's displayname of the replyed original message. Nickname is prior than userID.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *sender;
|
||||
|
||||
/**
|
||||
* The faceURL of the replyed original message
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *faceURL;
|
||||
|
||||
/**
|
||||
* The message type of the replyed original message. For details, see the enumeration value of V2TIMElemType.
|
||||
*/
|
||||
@property(nonatomic, assign) NSInteger type;
|
||||
|
||||
/**
|
||||
* The replyed original message
|
||||
*/
|
||||
@property(nonatomic, strong) V2TIMMessage *originMessage;
|
||||
|
||||
// Message reply root RootID (not necessarily the msgID of the originMessage above, but the ID of the message at the top)
|
||||
@property(nonatomic, copy) NSString *messageRootID;
|
||||
|
||||
+ (NSString *)displayAbstract:(NSInteger)type abstract:(NSString *)abstract withFileName:(BOOL)withFilename isRisk:(BOOL)isRisk;
|
||||
|
||||
@end
|
||||
|
||||
@interface TUIReferencePreviewData : TUIReplyPreviewData
|
||||
|
||||
@end
|
||||
39
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyPreviewData.m
Normal file
39
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyPreviewData.m
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// TUIReplyPreviewData.m
|
||||
// TUIChat
|
||||
//
|
||||
// Created by wyl on 2022/3/22.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIReplyPreviewData.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
|
||||
@implementation TUIReplyPreviewData
|
||||
|
||||
+ (NSString *)displayAbstract:(NSInteger)type abstract:(NSString *)abstract withFileName:(BOOL)withFilename isRisk:(BOOL)isRisk {
|
||||
NSString *text = abstract;
|
||||
if (type == V2TIM_ELEM_TYPE_IMAGE) {
|
||||
text = isRisk? TIMCommonLocalizableString(TUIkitMessageTypeRiskImage):TIMCommonLocalizableString(TUIkitMessageTypeImage);
|
||||
} else if (type == V2TIM_ELEM_TYPE_VIDEO) {
|
||||
text = isRisk? TIMCommonLocalizableString(TUIkitMessageTypeRiskVideo):TIMCommonLocalizableString(TUIkitMessageTypeVideo);
|
||||
} else if (type == V2TIM_ELEM_TYPE_SOUND) {
|
||||
text = isRisk? TIMCommonLocalizableString(TUIkitMessageTypeRiskVoice):TIMCommonLocalizableString(TUIKitMessageTypeVoice);
|
||||
} else if (type == V2TIM_ELEM_TYPE_FACE) {
|
||||
text = TIMCommonLocalizableString(TUIKitMessageTypeAnimateEmoji);
|
||||
} else if (type == V2TIM_ELEM_TYPE_FILE) {
|
||||
if (withFilename) {
|
||||
text = [NSString stringWithFormat:@"%@%@", TIMCommonLocalizableString(TUIkitMessageTypeFile), abstract];
|
||||
;
|
||||
} else {
|
||||
text = TIMCommonLocalizableString(TUIkitMessageTypeFile);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation TUIReferencePreviewData
|
||||
|
||||
@end
|
||||
37
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyQuoteViewData.h
Normal file
37
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyQuoteViewData.h
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// TUIReplyQuoteViewData.h
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TUIChatDefine.h"
|
||||
|
||||
@class TUIMessageCellData;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIReplyQuoteViewData : NSObject
|
||||
|
||||
+ (instancetype)getReplyQuoteViewData:(TUIMessageCellData *)originCellData;
|
||||
|
||||
- (CGSize)contentSize:(CGFloat)maxWidth;
|
||||
|
||||
/**
|
||||
* If you want to download the custom reply content asynchronously, you need to call the callback after the download is complete, and the TUI will be
|
||||
* automatically refreshed.
|
||||
*/
|
||||
@property(nonatomic, copy) TUIReplyQuoteAsyncLoadFinish onFinish;
|
||||
|
||||
@property(nonatomic, strong) TUIMessageCellData *originCellData;
|
||||
|
||||
@property(nonatomic, assign) BOOL supportForReply;
|
||||
|
||||
@property(nonatomic, assign) BOOL showRevokedOriginMessage;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
21
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyQuoteViewData.m
Normal file
21
TUIKit/TUIChat/BaseCellData/Reply/TUIReplyQuoteViewData.m
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TUIReplyQuoteViewData.m
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIReplyQuoteViewData.h"
|
||||
|
||||
@implementation TUIReplyQuoteViewData
|
||||
|
||||
+ (instancetype)getReplyQuoteViewData:(TUIMessageCellData *)originCellData {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CGSize)contentSize:(CGFloat)maxWidth {
|
||||
return CGSizeZero;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TUITextReplyQuoteViewData.h
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIReplyMessageCellData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUITextReplyQuoteViewData : TUIReplyQuoteViewData
|
||||
|
||||
@property(nonatomic, copy) NSString *text;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// TUITextReplyQuoteViewData.m
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUITextReplyQuoteViewData.h"
|
||||
#import <TIMCommon/NSString+TUIEmoji.h>
|
||||
#import "TUITextMessageCellData.h"
|
||||
|
||||
@implementation TUITextReplyQuoteViewData
|
||||
|
||||
+ (instancetype)getReplyQuoteViewData:(TUIMessageCellData *)originCellData {
|
||||
if (originCellData == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (![originCellData isKindOfClass:TUITextMessageCellData.class]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
TUITextReplyQuoteViewData *myData = [[TUITextReplyQuoteViewData alloc] init];
|
||||
myData.text = [(TUITextMessageCellData *)originCellData content];
|
||||
myData.originCellData = originCellData;
|
||||
return myData;
|
||||
}
|
||||
|
||||
- (CGSize)contentSize:(CGFloat)maxWidth {
|
||||
NSAttributedString *attributeString = nil;
|
||||
BOOL showRevokeStr = (self.originCellData.innerMessage.status == V2TIM_MSG_STATUS_LOCAL_REVOKED) &&
|
||||
!self.showRevokedOriginMessage;
|
||||
if (showRevokeStr) {
|
||||
NSString * revokeStr = self.supportForReply?
|
||||
TIMCommonLocalizableString(TUIKitRepliesOriginMessageRevoke):
|
||||
TIMCommonLocalizableString(TUIKitReferenceOriginMessageRevoke);
|
||||
attributeString = [revokeStr getFormatEmojiStringWithFont:[UIFont systemFontOfSize:10.0] emojiLocations:nil];
|
||||
} else {
|
||||
attributeString = [self.text getFormatEmojiStringWithFont:[UIFont systemFontOfSize:10.0] emojiLocations:nil];
|
||||
}
|
||||
|
||||
CGSize size = [@"0" sizeWithAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:10.0]}];
|
||||
CGRect rect = [attributeString boundingRectWithSize:CGSizeMake(maxWidth, size.height * 2)
|
||||
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
|
||||
context:nil];
|
||||
CGFloat h = rect.size.height < size.height * 2 ? rect.size.height : size.height * 2;
|
||||
if (showRevokeStr && self.supportForReply) {
|
||||
h = size.height *2;
|
||||
}
|
||||
return CGSizeMake(rect.size.width, h);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TUIVideoReplyQuoteViewData.h
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIImageReplyQuoteViewData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIVideoReplyQuoteViewData : TUIImageReplyQuoteViewData
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// TUIVideoReplyQuoteViewData.m
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIVideoReplyQuoteViewData.h"
|
||||
#import "TUIVideoMessageCellData.h"
|
||||
|
||||
@implementation TUIVideoReplyQuoteViewData
|
||||
|
||||
+ (instancetype)getReplyQuoteViewData:(TUIMessageCellData *)originCellData {
|
||||
if (originCellData == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (![originCellData isKindOfClass:TUIVideoMessageCellData.class]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
TUIVideoReplyQuoteViewData *myData = [[TUIVideoReplyQuoteViewData alloc] init];
|
||||
CGSize snapSize = CGSizeMake(originCellData.innerMessage.videoElem ? originCellData.innerMessage.videoElem.snapshotWidth : 0,
|
||||
originCellData.innerMessage.videoElem ? originCellData.innerMessage.videoElem.snapshotHeight : 0);
|
||||
myData.imageSize = [TUIVideoReplyQuoteViewData displaySizeWithOriginSize:snapSize];
|
||||
myData.originCellData = originCellData;
|
||||
return myData;
|
||||
}
|
||||
|
||||
- (void)downloadImage {
|
||||
[super downloadImage];
|
||||
|
||||
@weakify(self);
|
||||
if ([self.originCellData isKindOfClass:TUIVideoMessageCellData.class]) {
|
||||
TUIVideoMessageCellData *videoData = (TUIVideoMessageCellData *)self.originCellData;
|
||||
[videoData downloadThumb:^{
|
||||
@strongify(self);
|
||||
self.image = videoData.thumbImage;
|
||||
if (self.onFinish) {
|
||||
self.onFinish();
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TUIVoiceReplyQuoteViewData.h
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUITextReplyQuoteViewData.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIVoiceReplyQuoteViewData : TUITextReplyQuoteViewData
|
||||
|
||||
@property(nonatomic, strong) UIImage *icon;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// TUIVoiceReplyQuoteViewData.m
|
||||
// TUIChat
|
||||
//
|
||||
// Created by harvy on 2021/11/25.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIVoiceReplyQuoteViewData.h"
|
||||
#import <TIMCommon/NSString+TUIEmoji.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
#import "TUIVoiceMessageCellData.h"
|
||||
@implementation TUIVoiceReplyQuoteViewData
|
||||
|
||||
+ (instancetype)getReplyQuoteViewData:(TUIMessageCellData *)originCellData {
|
||||
if (originCellData == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (![originCellData isKindOfClass:TUIVoiceMessageCellData.class]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
TUIVoiceReplyQuoteViewData *myData = [[TUIVoiceReplyQuoteViewData alloc] init];
|
||||
myData.text = [NSString stringWithFormat:@"%d\"", [(TUIVoiceMessageCellData *)originCellData duration]];
|
||||
myData.icon = TUIChatCommonBundleImage(@"voice_reply");
|
||||
myData.originCellData = originCellData;
|
||||
return myData;
|
||||
}
|
||||
|
||||
- (CGSize)contentSize:(CGFloat)maxWidth {
|
||||
CGFloat marginWidth = 18;
|
||||
CGSize size = [@"0" sizeWithAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:10.0]}];
|
||||
CGRect rect = [self.text boundingRectWithSize:CGSizeMake(maxWidth - marginWidth, size.height)
|
||||
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
|
||||
attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:10.0]}
|
||||
context:nil];
|
||||
return CGSizeMake(rect.size.width + marginWidth, size.height);
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user