| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- //
- // MOEMNoticeBaseView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/7/23.
- //
- #import "MOEMNoticeBaseView.h"
- #import <ImSDK_Plus/ImSDK_Plus.h>
- #import "TUIConversation/TUIConversationCell.h"
- @interface MOEMNoticeBaseView ()
- @property (weak, nonatomic) IBOutlet UIView *bgView;
- @property (weak, nonatomic) IBOutlet UIButton *iconBtn;
- @property (weak, nonatomic) IBOutlet UILabel *nameLab;
- @property (weak, nonatomic) IBOutlet UILabel *contentLab;
- @property (weak, nonatomic) IBOutlet UILabel *timeLab;
- @property (weak, nonatomic) IBOutlet UILabel *redNumLab;
- @end
- @implementation MOEMNoticeBaseView
- + (instancetype)moEMNoticeBaseView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MOEMNoticeBaseView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
-
- self.bgView.layer.cornerRadius = 16.0;
- self.bgView.layer.masksToBounds = YES;
-
- self.redNumLab.layer.cornerRadius = 7.0;
- self.redNumLab.layer.masksToBounds = YES;
- self.redNumLab.hidden = YES;
-
- self.nameLab.font = [MOTextTools mediumFont:16.0];
- self.contentLab.font = [MOTextTools regularFont:13.0];
- self.timeLab.font = [MOTextTools regularFont:13.0];
- self.redNumLab.font = [MOTextTools mediumFont:10.0];
-
- self.nameLab.textColor = kBaseTextColor_1;
- self.contentLab.textColor = kBaseTextColor_3;
- self.timeLab.textColor = kBaseTextColor_3;
- self.redNumLab.textColor = kBaseTextColor_6;
- }
- - (IBAction)viewClickBlock:(id)sender {
- self.btnClickBlock ? self.btnClickBlock() : nil;
- }
- - (void)setCellType:(MOEMNoticeBaseViewType)cellType{
- _cellType = cellType;
-
- if(cellType == MOEMNoticeBaseViewTypeActivity){
- self.iconBtn.selected = YES;
- self.nameLab.text = @"Activity Notice";
- }
- else{
- self.iconBtn.selected = NO;
- self.nameLab.text = @"Official News";
- }
- }
- - (void)setT_vellModel:(V2TIMConversation *)t_vellModel{
- _t_vellModel = t_vellModel;
-
- int redNum = t_vellModel.unreadCount;
- if(redNum <= 0){
- self.redNumLab.hidden = YES;
- }
- else{
- self.redNumLab.hidden = NO;
-
- if(redNum > 99){
- self.redNumLab.text = @"99+";
- }
- else{
- self.redNumLab.text = [NSString stringWithFormat:@"%d",redNum];
- }
- }
-
- if(t_vellModel.lastMessage.elemType == V2TIM_ELEM_TYPE_CUSTOM){
- V2TIMCustomElem *customElem = t_vellModel.lastMessage.customElem;
- NSDictionary *param = [NSJSONSerialization JSONObjectWithData:customElem.data options:NSJSONReadingAllowFragments error:nil];
-
- NSInteger type = [[MODataManager objectOrNilForKey:@"type" fromDictionary:param] integerValue];
-
- NSString *contentText = [MODataManager objectOrNilForKey:@"content" fromDictionary:param];
- if(contentText.length == 0){
- self.contentLab.text = @"";
- }
- else{
- self.contentLab.text = contentText;
- }
- }
-
- if(t_vellModel.lastMessage.timestamp == nil){
- self.timeLab.hidden = YES;
- }
- else{
- self.timeLab.hidden = NO;
- // self.timeLab.text = [EaseDateHelper formattedTime:t_vellModel.lastMessage.timestamp forDateFormatter:[EaseDateHelper shareHelper].dfYMD];
-
- self.timeLab.text = [TUIConversationCell convertDateTwoToStr:t_vellModel.lastMessage.timestamp];
- }
- }
- @end
|