EMMsgExtSmartBubbleView.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // EMMsgExtSmartBubbleView.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/4/7.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "EMMsgExtSmartBubbleView.h"
  9. @implementation EMMsgExtSmartBubbleView
  10. - (instancetype)initWithDirection:(EMMessageDirection)aDirection
  11. type:(EMMessageType)aType
  12. {
  13. self = [super initWithDirection:aDirection type:aType];
  14. if (self) {
  15. [self _setupSubviews];
  16. }
  17. return self;
  18. }
  19. #pragma mark - Subviews
  20. - (void)_setupSubviews
  21. {
  22. [self setupAppBackgroundImage];
  23. self.iconView = [[UIImageView alloc] init];
  24. self.iconView.contentMode = UIViewContentModeScaleAspectFit;
  25. self.iconView.clipsToBounds = YES;
  26. [self addSubview:self.iconView];
  27. self.textLabel = [[UILabel alloc] init];
  28. self.textLabel.font = [UIFont systemFontOfSize:18];
  29. self.textLabel.numberOfLines = 1;
  30. self.textLabel.textColor = UIColorHex(0x0A0A0A);
  31. [self addSubview:self.textLabel];
  32. self.detailLabel = [[UILabel alloc] init];
  33. self.detailLabel.font = [UIFont systemFontOfSize:12];
  34. self.detailLabel.numberOfLines = 2;
  35. self.detailLabel.textColor = UIColorHex(0x999999);
  36. [self addSubview:self.detailLabel];
  37. [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.top.equalTo(self.textLabel.mas_bottom).offset(5);
  39. make.bottom.equalTo(self).offset(-10);
  40. make.left.equalTo(self.textLabel);
  41. make.right.equalTo(self.textLabel);
  42. }];
  43. if (self.direction == EMMessageDirectionSend) {
  44. // self.iconView.image = [UIImage imageNamed:@"msg_file_white"];
  45. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.equalTo(self).offset(10);
  47. make.left.equalTo(self).offset(10);
  48. make.centerY.equalTo(self);
  49. make.width.equalTo(@40);
  50. }];
  51. [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.equalTo(self).offset(10);
  53. make.left.equalTo(self.iconView.mas_right).offset(5);
  54. make.right.equalTo(self).offset(-15);
  55. }];
  56. } else {
  57. // self.iconView.image = [UIImage imageNamed:@"msg_file"];
  58. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.equalTo(self).offset(10);
  60. make.left.equalTo(self).offset(13);
  61. make.centerY.equalTo(self);
  62. make.width.equalTo(@40);
  63. }];
  64. [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.equalTo(self).offset(10);
  66. make.left.equalTo(self.iconView.mas_right).offset(5);
  67. make.right.equalTo(self).offset(-10);
  68. }];
  69. }
  70. }
  71. #pragma mark - Setter
  72. - (void)setModel:(EMMessageModel *)model
  73. {
  74. NSDictionary * extDcit = model.emModel.ext;
  75. NSString * imageStr = [ZYCTool getFileNameImage:[extDcit objectForKey:@"app_title"]];
  76. self.textLabel.text = [extDcit objectForKey:@"app_title"];
  77. self.detailLabel.text = [extDcit objectForKey:@"app_content"];
  78. switch ([[extDcit objectForKey:@"app_type"] integerValue]) {
  79. case CollectModel_Aritle:
  80. {
  81. self.iconView.image = IMG(@"文章");
  82. }
  83. break;
  84. case CollectModel_Text:
  85. {
  86. self.iconView.image = IMG(@"文章");
  87. }
  88. break;
  89. case CollectModel_Notice:
  90. {
  91. self.iconView.image = IMG(@"通知图标");
  92. }
  93. break;
  94. case CollectModel_NoteBook:
  95. {
  96. self.iconView.image = IMG(@"noteBook_icon");
  97. }
  98. break;
  99. case CollectModel_NewTopic:
  100. {
  101. self.iconView.image = IMG(@"话题");
  102. }
  103. break;
  104. case CollectModel_Toipc:
  105. {
  106. self.iconView.image = IMG(@"话题");
  107. }
  108. break;
  109. case CollectModel_InterMail:
  110. {
  111. self.iconView.image = IMG(@"站内信");
  112. }
  113. break;
  114. case CollectModel_CollectFile:
  115. {
  116. self.iconView.image = IMG(@"find_1");
  117. }
  118. break;
  119. case CollectModel_NoteFile:
  120. {
  121. self.iconView.image = IMG(@"find_1");
  122. }
  123. break;
  124. case CollectModel_meetMian:
  125. {
  126. self.iconView.image = IMG(@"会议");
  127. }
  128. break;
  129. case CollectModel_Image:
  130. {
  131. [self.iconView setImageWithURL:[NSURL URLWithString:[extDcit objectForKey:@"app_min_url"]] placeholder:nil];
  132. }
  133. break;
  134. case CollectModel_file:
  135. {
  136. if(imageStr.length > 0){
  137. self.iconView.image = IMG(imageStr);
  138. }else{
  139. [self.iconView setImageWithURL:[NSURL URLWithString:[extDcit objectForKey:@"app_min_url"]] placeholder:nil];
  140. }
  141. }
  142. break;
  143. default:
  144. break;
  145. }
  146. }
  147. @end