增加换肤功能

This commit is contained in:
启星
2025-08-14 10:07:49 +08:00
parent f6964c1e89
commit 4f9318d98e
8789 changed files with 978530 additions and 2 deletions

View File

@@ -0,0 +1,16 @@
// Created by Tencent on 2023/06/09.
// Copyright © 2023 Tencent. All rights reserved.
/**
*
* This file declares the data source for TUIGroupCreatedCell
*/
#import <TIMCommon/TUISystemMessageCellData.h>
@interface TUIGroupCreatedCellData : TUISystemMessageCellData
@property(nonatomic, copy) NSString *opUser;
@property(nonatomic, strong) NSNumber *cmd;
@end

View File

@@ -0,0 +1,87 @@
//
// TUIGroupCreatedCellData.m
// TUIKitDemo
//
// Created by annidyfeng on 2019/6/10.
// Copyright © 2019 Tencent. All rights reserved.
//
#import "TUIGroupCreatedCellData.h"
#import <TUICore/NSString+TUIUtil.h>
@implementation TUIGroupCreatedCellData
+ (TUIGroupCreatedCellData *)getCellData:(V2TIMMessage *)message {
NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data options:NSJSONReadingAllowFragments error:nil];
TUIGroupCreatedCellData *cellData = [[TUIGroupCreatedCellData alloc] initWithDirection:(message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming)];
cellData.innerMessage = message;
cellData.msgID = message.msgID;
cellData.content = param[@"content"];
cellData.opUser = [self.class getOpUserName:message]?:param[@"opUser"];
cellData.cmd = param[@"cmd"];
return cellData;
}
+ (NSString *)getOpUserName:(V2TIMMessage *)info {
NSString *opUser;
if (info.nameCard.length > 0) {
opUser = info.nameCard;
} else if (info.nickName.length > 0) {
opUser = info.nickName;
} else {
opUser = info.userID;
}
return opUser;
}
- (NSMutableAttributedString *)attributedString {
NSString *localizableContent = self.content;
if (self.cmd && [self.cmd isKindOfClass:NSNumber.class]) {
NSInteger command = [self.cmd integerValue];
if (command == 1) {
localizableContent = TIMCommonLocalizableString(TUICommunityCreateTipsMessage);
} else {
localizableContent = TIMCommonLocalizableString(TUIGroupCreateTipsMessage);
}
}
NSString *str = [NSString stringWithFormat:@"\"%@\" %@", self.opUser, localizableContent];
str = rtlString(str);
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:str];
NSDictionary *attributeDict = @{NSForegroundColorAttributeName : [UIColor d_systemGrayColor]};
[attributeString setAttributes:attributeDict range:NSMakeRange(0, attributeString.length)];
return attributeString;
}
+ (NSString *)getDisplayString:(V2TIMMessage *)msg {
if (msg.customElem == nil || msg.customElem.data == nil) {
return nil;
}
NSDictionary *param = [TUITool jsonData2Dictionary:msg.customElem.data];
if (param == nil || ![param isKindOfClass:[NSDictionary class]]) {
return nil;
}
NSString *businessID = param[@"businessID"];
if (![businessID isKindOfClass:[NSString class]]) {
return nil;
}
if (![businessID isEqualToString:BussinessID_GroupCreate] && ![param.allKeys containsObject:BussinessID_GroupCreate]) {
return nil;
}
NSString *localizableContent = param[@"content"];
NSNumber *cmd = param[@"cmd"];
if (cmd && [cmd isKindOfClass:NSNumber.class]) {
NSInteger command = [cmd integerValue];
if (command == 1) {
localizableContent = TIMCommonLocalizableString(TUICommunityCreateTipsMessage);
} else {
localizableContent = TIMCommonLocalizableString(TUIGroupCreateTipsMessage);
}
}
NSString * opUser = [self.class getOpUserName:msg]?:param[@"opUser"];
NSString *str = [NSString stringWithFormat:@"\"%@\" %@", opUser, localizableContent];
return rtlString(str);
}
@end

View File

@@ -0,0 +1,58 @@
// Created by Tencent on 2023/06/09.
// Copyright © 2023 Tencent. All rights reserved.
/**
* This document declares modules for implementing "more" units.
* - "More units", that is, several units that appear after clicking the "+" in the lower right corner of the chat interface.
* - At present, "More Units" provides four multimedia sending functions of shooting, video, picture and file, and you can also customize it.
* - TUIInputMoreCellData is responsible for storing the information needed for a series of "more" cells.
*/
#import <Foundation/Foundation.h>
@import UIKit;
NS_ASSUME_NONNULL_BEGIN
typedef void (^TUIInputMoreCallback)(NSDictionary *param);
/////////////////////////////////////////////////////////////////////////////////
//
// TUIInputMoreCellData
//
/////////////////////////////////////////////////////////////////////////////////
/**
* 【Module name】TUIInputMoreCellData
* 【Function description】"More units" data source
* - "More Units" is responsible for displaying in "More Views", showing the user the functionality contained in "More Views". At the same time, it serves as
* the entrance of each function and responds to user interaction events.
* - The data source is responsible for storing the information needed for a series of "more units".
*/
@interface TUIInputMoreCellData : NSObject
/**
* Image for single unit
* The icons of each unit are different, which are used to visually represent the function corresponding to the unit
*/
@property(nonatomic, strong) UIImage *image;
/**
* Name for single unit
* The names of each unit are different (such as Photo, Video, File, Album, etc.), which are used to display the corresponding functions of the unit in text
* form below the icon.
*/
@property(nonatomic, strong) NSString *title;
/**
* Callback for clicked
*/
@property(nonatomic, copy) TUIInputMoreCallback onClicked;
/**
* Prioriy for displaying in more menu list
* The larger the value, the higher the front in list
*/
@property(nonatomic, assign) NSInteger priority;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,9 @@
// Created by Tencent on 2023/06/09.
// Copyright © 2023 Tencent. All rights reserved.
#import "TUIInputMoreCellData.h"
@implementation TUIInputMoreCellData
@end

View File

@@ -0,0 +1,39 @@
// Created by Tencent on 2023/06/09.
// Copyright © 2023 Tencent. All rights reserved.
/******************************************************************************
*
* This file declares the TUIMemberCellData class.
* It provides a data source for the TUIMemberCell class, which is mainly used in the message read member list interface, etc.
*
******************************************************************************/
#import <TIMCommon/TIMCommonModel.h>
NS_ASSUME_NONNULL_BEGIN
@interface TUIMemberDescribeCellData : TUICommonCellData
@property(nonatomic, copy) NSString *title;
@property(nonatomic, copy) UIImage *icon;
@end
@interface TUIMemberCellData : TUICommonCellData
@property(nonatomic, copy) NSString *title; // member's display name
@property(nonatomic, copy) NSURL *avatarUrL; // member's avatar image url
@property(nonatomic, copy) NSString *detail; // optional, used to display more info
@property(nonatomic, copy) NSString *userID;
- (instancetype)initWithUserID:(nonnull NSString *)userID
nickName:(nullable NSString *)nickName
friendRemark:(nullable NSString *)friendRemark
nameCard:(nullable NSString *)nameCard
avatarUrl:(nonnull NSString *)avatarUrl
detail:(nullable NSString *)detail;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,47 @@
//
// TUIMemberCellData.m
// TUIChat
//
// Created by xia on 2022/3/14.
// Copyright © 2023 Tencent. All rights reserved.
//
#import "TUIMemberCellData.h"
@implementation TUIMemberDescribeCellData
@end
@implementation TUIMemberCellData
- (instancetype)initWithUserID:(nonnull NSString *)userID
nickName:(nullable NSString *)nickName
friendRemark:(nullable NSString *)friendRemark
nameCard:(nullable NSString *)nameCard
avatarUrl:(nonnull NSString *)avatarUrl
detail:(nullable NSString *)detail {
self = [super init];
if (userID.length > 0) {
_userID = userID;
}
if (avatarUrl.length > 0) {
_avatarUrL = [NSURL URLWithString:avatarUrl];
}
_detail = detail;
if (nameCard.length > 0) {
_title = nameCard;
} else if (friendRemark.length > 0) {
_title = friendRemark;
} else if (nickName.length > 0) {
_title = nickName;
} else {
_title = userID;
}
return self;
}
@end

View File

@@ -0,0 +1,67 @@
// Created by Tencent on 2023/06/09.
// Copyright © 2023 Tencent. All rights reserved.
/**
* This file declares the TUITextMessageCellData class.
* This class inherits from TUIBubbleMessageCellData and is used to store a series of data and information required by the text message unit.
*/
#import <TIMCommon/TUIBubbleMessageCellData.h>
#import <TIMCommon/TUIMessageCellData.h>
NS_ASSUME_NONNULL_BEGIN
/**
* 【Module name】 TUITextMessageCellData
* 【Function description】The datasource of text message unit.
* - Text message unit, which is the most common message unit in most message sending and receiving situations.
* - The text message unit data source provides a series of required data and information for the text message unit.
*/
@interface TUITextMessageCellData : TUIBubbleMessageCellData
/**
* Content of text message
*/
@property(nonatomic, strong) NSString *content;
@property(nonatomic, assign) BOOL isAudioCall;
@property(nonatomic, assign) BOOL isVideoCall;
@property(nonatomic, assign) BOOL isCaller;
@property(nonatomic, assign) BOOL showUnreadPoint;
/**
*
* Mutable strings.
* After the text message receives the content string, it is necessary to convert the string expression (such as [smile]) that may exist in the string into a
* picture expression. This string is responsible for storing the converted result of the above process.
*
*/
- (NSAttributedString *)getContentAttributedString:(UIFont *)textFont;
/**
*
* Get the display size of content string
*/
- (CGSize)getContentAttributedStringSize:(NSAttributedString *)attributeString maxTextSize:(CGSize)maxTextSize;
/**
* NSValue (NSRange) stores the converted string of emoji at the position of attributedString.
* NSAttributedString stores the string before emoji conversion, such as "[呲牙]".
* When the text is selected and copied, it is necessary to find the original string of emoji.
*/
@property(nonatomic, strong) NSMutableArray<NSDictionary<NSValue *, NSAttributedString *> *> *emojiLocations;
/**
* The size of the label which displays the text message content.
* Position the text message with the @textOrigin.
*/
@property(nonatomic, assign) CGSize textSize;
/**
* The origin of label which displays the text message content.
*/
@property(nonatomic, assign) CGPoint textOrigin;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,124 @@
//
// TUITextMessageCellData.m
// TXIMSDK_TUIKit_iOS
//
// Created by annidyfeng on 2019/5/21.
// Copyright © 2023 Tencent. All rights reserved.
//
#import "TUITextMessageCellData.h"
#import <TIMCommon/NSString+TUIEmoji.h>
#import <TIMCommon/TIMCommonModel.h>
#import <TIMCommon/TIMDefine.h>
#import <TUICore/TUIThemeManager.h>
#ifndef CGFLOAT_CEIL
#ifdef CGFLOAT_IS_DOUBLE
#define CGFLOAT_CEIL(value) ceil(value)
#else
#define CGFLOAT_CEIL(value) ceilf(value)
#endif
#endif
@interface TUITextMessageCellData ()
@property(nonatomic, assign) CGSize size;
@property(nonatomic, assign) CGFloat containerWidth;
@property(nonatomic, strong) NSMutableAttributedString *attributedString;
@end
@implementation TUITextMessageCellData
{
NSString *_content;
}
+ (TUIMessageCellData *)getCellData:(V2TIMMessage *)message {
TUITextMessageCellData *textData = [[TUITextMessageCellData alloc] initWithDirection:(message.isSelf ? MsgDirectionOutgoing : MsgDirectionIncoming)];
textData.content = message.textElem.text;
textData.reuseId = TTextMessageCell_ReuseId;
textData.status = Msg_Status_Init;
return textData;
}
+ (NSString *)getDisplayString:(V2TIMMessage *)message {
NSString *content = message.textElem.text;
return content.getLocalizableStringWithFaceContent;
}
- (Class)getReplyQuoteViewDataClass {
return NSClassFromString(@"TUITextReplyQuoteViewData");
}
- (Class)getReplyQuoteViewClass {
return NSClassFromString(@"TUITextReplyQuoteView");
}
- (instancetype)initWithDirection:(TMsgDirection)direction {
self = [super initWithDirection:direction];
if (self) {
if (direction == MsgDirectionIncoming) {
self.cellLayout = [TUIMessageCellLayout incommingTextMessageLayout];
} else {
self.cellLayout = [TUIMessageCellLayout outgoingTextMessageLayout];
}
}
return self;
}
- (void)setContent:(NSString *)content {
if (![_content isEqualToString:content]) {
_content = content;
_attributedString = nil;
}
}
- (NSString *)content {
return _content;
}
- (NSAttributedString *)getContentAttributedString:(UIFont *)textFont {
if (!_attributedString) {
_emojiLocations = [NSMutableArray array];
_attributedString = [self.content getFormatEmojiStringWithFont:textFont emojiLocations:_emojiLocations];
if (self.isAudioCall || self.isVideoCall) {
NSTextAttachment *attchment = [[NSTextAttachment alloc] init];
UIImage *image = nil;
if (self.isAudioCall) {
image = TUIChatCommonBundleImage(@"audio_call");
}
if (self.isVideoCall) {
if (self.isCaller) {
image = TUIChatCommonBundleImage(@"video_call_self");
} else {
image = TUIChatCommonBundleImage(@"video_call");
}
}
attchment.image = image;
attchment.bounds = CGRectMake(0, -(textFont.lineHeight - textFont.pointSize) / 2, 16, 16);
NSAttributedString *imageString = [NSAttributedString attributedStringWithAttachment:(NSTextAttachment *)(attchment)];
NSAttributedString *spaceString = [[NSAttributedString alloc] initWithString:@" " attributes:@{NSFontAttributeName : textFont}];
if (self.isCaller) {
[_attributedString appendAttributedString:spaceString];
[_attributedString appendAttributedString:imageString];
} else {
[_attributedString insertAttributedString:spaceString atIndex:0];
[_attributedString insertAttributedString:imageString atIndex:0];
}
}
}
return _attributedString;
}
- (CGSize)getContentAttributedStringSize:(NSAttributedString *)attributeString maxTextSize:(CGSize)maxTextSize {
CGRect rect = [attributeString boundingRectWithSize:maxTextSize
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
context:nil];
CGFloat width = CGFLOAT_CEIL(rect.size.width);
CGFloat height = CGFLOAT_CEIL(rect.size.height);
return CGSizeMake(width, height);
}
@end