// // HomeMsgHeaderView.m // tongxin // // Created by ecell on 2023/4/24. // Copyright © 2023 xTT. All rights reserved. // #import "HomeMsgHeaderView.h" @interface HomeMsgHeaderView () @property (nonatomic ,weak) UILabel *msgLabel; @property (nonatomic ,weak) UILabel *timeLabel; @end @implementation HomeMsgHeaderView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = KKClearColor; [self subHeaderView]; } return self; } - (void)setModelDic:(NSDictionary *)modelDic { _modelDic = modelDic; NSDictionary *dic = modelDic[@"lastData"]; if ([dic isKindOfClass:NSDictionary.class]) { //lowBattery rail sms sos photograph 提醒消息 //checkResults checkedResults 关注消息 //identityTransfer identityTransfered systemUpdate 系统消息 NSString *messageType = @"--"; NSString *type = dic[@"type"]; if([type isEqualToString:@"lowBattery"] || [type isEqualToString:@"rail"] || [type isEqualToString:@"sms"] || [type isEqualToString:@"sos"] || [type isEqualToString:@"photograph"]){ messageType = @"您有新的提醒消息"; } if([type isEqualToString:@"checkResults"] || [type isEqualToString:@"checkedResults"] || [type isEqualToString:@"applicationRrecord"] || [type isEqualToString:@"applicationOvertime"]){ messageType = @"您有新的关注消息"; } if([type isEqualToString:@"identityTransfer"] || [type isEqualToString:@"identityTransfered"] || [type isEqualToString:@"systemUpdate"]) messageType = @"您有新的系统消息"; self.msgLabel.text = messageType; NSTimeInterval timestamp = [dic[@"timestamp"] doubleValue]; self.timeLabel.text = [UICommon updateTimeForRow:[NSString stringWithFormat:@"%.0f",timestamp]]; } } - (void)subHeaderView { UIView *bgView = [[UIView alloc] init]; bgView.backgroundColor = KKWhiteColorColor; bgView.layer.cornerRadius = 10; bgView.layer.masksToBounds = YES; [self addSubview:bgView]; [bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self); make.top.equalTo(self.mas_top).offset(12); make.bottom.equalTo(self.mas_bottom).inset(12); }]; UIImageView *iconImg = [UICommon ui_imageView:CGRectZero fileName:@"comm_set_msg_icon"]; [bgView addSubview:iconImg]; [iconImg mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(bgView); make.left.equalTo(bgView).offset(15); make.size.mas_equalTo(iconImg.image.size); }]; UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBold_(16) textColor:KKTextBlackColor text:@"系统消息" Radius:0]; [bgView addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(iconImg.mas_right).offset(10); make.bottom.equalTo(iconImg.mas_centerY).inset(3); }]; UILabel *msgLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(13) textColor:KKGrey163 text:@"--" Radius:0]; self.msgLabel = msgLabel; [bgView addSubview:msgLabel]; [msgLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(titleLabel); make.top.equalTo(iconImg.mas_centerY).offset(3); }]; UILabel *timeLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(11) textColor:KKGrey163 text:@"" Radius:0]; self.timeLabel = timeLabel; [bgView addSubview:timeLabel]; [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(bgView.mas_right).inset(15); make.centerY.equalTo(titleLabel); }]; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ @end