// // 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