This commit is contained in:
启星
2025-08-08 10:49:36 +08:00
parent 6400cf78bb
commit b5ce3d580a
8780 changed files with 978183 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
//
// TUIEvaluationCell.h
// TUIChat
//
// Created by xia on 2022/6/10.
// Copyright © 2023 Tencent. All rights reserved.
//
#import <TIMCommon/TUIBubbleMessageCell.h>
#import "TUIEvaluationCellData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TUIEvaluationCell : TUIBubbleMessageCell
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UILabel *commentLabel;
@property(nonatomic, strong) NSMutableArray *starImageArray;
- (void)fillWithData:(TUIEvaluationCellData *)data;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,141 @@
//
// TUIEvaluationCell.m
// TUIChat
//
// Created by xia on 2022/6/10.
// Copyright © 2023 Tencent. All rights reserved.
//
#import "TUIEvaluationCell.h"
#import <TUICore/TUIGlobalization.h>
#import <TUICore/TUIThemeManager.h>
@implementation TUIEvaluationCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:15];
_titleLabel.numberOfLines = 1;
_titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_titleLabel.textColor = TUIChatDynamicColor(@"chat_text_message_receive_text_color", @"#000000");
[self.container addSubview:_titleLabel];
for (int i = 0; i < 5; i++) {
UIImageView *imageView = [[UIImageView alloc] init];
[imageView setImage:TUIChatBundleThemeImage(@"chat_custom_evaluation_message_img", @"message_custom_evaluation")];
[self.container addSubview:imageView];
[self.starImageArray addObject:imageView];
}
_commentLabel = [[UILabel alloc] init];
_commentLabel.font = [UIFont systemFontOfSize:15];
_commentLabel.numberOfLines = 0;
_commentLabel.textColor = TUIChatDynamicColor(@"chat_custom_evaluation_message_desc_color", @"#000000");
[self.container addSubview:_commentLabel];
}
return self;
}
- (void)fillWithData:(TUIEvaluationCellData *)data {
[super fillWithData:data];
self.titleLabel.text = data.desc;
self.commentLabel.text = data.comment;
// Configure all StarViews to avoid UI cache clutter
for (int i = 0; i < self.starImageArray.count; i++) {
UIImageView *starView = [self.starImageArray objectAtIndex:i];
starView.hidden = (i >= data.score);
}
// tell constraints they need updating
[self setNeedsUpdateConstraints];
// update constraints now so we can animate the change
[self updateConstraintsIfNeeded];
[self layoutIfNeeded];
}
+ (BOOL)requiresConstraintBasedLayout {
return YES;
}
// this is Apple's recommended place for adding/updating constraints
- (void)updateConstraints {
[super updateConstraints];
[self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(10);
make.leading.mas_equalTo(10);
make.width.mas_equalTo(225);
make.height.mas_equalTo(18);
}];
UIImageView *leftView = nil;
for (UIImageView *starView in self.starImageArray) {
if (leftView == nil) {
[starView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(10);
make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(6);
make.width.mas_equalTo(30);
make.height.mas_equalTo(30);
}];
} else {
[starView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(leftView.mas_trailing);
make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(6);
make.width.mas_equalTo(30);
make.height.mas_equalTo(30);
}];
}
leftView = starView;
}
UIImageView *starView = self.starImageArray.firstObject;
self.commentLabel.hidden = self.commentLabel.text.length == 0;
if (self.commentLabel.text.length > 0) {
CGRect rect = [self.commentLabel.text boundingRectWithSize:CGSizeMake(225, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]}
context:nil];
CGSize size = CGSizeMake(225, ceilf(rect.size.height));
[self.commentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(starView.mas_bottom).mas_offset(6);
make.leading.mas_equalTo(10);
make.width.mas_equalTo(size.width);
make.height.mas_equalTo(size.height);
}];
}
}
- (void)layoutSubviews {
[super layoutSubviews];
}
- (NSMutableArray *)starImageArray {
if (!_starImageArray) {
_starImageArray = [[NSMutableArray alloc] init];
}
return _starImageArray;
}
#pragma mark - TUIMessageCellProtocol
+ (CGSize)getContentSize:(TUIMessageCellData *)data {
NSAssert([data isKindOfClass:TUIEvaluationCellData.class], @"data must be kind of TUIEvaluationCellData");
TUIEvaluationCellData *evaluationCellData = (TUIEvaluationCellData *)data;
CGRect rect = [evaluationCellData.comment boundingRectWithSize:CGSizeMake(215, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]}
context:nil];
CGSize size = CGSizeMake(245, ceilf(rect.size.height));
size.height += evaluationCellData.comment.length > 0 ? 88 : 50;
return size;
}
@end

View File

@@ -0,0 +1,23 @@
//
// MyCustomCell.h
// TUIKitDemo
//
// Created by annidyfeng on 2019/6/10.
// Copyright © 2019 Tencent. All rights reserved.
//
#import <TIMCommon/TUIBubbleMessageCell.h>
#import <TIMCommon/TUIMessageCell.h>
#import "TUILinkCellData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TUILinkCell : TUIBubbleMessageCell
@property UILabel *myTextLabel;
@property UILabel *myLinkLabel;
@property TUILinkCellData *customData;
- (void)fillWithData:(TUILinkCellData *)data;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,95 @@
//
// MyCustomCell.m
// TUIKitDemo
//
// Created by annidyfeng on 2019/6/10.
// Copyright © 2019 Tencent. All rights reserved.
//
#import "TUILinkCell.h"
#import <TUICore/TUIGlobalization.h>
#import <TUICore/TUIThemeManager.h>
@implementation TUILinkCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
_myTextLabel = [[UILabel alloc] init];
_myTextLabel.numberOfLines = 0;
_myTextLabel.font = [UIFont systemFontOfSize:15];
_myTextLabel.textAlignment = isRTL()?NSTextAlignmentRight:NSTextAlignmentLeft;
_myTextLabel.textColor = TUIChatDynamicColor(@"chat_link_message_title_color", @"#000000");
[self.container addSubview:_myTextLabel];
_myLinkLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_myLinkLabel.text = TIMCommonLocalizableString(TUIKitMoreLinkDetails);
_myLinkLabel.font = [UIFont systemFontOfSize:15];
_myLinkLabel.textAlignment = isRTL()?NSTextAlignmentRight:NSTextAlignmentLeft;
_myLinkLabel.textColor = TUIChatDynamicColor(@"chat_link_message_subtitle_color", @"#0000FF");
[self.container addSubview:_myLinkLabel];
}
return self;
}
- (void)fillWithData:(TUILinkCellData *)data;
{
[super fillWithData:data];
self.customData = data;
self.myTextLabel.text = data.text;
// tell constraints they need updating
[self setNeedsUpdateConstraints];
// update constraints now so we can animate the change
[self updateConstraintsIfNeeded];
[self layoutIfNeeded];
}
+ (BOOL)requiresConstraintBasedLayout {
return YES;
}
// this is Apple's recommended place for adding/updating constraints
- (void)updateConstraints {
[super updateConstraints];
CGRect rect = [self.myTextLabel.text boundingRectWithSize:CGSizeMake(245, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]}
context:nil];
[self.myTextLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(10);
make.leading.mas_equalTo(10);
make.width.mas_equalTo(245);
make.height.mas_equalTo(rect.size.height);
}];
[self.myLinkLabel sizeToFit];
[self.myLinkLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.myTextLabel.mas_bottom).mas_offset(15);
make.leading.mas_equalTo(10);
make.width.mas_equalTo(self.myLinkLabel.frame.size.width);
make.height.mas_equalTo(self.myLinkLabel.frame.size.height);
}];
}
- (void)layoutSubviews {
[super layoutSubviews];
}
#pragma mark - TUIMessageCellProtocol
+ (CGSize)getContentSize:(TUIMessageCellData *)data {
NSAssert([data isKindOfClass:TUILinkCellData.class], @"data must be kind of TUILinkCellData");
TUILinkCellData *linkCellData = (TUILinkCellData *)data;
CGFloat textMaxWidth = 245.f;
CGRect rect = [linkCellData.text boundingRectWithSize:CGSizeMake(textMaxWidth, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]}
context:nil];
CGSize size = CGSizeMake(textMaxWidth + 15, rect.size.height + 56);
return size;
}
@end

View File

@@ -0,0 +1,26 @@
//
// TUIOrderCell.h
// TUIChat
//
// Created by xia on 2022/6/13.
// Copyright © 2023 Tencent. All rights reserved.
//
#import <TIMCommon/TUIBubbleMessageCell.h>
#import "TUIOrderCellData.h"
NS_ASSUME_NONNULL_BEGIN
@interface TUIOrderCell : TUIBubbleMessageCell
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UILabel *descLabel;
@property(nonatomic, strong) UIImageView *iconView;
@property(nonatomic, strong) UILabel *priceLabel;
@property(nonatomic, strong) TUIOrderCellData *customData;
- (void)fillWithData:(TUIOrderCellData *)data;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,112 @@
//
// TUIOrderCell.m
// TUIChat
//
// Created by xia on 2022/6/13.
// Copyright © 2023 Tencent. All rights reserved.
//
#import "TUIOrderCell.h"
#import <TUICore/TUIGlobalization.h>
#import <TUICore/TUIThemeManager.h>
@implementation TUIOrderCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont boldSystemFontOfSize:12];
_titleLabel.textColor = TUIChatDynamicColor(@"chat_text_message_receive_text_color", @"#000000");
_titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[self.container addSubview:_titleLabel];
_descLabel = [[UILabel alloc] init];
_descLabel.font = [UIFont systemFontOfSize:12];
_descLabel.numberOfLines = 1;
_descLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_descLabel.textColor = TUIChatDynamicColor(@"chat_custom_order_message_desc_color", @"#999999");
[self.container addSubview:_descLabel];
_priceLabel = [[UILabel alloc] init];
_priceLabel.font = [UIFont boldSystemFontOfSize:18];
_priceLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_priceLabel.textColor = TUIChatDynamicColor(@"chat_custom_order_message_price_color", @"#FF7201");
[self.container addSubview:_priceLabel];
_iconView = [[UIImageView alloc] init];
_iconView.layer.cornerRadius = 8.0;
_iconView.layer.masksToBounds = YES;
[self.container addSubview:_iconView];
}
return self;
}
- (void)fillWithData:(TUIOrderCellData *)data {
[super fillWithData:data];
self.customData = data;
self.titleLabel.text = data.title;
self.descLabel.text = data.desc;
self.priceLabel.text = data.price;
if (data.imageUrl == nil) {
[self.iconView setImage:TUIChatBundleThemeImage(@"chat_custom_order_message_img", @"message_custom_order")];
} else {
[self.iconView setImage:[UIImage sd_imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:data.imageUrl]]]];
}
// tell constraints they need updating
[self setNeedsUpdateConstraints];
// update constraints now so we can animate the change
[self updateConstraintsIfNeeded];
[self layoutIfNeeded];
}
+ (BOOL)requiresConstraintBasedLayout {
return YES;
}
// this is Apple's recommended place for adding/updating constraints
- (void)updateConstraints {
[super updateConstraints];
[self.iconView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(10);
make.leading.mas_equalTo(12);
make.width.mas_equalTo(60);
make.height.mas_equalTo(60);
}];
[self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(10);
make.leading.mas_equalTo(80);
make.width.mas_equalTo(150);
make.height.mas_equalTo(17);
}];
[self.descLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(30);
make.leading.mas_equalTo(80);
make.width.mas_equalTo(150);
make.height.mas_equalTo(17);
}];
[self.priceLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(49);
make.leading.mas_equalTo(80);
make.width.mas_equalTo(150);
make.height.mas_equalTo(25);
}];
}
- (void)layoutSubviews {
[super layoutSubviews];
}
#pragma mark - TUIMessageCellProtocol
+ (CGSize)getContentSize:(TUIMessageCellData *)data {
CGSize size = CGSizeMake(245, 80);
return size;
}
@end