MessageListCell.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // MessageListCell.m
  3. // YBVideo
  4. //
  5. // Created by YunBao on 2018/7/13.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "MessageListCell.h"
  9. #import "MessageListModel.h"
  10. #import "JCHATSendMsgManager.h"
  11. @interface MessageListCell()
  12. @end
  13. @implementation MessageListCell
  14. - (void)awakeFromNib {
  15. [super awakeFromNib];
  16. // Initialization code
  17. _siliaoL.text = YZMsg(@"私聊");
  18. _iconTag.image = [UIImage imageNamed:getImagename(@"msg_gov")];
  19. }
  20. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  21. [super setSelected:selected animated:animated];
  22. // Configure the view for the selected state
  23. }
  24. - (IBAction)clickIconBtn:(UIButton *)sender {
  25. if (self.iconEvent) {
  26. self.iconEvent(@"头像");
  27. }
  28. }
  29. +(MessageListCell*)cellWithTab:(UITableView *)tableView andIndexPath:(NSIndexPath*)indexPath {
  30. MessageListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MessageListCell"];
  31. if (!cell) {
  32. cell = [[[NSBundle mainBundle]loadNibNamed:@"MessageListCell" owner:nil options:nil]objectAtIndex:0];
  33. cell.backgroundColor = CellRow_Cor;
  34. }
  35. return cell;
  36. }
  37. - (void)setIsWhiteStyle:(BOOL)isWhiteStyle {
  38. _isWhiteStyle = isWhiteStyle;
  39. if (_isWhiteStyle) {
  40. self.backgroundColor = UIColor.whiteColor;
  41. self.contentView.backgroundColor = UIColor.whiteColor;
  42. self.lineL.backgroundColor = RGB_COLOR(@"#f4f5f6", 1);
  43. self.nameL.textColor = RGB_COLOR(@"#000000", 1);
  44. }
  45. }
  46. -(void)setModel:(MessageListModel *)model {
  47. _model = model;
  48. [_iconIV sd_setImageWithURL:[NSURL URLWithString:_model.iconStr]];
  49. //官方标识
  50. if ([_model.uidStr isEqual:@"dsp_admin_1"] || [_model.uidStr isEqual:@"dsp_admin_2"]) {
  51. _iconTag.hidden = NO;
  52. }else{
  53. _iconTag.hidden = YES;
  54. }
  55. _nameL.text = _model.unameStr;
  56. //NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  57. //NSString *app_name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
  58. //改为服务端获取
  59. if ([[[JCHATSendMsgManager ins] draftStringWithConversation:_model.conversation] isEqualToString:@""]) {
  60. _detailL.text = model.contentStr;
  61. } else {
  62. NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"[%@] %@",YZMsg(@"草稿"),[[JCHATSendMsgManager ins] draftStringWithConversation:_model.conversation]]];
  63. [attriString addAttribute:NSForegroundColorAttributeName
  64. value:[UIColor redColor]
  65. range:NSMakeRange(0, 4)];
  66. _detailL.attributedText = attriString;
  67. }
  68. _timeL.text = _model.timeStr;
  69. int num = [_model.unReadStr intValue];
  70. if (num > 0) {
  71. _redPoint.hidden = NO;
  72. _redPoint.text = [NSString stringWithFormat:@"%d",num];
  73. }else{
  74. _redPoint.hidden = YES;
  75. }
  76. //个位数显示圆点,两位及以上显示椭圆
  77. if (num < 10) {
  78. _redPointWidth.constant = _redPoint.frame.size.height;
  79. }else{
  80. _redPointWidth.constant = _redPoint.frame.size.width + 10;
  81. }
  82. }
  83. @end