|
|
// |
|
|
// CommMessageTableViewCell.m |
|
|
// LekangGuard |
|
|
// |
|
|
// Created by ecell on 2023/6/7. |
|
|
// |
|
|
|
|
|
#import "CommMessageTableViewCell.h" |
|
|
|
|
|
@interface CommMessageTableViewCell () |
|
|
|
|
|
@property (nonatomic ,weak) UILabel *titleLabel; |
|
|
|
|
|
@property (nonatomic ,weak) UILabel *nbLabel; |
|
|
|
|
|
@property (nonatomic ,weak) UILabel *statusLabel; |
|
|
|
|
|
@property (nonatomic ,weak) UILabel *textsLabel; |
|
|
|
|
|
@property (nonatomic ,weak) UILabel *commLabel; |
|
|
|
|
|
@property (nonatomic ,weak) UILabel *timeLabel; |
|
|
|
|
|
@end |
|
|
|
|
|
@implementation CommMessageTableViewCell |
|
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier |
|
|
{ |
|
|
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; |
|
|
if (self) |
|
|
{ |
|
|
self.selectionStyle = UITableViewCellSelectionStyleNone; |
|
|
self.backgroundColor = KKClearColor; |
|
|
[self subCellView]; |
|
|
} |
|
|
|
|
|
return self; |
|
|
} |
|
|
|
|
|
- (void)setRedModel:(RedFlowerModel *)redModel |
|
|
{ |
|
|
_redModel = redModel; |
|
|
self.titleLabel.text = @"小红花奖励"; |
|
|
self.textsLabel.text = F(@"%@因%@获得%ld朵小红花以兹鼓励.", redModel.rewardName,redModel.pushContent,redModel.flowerNumber); |
|
|
self.commLabel.text = redModel.pushName; |
|
|
self.timeLabel.text = redModel.createTime; |
|
|
self.statusLabel.hidden = redModel.receiveStatus == 0 ? NO : YES; |
|
|
} |
|
|
|
|
|
- (void)setSchModel:(SchModel *)schModel |
|
|
{ |
|
|
_schModel = schModel; |
|
|
self.titleLabel.text = schModel.noticeSubject; |
|
|
self.textsLabel.text = schModel.noticeMassage; |
|
|
self.commLabel.text = schModel.noticeCreateOrgName; |
|
|
self.timeLabel.text = schModel.sendTime; |
|
|
self.statusLabel.hidden = schModel.sendReadStatus == 2 ? NO : YES; |
|
|
} |
|
|
|
|
|
- (void)setJobModel:(JobModel *)jobModel |
|
|
{ |
|
|
_jobModel = jobModel; |
|
|
self.titleLabel.attributedText = [self labelFontSizeColor:F(@"%@ %@",jobModel.courseName,jobModel.title) toText:jobModel.courseName]; |
|
|
self.titleLabel.textAlignment = NSTextAlignmentLeft; |
|
|
self.textsLabel.text = jobModel.descriptions; |
|
|
|
|
|
self.commLabel.attributedText = [self labelFontSize:F(@"%@/%@\n%@",jobModel.gradeName,jobModel.className,jobModel.teacherName)]; |
|
|
self.timeLabel.text = jobModel.docPushTime; |
|
|
self.statusLabel.hidden = jobModel.receiveStatus == 2 ? NO : YES; |
|
|
} |
|
|
|
|
|
- (void)subCellView |
|
|
{ |
|
|
UIView *bgView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKWhiteColorColor]; |
|
|
[self.contentView addSubview:bgView]; |
|
|
[bgView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
make.left.right.equalTo(self.contentView).inset(15); |
|
|
make.top.equalTo(self.contentView).offset(15); |
|
|
make.bottom.equalTo(self.contentView.mas_bottom); |
|
|
}]; |
|
|
|
|
|
/// 阅读状态 |
|
|
UILabel *statusLabel = [UICommon ui_label:CGRectZero lines:1 align:NSTextAlignmentCenter font:Font_(12) textColor:UIColor.redColor text:@"未阅" Radius:0]; |
|
|
statusLabel.hidden = YES; |
|
|
self.statusLabel = statusLabel; |
|
|
[bgView addSubview:statusLabel]; |
|
|
[statusLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
make.right.equalTo(bgView.mas_right).inset(15); |
|
|
make.top.equalTo(bgView.mas_top).offset(10); |
|
|
}]; |
|
|
|
|
|
|
|
|
/// 标题 |
|
|
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:1 align:NSTextAlignmentCenter font:FontBold_(18) textColor:KKMainColor text:@"" Radius:0]; |
|
|
self.titleLabel = titleLabel; |
|
|
[bgView addSubview:titleLabel]; |
|
|
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
make.left.equalTo(bgView).offset(15); |
|
|
make.right.equalTo(bgView.mas_right).inset(40); |
|
|
make.top.equalTo(bgView.mas_top).offset(15); |
|
|
}]; |
|
|
|
|
|
|
|
|
/// 内容 |
|
|
UILabel *textsLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(14) textColor:KKGrey121 text:@"" Radius:0]; |
|
|
self.textsLabel = textsLabel; |
|
|
[bgView addSubview:textsLabel]; |
|
|
[textsLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
make.left.equalTo(bgView).offset(15); |
|
|
make.right.equalTo(bgView.mas_right).inset(15); |
|
|
make.top.equalTo(titleLabel.mas_bottom).offset(15); |
|
|
}]; |
|
|
|
|
|
/// 发送人 |
|
|
UILabel *commLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentRight font:Font_(13) textColor:KKTextBlackColor text:@"" Radius:0]; |
|
|
self.commLabel = commLabel; |
|
|
[bgView addSubview:commLabel]; |
|
|
[commLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
make.right.equalTo(bgView.mas_right).inset(15); |
|
|
make.top.equalTo(textsLabel.mas_bottom).offset(20); |
|
|
}]; |
|
|
|
|
|
|
|
|
/// 时间 |
|
|
UILabel *timeLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(13) textColor:KKGrey121 text:@"" Radius:0]; |
|
|
self.timeLabel = timeLabel; |
|
|
[bgView addSubview:timeLabel]; |
|
|
[timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
|
make.right.equalTo(bgView.mas_right).inset(15); |
|
|
make.top.equalTo(commLabel.mas_bottom).offset(8); |
|
|
make.bottom.equalTo(bgView.mas_bottom).inset(15); |
|
|
}]; |
|
|
} |
|
|
|
|
|
- (NSAttributedString *)labelFontSize:(NSString *)text |
|
|
{ |
|
|
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:text]; |
|
|
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; |
|
|
paragraphStyle.lineSpacing = 10; |
|
|
paragraphStyle.alignment = NSTextAlignmentRight; |
|
|
[string addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)]; |
|
|
|
|
|
return string; |
|
|
} |
|
|
|
|
|
/// 指定字符大小 |
|
|
/// @param text 内容 |
|
|
- (NSAttributedString *)labelFontSizeColor:(NSString *)text toText:(NSString *)totext |
|
|
{ |
|
|
NSRange symbolRange = [text rangeOfString:totext]; |
|
|
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:text]; |
|
|
if (symbolRange.location != NSNotFound) { |
|
|
[string addAttribute:NSForegroundColorAttributeName value:KKTextBlackColor range:NSMakeRange(symbolRange.location, symbolRange.length)]; |
|
|
} |
|
|
return string; |
|
|
} |
|
|
|
|
|
- (void)awakeFromNib { |
|
|
[super awakeFromNib]; |
|
|
// Initialization code |
|
|
} |
|
|
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { |
|
|
[super setSelected:selected animated:animated]; |
|
|
|
|
|
// Configure the view for the selected state |
|
|
} |
|
|
|
|
|
@end
|
|
|
|