99 lines
2.7 KiB
Objective-C
99 lines
2.7 KiB
Objective-C
//
|
|
// MessageContentGiftView.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/4/15.
|
|
//
|
|
|
|
#import "MessageContentGiftView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "NetImageView.h"
|
|
#import "DJDKMIMOMColor.h"
|
|
///Model
|
|
#import "GiftReceiveInfoModel.h"
|
|
#import "MessageGiftModel.h"
|
|
@interface MessageContentGiftView ()
|
|
///礼物的
|
|
@property (nonatomic,strong) NetImageView *giftImageView;
|
|
///显示名字
|
|
@property (nonatomic,strong) UILabel *giftNameLabel;
|
|
///描述
|
|
@property (nonatomic,strong) UILabel *giftNumLabel;
|
|
@end
|
|
|
|
@implementation MessageContentGiftView
|
|
|
|
- (void)initSubViews {
|
|
[super initSubViews];
|
|
[self addSubview:self.backView];
|
|
|
|
[self.backView addSubview:self.giftImageView];
|
|
[self.backView addSubview:self.giftNameLabel];
|
|
[self.backView addSubview:self.giftNumLabel];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[super initSubViewConstraints];
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(80);
|
|
make.width.mas_equalTo(185);
|
|
}];
|
|
|
|
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(60, 60));
|
|
make.leading.mas_equalTo(self.backView);
|
|
make.centerY.mas_equalTo(self.backView);
|
|
}];
|
|
|
|
[self.giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(self.giftImageView.mas_trailing).offset(10);
|
|
make.bottom.mas_equalTo(self.giftImageView.mas_centerY).offset(-3);
|
|
}];
|
|
|
|
[self.giftNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(self.giftNameLabel);
|
|
make.top.mas_equalTo(self.giftImageView.mas_centerY).offset(3);
|
|
}];
|
|
}
|
|
|
|
- (void)render:(MessageBaseModel *)model {
|
|
MessageGiftModel *obj = (MessageGiftModel *)model;
|
|
self.giftImageView.imageUrl = obj.giftInfo.giftUrl;
|
|
self.giftNameLabel.text = obj.giftInfo.giftName;
|
|
self.giftNumLabel.text = [NSString stringWithFormat:@"X%ld", obj.giftNum];
|
|
}
|
|
|
|
- (NetImageView *)giftImageView {
|
|
if (!_giftImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_giftImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_giftImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
_giftImageView.layer.masksToBounds = YES;
|
|
}
|
|
return _giftImageView;
|
|
}
|
|
|
|
- (UILabel *)giftNameLabel {
|
|
if (!_giftNameLabel) {
|
|
_giftNameLabel = [[UILabel alloc] init];
|
|
_giftNameLabel.font = [UIFont systemFontOfSize:15];
|
|
_giftNameLabel.textColor = [DJDKMIMOMColor mainTextColor];
|
|
}
|
|
return _giftNameLabel;
|
|
}
|
|
|
|
- (UILabel *)giftNumLabel {
|
|
if (!_giftNumLabel) {
|
|
_giftNumLabel = [[UILabel alloc] init];
|
|
_giftNumLabel.font = [UIFont systemFontOfSize:12];
|
|
_giftNumLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
|
}
|
|
return _giftNumLabel;
|
|
}
|
|
|
|
@end
|