Files
peko-ios/YuMi/Modules/YMMessage/View/Session/Content/MessageContentSkillCardView.m
2024-04-11 17:05:27 +08:00

93 lines
2.7 KiB
Objective-C

//
// MessageContentSkillCardView.m
// YUMI
//
// Created by YUMI on 2022/4/28.
//
#import "MessageContentSkillCardView.h"
///Third
#import <Masonry/Masonry.h>
#import "HttpRequestHelper.h"
#import "AttachMentModel.h"
#import "GuildMessageModel.h"
#import "MessageSkillCardModel.h"
#import "DJDKMIMOMColor.h"
#import "XNDJTDDLoadingTool.h"
#import "AccountInfoStorage.h"
#import "XPMineGuildViewController.h"
#import "XCCurrentVCStackManager.h"
#define MESSAGE_MAX_WIDTH 180
@interface MessageContentSkillCardView ()
///显示标题
@property (nonatomic,strong) UILabel *titleLabel;
///显示内容
@property (nonatomic,strong) YYLabel *contentLabel;
///消息的信息
@property (nonatomic,strong) GuildMessageModel *messageInfo;
@property (nonatomic,strong) NIMMessage *message;
@end
@implementation MessageContentSkillCardView
- (void)initSubViews {
[super initSubViews];
[self.backView addSubview:self.titleLabel];
[self.backView addSubview:self.contentLabel];
}
- (void)initSubViewConstraints {
[super initSubViewConstraints];
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(MESSAGE_MAX_WIDTH);
make.bottom.mas_equalTo(self.contentLabel.mas_bottom);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self.backView);
make.top.mas_equalTo(self.backView).offset(MESSAGE_PADDING);
}];
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.leading.mas_equalTo(self.backView);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(MESSAGE_PADDING);
make.height.mas_equalTo(15);
}];
}
- (void)render:(MessageBaseModel *)model {
self.message = model.message;
MessageSkillCardModel *obj = (MessageSkillCardModel *)model;
GuildMessageModel * info= obj.guildInfo;
self.messageInfo = info;
self.titleLabel.text = info.layout.title.content;
self.titleLabel.font = [UIFont systemFontOfSize:info.layout.title.fontSize weight:info.layout.title.fontBold?UIFontWeightBold:UIFontWeightRegular];
self.contentLabel.attributedText = obj.attribute;
self.contentLabel.textAlignment = NSTextAlignmentCenter;
[self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(obj.textHeight);
}];
}
#pragma mark - Getters And Setters
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textAlignment= NSTextAlignmentCenter;
_titleLabel.font = [UIFont systemFontOfSize:14];
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
}
return _titleLabel;
}
- (YYLabel *)contentLabel {
if (!_contentLabel) {
_contentLabel = [[YYLabel alloc] init];
_contentLabel.numberOfLines = 0;
}
return _contentLabel;
}
@end