123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- //
- // EMMsgExtSmartBubbleView.m
- // smartRhino
- //
- // Created by niuzhen on 2020/4/7.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "EMMsgExtSmartBubbleView.h"
- @implementation EMMsgExtSmartBubbleView
- - (instancetype)initWithDirection:(EMMessageDirection)aDirection
- type:(EMMessageType)aType
- {
- self = [super initWithDirection:aDirection type:aType];
- if (self) {
- [self _setupSubviews];
- }
-
- return self;
- }
- #pragma mark - Subviews
- - (void)_setupSubviews
- {
- [self setupAppBackgroundImage];
-
- self.iconView = [[UIImageView alloc] init];
- self.iconView.contentMode = UIViewContentModeScaleAspectFit;
- self.iconView.clipsToBounds = YES;
- [self addSubview:self.iconView];
-
- self.textLabel = [[UILabel alloc] init];
- self.textLabel.font = [UIFont systemFontOfSize:18];
- self.textLabel.numberOfLines = 1;
- self.textLabel.textColor = UIColorHex(0x0A0A0A);
- [self addSubview:self.textLabel];
-
- self.detailLabel = [[UILabel alloc] init];
- self.detailLabel.font = [UIFont systemFontOfSize:12];
- self.detailLabel.numberOfLines = 2;
- self.detailLabel.textColor = UIColorHex(0x999999);
- [self addSubview:self.detailLabel];
- [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.textLabel.mas_bottom).offset(5);
- make.bottom.equalTo(self).offset(-10);
- make.left.equalTo(self.textLabel);
- make.right.equalTo(self.textLabel);
- }];
- if (self.direction == EMMessageDirectionSend) {
- // self.iconView.image = [UIImage imageNamed:@"msg_file_white"];
- [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(10);
- make.left.equalTo(self).offset(10);
- make.centerY.equalTo(self);
- make.width.equalTo(@40);
- }];
- [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(10);
- make.left.equalTo(self.iconView.mas_right).offset(5);
- make.right.equalTo(self).offset(-15);
- }];
- } else {
- // self.iconView.image = [UIImage imageNamed:@"msg_file"];
- [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(10);
- make.left.equalTo(self).offset(13);
- make.centerY.equalTo(self);
- make.width.equalTo(@40);
- }];
- [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(10);
- make.left.equalTo(self.iconView.mas_right).offset(5);
- make.right.equalTo(self).offset(-10);
- }];
-
- }
- }
- #pragma mark - Setter
- - (void)setModel:(EMMessageModel *)model
- {
- NSDictionary * extDcit = model.emModel.ext;
- NSString * imageStr = [ZYCTool getFileNameImage:[extDcit objectForKey:@"app_title"]];
- self.textLabel.text = [extDcit objectForKey:@"app_title"];
- self.detailLabel.text = [extDcit objectForKey:@"app_content"];
- switch ([[extDcit objectForKey:@"app_type"] integerValue]) {
- case CollectModel_Aritle:
- {
- self.iconView.image = IMG(@"文章");
- }
- break;
- case CollectModel_Text:
- {
- self.iconView.image = IMG(@"文章");
- }
- break;
- case CollectModel_Notice:
- {
- self.iconView.image = IMG(@"通知图标");
- }
- break;
- case CollectModel_NoteBook:
- {
- self.iconView.image = IMG(@"noteBook_icon");
- }
- break;
- case CollectModel_NewTopic:
- {
- self.iconView.image = IMG(@"话题");
- }
- break;
- case CollectModel_Toipc:
- {
- self.iconView.image = IMG(@"话题");
- }
- break;
- case CollectModel_InterMail:
- {
- self.iconView.image = IMG(@"站内信");
- }
- break;
- case CollectModel_CollectFile:
- {
- self.iconView.image = IMG(@"find_1");
- }
- break;
- case CollectModel_NoteFile:
- {
- self.iconView.image = IMG(@"find_1");
- }
- break;
- case CollectModel_meetMian:
- {
- self.iconView.image = IMG(@"会议");
- }
- break;
- case CollectModel_Image:
- {
- [self.iconView setImageWithURL:[NSURL URLWithString:[extDcit objectForKey:@"app_min_url"]] placeholder:nil];
- }
- break;
- case CollectModel_file:
- {
- if(imageStr.length > 0){
- self.iconView.image = IMG(imageStr);
- }else{
- [self.iconView setImageWithURL:[NSURL URLWithString:[extDcit objectForKey:@"app_min_url"]] placeholder:nil];
- }
- }
- break;
- default:
- break;
- }
- }
- @end
|