Files
peko-ios/YuMi/Modules/YMMessage/View/Session/Content/PIMessageContentServiceReplyView.m
2024-04-28 11:41:57 +08:00

180 lines
7.6 KiB
Objective-C

//
// PIMessageContentServiceReplyView.m
// YuMi
//
// Created by duoban on 2023/9/12.
//
#import "PIMessageContentServiceReplyView.h"
#import "PIMessageContentServiceReplyModel.h"
@interface PIMessageContentServiceReplyView()
@property(nonatomic,strong) UIImageView *bgImageView;
@property(nonatomic,strong) UILabel *titleView;
@property(nonatomic,strong) UILabel *contentView;
@property(nonatomic,strong) UILabel *contentView1;
@property(nonatomic,strong) YYLabel *contentView2;
@property(nonatomic,strong) YYLabel *contentView3;
@property(nonatomic,strong) UILabel *contentView4;
@end
@implementation PIMessageContentServiceReplyView
- (void)initSubViews {
[super initSubViews];
[self addSubview:self.backView];
[self.backView addSubview:self.bgImageView];
[self.bgImageView addSubview:self.titleView];
[self.bgImageView addSubview:self.contentView];
[self.bgImageView addSubview:self.contentView1];
[self.bgImageView addSubview:self.contentView2];
[self.bgImageView addSubview:self.contentView3];
[self.bgImageView addSubview:self.contentView4];
}
- (void)initSubViewConstraints {
[super initSubViewConstraints];
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(278);
make.height.mas_equalTo(236);
}];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.backView);
}];
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(16);
make.top.mas_equalTo(58);
make.height.mas_equalTo(20);
}];
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(16);
make.trailing.mas_equalTo(-14);
make.top.equalTo(self.titleView.mas_bottom).mas_offset(6);
}];
[self.contentView1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(16);
make.trailing.mas_equalTo(-14);
make.top.equalTo(self.contentView.mas_bottom).mas_offset(6);
}];
[self.contentView2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(16);
make.trailing.mas_equalTo(-14);
make.top.equalTo(self.contentView1.mas_bottom).mas_offset(4);
}];
[self.contentView3 mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(16);
make.trailing.mas_equalTo(-14);
make.top.equalTo(self.contentView2.mas_bottom).mas_offset(4);
}];
[self.contentView4 mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(16);
make.trailing.mas_equalTo(-14);
make.top.equalTo(self.contentView3.mas_bottom).mas_offset(6);
}];
}
- (void)render:(MessageBaseModel *)model {
NIMMessage *message = model.message;
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
AttachmentModel * attach = (AttachmentModel *)obj.attachment;
NSString *official0 = attach.data[@"official0"];
NSString *official1 = attach.data[@"official1"];
NSString *chatText = [NSString stringWithFormat:YMLocalizedString(@"PIMessageContentServiceReplyView4"),official0];
NSString *lineText = [NSString stringWithFormat:YMLocalizedString(@"PIMessageContentServiceReplyView5"),official1];
NSMutableAttributedString *chatAtt = [[NSMutableAttributedString alloc] initWithString:chatText];
chatAtt.yy_color = UIColorFromRGB(0x767585);
NSMutableAttributedString *lineAtt = [[NSMutableAttributedString alloc] initWithString:lineText];
lineAtt.yy_color = UIColorFromRGB(0x767585);
_contentView.numberOfLines = 0;
NSString *userString = YMLocalizedString(@"PIMessageContentServiceReplyView1");
NSMutableAttributedString *userAttString = [[NSMutableAttributedString alloc] initWithString:userString attributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x9168FA)}];
[userAttString yy_setTextHighlightRange:NSMakeRange(0, userAttString.length) color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPMineHeadView8")];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = official0;
} longPressAction:nil];
[chatAtt insertAttributedString:userAttString atIndex:chatText.length];
_contentView2.attributedText = chatAtt;
NSString *protocolString = YMLocalizedString(@"PIMessageContentServiceReplyView1");
NSMutableAttributedString *privateString = [[NSMutableAttributedString alloc] initWithString:protocolString attributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x9168FA)}];
[privateString yy_setTextHighlightRange:NSMakeRange(0, privateString.length) color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPMineHeadView8")];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = official1;
} longPressAction:nil];
[lineAtt insertAttributedString:privateString atIndex:lineText.length];
_contentView3.attributedText = lineAtt;
self.superview.backgroundColor = [UIColor clearColor];
}
- (UIImageView *)bgImageView{
if(!_bgImageView){
_bgImageView = [UIImageView new];
_bgImageView.image = kImage(@"message_content_service_reply");
_bgImageView.userInteractionEnabled = YES;
}
return _bgImageView;
}
- (UILabel *)titleView{
if(!_titleView){
_titleView = [UILabel labelInitWithText:YMLocalizedString(@"PIMessageContentServiceReplyView0") font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x1F1B4F)];
}
return _titleView;
}
- (UILabel *)contentView{
if(!_contentView){
_contentView = [[UILabel alloc] init];
_contentView.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_contentView.textColor = UIColorFromRGB(0x767585);
_contentView.text = YMLocalizedString(@"PIMessageContentServiceReplyView2");
_contentView.numberOfLines = 2;
}
return _contentView;
}
- (UILabel *)contentView1{
if(!_contentView1){
_contentView1 = [[UILabel alloc] init];
_contentView1.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_contentView1.textColor = UIColorFromRGB(0x767585);
_contentView1.text = YMLocalizedString(@"PIMessageContentServiceReplyView3");
_contentView1.numberOfLines = 2;
}
return _contentView1;
}
- (YYLabel *)contentView2{
if(!_contentView2){
_contentView2 = [[YYLabel alloc] init];
_contentView2.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_contentView2.textColor = UIColorFromRGB(0x767585);
}
return _contentView2;
}
- (YYLabel *)contentView3{
if(!_contentView3){
_contentView3 = [[YYLabel alloc] init];
_contentView3.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_contentView3.textColor = UIColorFromRGB(0x767585);
}
return _contentView3;
}
- (UILabel *)contentView4{
if(!_contentView4){
_contentView4 = [[UILabel alloc] init];
_contentView4.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_contentView4.textColor = UIColorFromRGB(0x767585);
_contentView4.text = YMLocalizedString(@"PIMessageContentServiceReplyView6");
_contentView4.numberOfLines = 3;
}
return _contentView4;
}
@end