123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- //
- // ChatMsgSearchReseltContentCell.m
- // smartRhino
- //
- // Created by armin on 2019/11/4.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "ChatMsgSearchReseltContentCell.h"
- @implementation ChatMsgSearchReseltContentCell
- - (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
- }
- + (CGFloat)configCell0Height{
- return 64;
- }
- + (ChatMsgSearchReseltContentCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"ChatMsgSearchReseltContentCell0";
- ChatMsgSearchReseltContentCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatMsgSearchReseltContentCell" owner:nil options:nil] objectAtIndex:0];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- [cell.cell0ShowImgView setRadius:4 corners:UIRectCornerAllCorners];
- cell.cell0IntroLabel.textColor = RGB(153, 153, 153);
- return cell;
- }
- - (void)bindData:(ChatMsgSearchModelSub *)model WithKeyStr:(nonnull NSString *)keyStr {
-
-
- // 0:全部 1 通知 2 通讯录 3 单聊 4群聊 5 文章 6 站内信 7话题 (后台定义)
-
- // 全部
- // 消息(单聊 群聊)
- // 话题
- // 小组 ??
- // 通知
- // 站内信
- // 通讯录
-
-
-
-
- model.SearchType = 3;
-
-
- // 通讯录样式
- if (model.SearchType == 6 || model.SearchType == 3) {
- [self.type7NameLabel setHidden:NO];
- [self.cell0TitleLabel setHidden:YES];
- [self.cell0IntroLabel setHidden:YES];
- } else {
- [self.type7NameLabel setHidden:YES];
- [self.cell0TitleLabel setHidden:NO];
- [self.cell0IntroLabel setHidden:NO];
- }
-
-
- // 消息样式
- if (model.SearchType == 1) {
- self.cell0IntroLabel.textColor = kColorFromRGB(0x3979D3);
- } else {
- self.cell0IntroLabel.textColor = kColorFromRGB(0x999999);
- }
-
-
- [self.cell0ShowImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
-
- switch (model.SearchType) {
- case 1:{
- self.cell0TitleLabel.text = model.Title;
- self.cell0IntroLabel.text = [NSString stringWithFormat:@"%@条相关记录",@(1)];
- self.cell0TypeLabel.text = @"消息";
- }
- break;
- case 2:{
- self.cell0IntroLabel.text = [NSString stringWithFormat:@"%@ %@",model.Name,[ZYCTool yearMonthAndDayHourMinuesSecond:model.CreatedDate]];
- // 关键字变色
- self.cell0TitleLabel.attributedText = [self changeText:model.Title KeyWordL:keyStr KeyWordColor:RGB(234, 55, 41)];
- self.cell0TypeLabel.text = @"话题";
- }
- break;
- case 3:{
- self.type7NameLabel.attributedText = [self changeText:model.Title KeyWordL:keyStr KeyWordColor:RGB(234, 55, 41)];
- [self.cell0ShowImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
- self.cell0TypeLabel.text = @"小组";
- }
- break;
- case 4:{
- self.cell0TypeLabel.text = @"通知";
- // 关键字变色
- self.cell0TitleLabel.attributedText = [self changeText:model.Title KeyWordL:keyStr KeyWordColor:RGB(234, 55, 41)];
- self.cell0IntroLabel.text = model.Name;
- // todo 已读未读
- }
- break;
- case 5:{
- self.cell0IntroLabel.text = model.Name;
- // todo 已读未读
- self.cell0TypeLabel.text = @"站内信";
- self.cell0TitleLabel.attributedText = [self changeText:model.Title KeyWordL:keyStr KeyWordColor:RGB(234, 55, 41)];
- }
- break;
- case 6:{
- self.type7NameLabel.attributedText = [self changeText:model.Title KeyWordL:keyStr KeyWordColor:RGB(234, 55, 41)];
- [self.cell0ShowImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
- self.cell0TypeLabel.text = @"通讯录";
- }
- break;
- default:
- self.type7NameLabel.text = @"";
- [self.cell0ShowImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage];
- self.cell0TypeLabel.text = @"";
- self.cell0TitleLabel.text = @"";
- self.cell0IntroLabel.text = @"";
- break;
- }
-
- }
- // 关键字变色
- - (NSAttributedString *)changeText:(NSString *)text KeyWordL:(NSString *)keyWord KeyWordColor:(UIColor *)color {
-
- NSString *string1 = text;
- NSString *string2 = keyWord;
-
- NSArray *array=[string1 componentsSeparatedByString:string2];
- NSMutableArray *arrayOfLocation=[NSMutableArray new];
- int d=0;
- for (int i=0; i<array.count-1; i++) {
- NSString *string=array[i];
- NSNumber *number=[NSNumber numberWithInt:d+=string.length];
- d+=string2.length;
- [arrayOfLocation addObject:number];
- }
-
- // 关键字变色
- NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:text];
- for (int i = 0; i < arrayOfLocation.count; i ++) {
- NSInteger loc = [arrayOfLocation[i] integerValue];
- NSRange range = NSMakeRange(loc, keyWord.length);
- [attrString addAttribute:(NSString *)NSForegroundColorAttributeName
- value:RGB(234, 55, 41)
- range:range];
- }
- return attrString;
- }
- @end
|