126 lines
3.9 KiB
Objective-C
126 lines
3.9 KiB
Objective-C
//
|
|
// MessageContentMonentsView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/8/25.
|
|
//
|
|
|
|
#import "MessageContentMonentsView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "NetImageView.h"
|
|
#import "ThemeColor.h"
|
|
#import "XPGiftStorage.h"
|
|
#import "NSObject+MJExtension.h"
|
|
#import "XCCurrentVCStackManager.h"
|
|
///Model
|
|
#import "GiftReceiveInfoModel.h"
|
|
///View
|
|
#import "XPMonentsDetailViewController.h"
|
|
#import "MonentsInfoModel.h"
|
|
@interface MessageContentMonentsView ()
|
|
///礼物的
|
|
@property (nonatomic,strong) NetImageView *monentsView;
|
|
///显示名字
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
///描述
|
|
@property (nonatomic,strong) UILabel *contentLabel;
|
|
///动态
|
|
@property (nonatomic,strong) MonentsInfoModel *monents;
|
|
@end
|
|
|
|
@implementation MessageContentMonentsView
|
|
|
|
+ (CGFloat)measureHeight:(NIMMessage *)message {
|
|
return (CONTENT_PADDING_V_TOTAL + 60);
|
|
}
|
|
|
|
- (void)initSubViews {
|
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBackView)];
|
|
[self.backView addGestureRecognizer:tap];
|
|
[super initSubViews];
|
|
[self addSubview:self.backView];
|
|
|
|
[self.backView addSubview:self.monentsView];
|
|
[self.backView addSubview:self.titleLabel];
|
|
[self.backView addSubview:self.contentLabel];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[super initSubViewConstraints];
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(250, 60));
|
|
}];
|
|
|
|
[self.monentsView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(50, 50));
|
|
make.left.mas_equalTo(self.backView);
|
|
make.centerY.mas_equalTo(self.backView);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.monentsView.mas_right).offset(10);
|
|
make.bottom.mas_equalTo(self.monentsView.mas_centerY).offset(-3);
|
|
make.right.mas_lessThanOrEqualTo(self.backView).offset(-10);
|
|
}];
|
|
|
|
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.titleLabel);
|
|
make.top.mas_equalTo(self.monentsView.mas_centerY).offset(3);
|
|
make.right.mas_lessThanOrEqualTo(self.backView).offset(-10);
|
|
}];
|
|
}
|
|
|
|
- (void)tapBackView {
|
|
XPMonentsDetailViewController * detailView = [[XPMonentsDetailViewController alloc] init];
|
|
detailView.monentsInfo = self.monents;
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:detailView animated:YES];
|
|
}
|
|
|
|
- (void)render:(NIMMessage *)message {
|
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
|
AttachmentModel * attach = obj.attachment;
|
|
NSDictionary * dic = attach.data;
|
|
self.monents = [MonentsInfoModel modelWithDictionary:dic];
|
|
self.monentsView.imageUrl = dic[@"imageUrl"];
|
|
NSString * nick = self.monents.nick;
|
|
if (nick.length > 6) {
|
|
nick = [nick substringToIndex:6];
|
|
}
|
|
NSString * title = [NSString stringWithFormat:@"%@%@",nick, @"发布了一条动态"];
|
|
self.titleLabel.text = dic[@"title"] ? dic[@"title"] : title;
|
|
self.contentLabel.text = self.monents.content;
|
|
}
|
|
|
|
- (NetImageView *)monentsView {
|
|
if (!_monentsView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_monentsView = [[NetImageView alloc] initWithConfig:config];
|
|
_monentsView.contentMode = UIViewContentModeScaleAspectFill;
|
|
_monentsView.layer.masksToBounds = YES;
|
|
_monentsView.layer.cornerRadius = 10;
|
|
}
|
|
return _monentsView;
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.font = [UIFont systemFontOfSize:15];
|
|
_titleLabel.textColor = [ThemeColor mainTextColor];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UILabel *)contentLabel {
|
|
if (!_contentLabel) {
|
|
_contentLabel = [[UILabel alloc] init];
|
|
_contentLabel.font = [UIFont systemFontOfSize:12];
|
|
_contentLabel.textColor = [ThemeColor secondTextColor];
|
|
}
|
|
return _contentLabel;
|
|
}@end
|