MOEMNoticeBaseView.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // MOEMNoticeBaseView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/7/23.
  6. //
  7. #import "MOEMNoticeBaseView.h"
  8. #import <ImSDK_Plus/ImSDK_Plus.h>
  9. #import "TUIConversation/TUIConversationCell.h"
  10. @interface MOEMNoticeBaseView ()
  11. @property (weak, nonatomic) IBOutlet UIView *bgView;
  12. @property (weak, nonatomic) IBOutlet UIButton *iconBtn;
  13. @property (weak, nonatomic) IBOutlet UILabel *nameLab;
  14. @property (weak, nonatomic) IBOutlet UILabel *contentLab;
  15. @property (weak, nonatomic) IBOutlet UILabel *timeLab;
  16. @property (weak, nonatomic) IBOutlet UILabel *redNumLab;
  17. @end
  18. @implementation MOEMNoticeBaseView
  19. + (instancetype)moEMNoticeBaseView{
  20. return [[[NSBundle mainBundle] loadNibNamed:@"MOEMNoticeBaseView" owner:self options:nil] firstObject];
  21. }
  22. - (void)awakeFromNib{
  23. [super awakeFromNib];
  24. self.bgView.layer.cornerRadius = 16.0;
  25. self.bgView.layer.masksToBounds = YES;
  26. self.redNumLab.layer.cornerRadius = 7.0;
  27. self.redNumLab.layer.masksToBounds = YES;
  28. self.redNumLab.hidden = YES;
  29. self.nameLab.font = [MOTextTools mediumFont:16.0];
  30. self.contentLab.font = [MOTextTools regularFont:13.0];
  31. self.timeLab.font = [MOTextTools regularFont:13.0];
  32. self.redNumLab.font = [MOTextTools mediumFont:10.0];
  33. self.nameLab.textColor = kBaseTextColor_1;
  34. self.contentLab.textColor = kBaseTextColor_3;
  35. self.timeLab.textColor = kBaseTextColor_3;
  36. self.redNumLab.textColor = kBaseTextColor_6;
  37. }
  38. - (IBAction)viewClickBlock:(id)sender {
  39. self.btnClickBlock ? self.btnClickBlock() : nil;
  40. }
  41. - (void)setCellType:(MOEMNoticeBaseViewType)cellType{
  42. _cellType = cellType;
  43. if(cellType == MOEMNoticeBaseViewTypeActivity){
  44. self.iconBtn.selected = YES;
  45. self.nameLab.text = @"Activity Notice";
  46. }
  47. else{
  48. self.iconBtn.selected = NO;
  49. self.nameLab.text = @"Official News";
  50. }
  51. }
  52. - (void)setT_vellModel:(V2TIMConversation *)t_vellModel{
  53. _t_vellModel = t_vellModel;
  54. int redNum = t_vellModel.unreadCount;
  55. if(redNum <= 0){
  56. self.redNumLab.hidden = YES;
  57. }
  58. else{
  59. self.redNumLab.hidden = NO;
  60. if(redNum > 99){
  61. self.redNumLab.text = @"99+";
  62. }
  63. else{
  64. self.redNumLab.text = [NSString stringWithFormat:@"%d",redNum];
  65. }
  66. }
  67. if(t_vellModel.lastMessage.elemType == V2TIM_ELEM_TYPE_CUSTOM){
  68. V2TIMCustomElem *customElem = t_vellModel.lastMessage.customElem;
  69. NSDictionary *param = [NSJSONSerialization JSONObjectWithData:customElem.data options:NSJSONReadingAllowFragments error:nil];
  70. NSInteger type = [[MODataManager objectOrNilForKey:@"type" fromDictionary:param] integerValue];
  71. NSString *contentText = [MODataManager objectOrNilForKey:@"content" fromDictionary:param];
  72. if(contentText.length == 0){
  73. self.contentLab.text = @"";
  74. }
  75. else{
  76. self.contentLab.text = contentText;
  77. }
  78. }
  79. if(t_vellModel.lastMessage.timestamp == nil){
  80. self.timeLab.hidden = YES;
  81. }
  82. else{
  83. self.timeLab.hidden = NO;
  84. // self.timeLab.text = [EaseDateHelper formattedTime:t_vellModel.lastMessage.timestamp forDateFormatter:[EaseDateHelper shareHelper].dfYMD];
  85. self.timeLab.text = [TUIConversationCell convertDateTwoToStr:t_vellModel.lastMessage.timestamp];
  86. }
  87. }
  88. @end