123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- //
- // ChatMsgListCell.m
- // smartRhino
- //
- // Created by armin on 2019/11/2.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "ChatMsgListCell.h"
- #import "NSDate+Extension.h"
- #import "UIImage+GH.h"
- @interface ChatMsgListCell()
- @property (copy,nonatomic) NSMutableArray *chatDistoryArray;
- @end
- @implementation ChatMsgListCell
- - (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 50;
- }
- + (CGFloat)configCell1Height{
- return 90;
- }
- + (CGFloat)configCell2Height{
- return 69;
- }
- + (CGFloat)configCell3Height{
- return 76;
- }
- + (CGFloat)configCell4Height{
- return 40;
- }
- + (CGFloat)configCell5Height{
- return 76;
- }
- + (ChatMsgListCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"ChatMsgListCell0";
- ChatMsgListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatMsgListCell" owner:nil options:nil] objectAtIndex:0];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.cell0SearchBgView.layer.masksToBounds = YES;
- cell.cell0SearchBgView.layer.cornerRadius = 36/2.0;
- cell.cell0SearchBgView.layer.borderWidth = 0.5;
- cell.cell0SearchBgView.layer.borderColor = RGB(204, 204, 204).CGColor;
- cell.cell0MengCengView.hidden = YES;
- return cell;
- }
- + (ChatMsgListCell *)configCell1:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"ChatMsgListCell1";
- ChatMsgListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatMsgListCell" owner:nil options:nil] objectAtIndex:1];
- }
- cell.rightImg.hidden = NO;
- cell.cell1RightIntoBtn.hidden = NO;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- + (ChatMsgListCell *)configCell2:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"ChatMsgListCell2";
- ChatMsgListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatMsgListCell" owner:nil options:nil] objectAtIndex:2];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.cell2RightArrowImgView.hidden = NO;
- cell.enterBtn.hidden = YES;
- return cell;
- }
- + (ChatMsgListCell *)configCell3:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"ChatMsgListCell3";
- ChatMsgListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatMsgListCell" owner:nil options:nil] objectAtIndex:3];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
-
- cell.cell3RedBgView.layer.masksToBounds = YES;
- cell.cell3RedBgView.layer.cornerRadius = 16/2.0;
-
- cell.cell3MengCengView.hidden = YES;
-
- return cell;
- }
- + (ChatMsgListCell *)configCell4:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"ChatMsgListCell4";
- ChatMsgListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatMsgListCell" owner:nil options:nil] objectAtIndex:4];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- + (ChatMsgListCell *)configCell5:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"ChatMsgListCell5";
- ChatMsgListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatMsgListCell" owner:nil options:nil] objectAtIndex:5];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
-
- cell.cell5RedBgView.layer.masksToBounds = YES;
- cell.cell5RedBgView.layer.cornerRadius = 16/2.0;
-
- return cell;
- }
- + (ChatMsgListCell *)configCell6:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifer = @"ChatMsgListCell6";
- ChatMsgListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
- if (cell == nil) {
- cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatMsgListCell" owner:nil options:nil] objectAtIndex:6];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.cell2RightArrowImgView.hidden = YES;
- return cell;
- }
- - (void)setCell2DataWithModel:(NoticeModel *)model
- {
- self.cell2TitleLabel.text = model.FolderName;
- self.cell2TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.UReadTopicCount];
- }
- - (void)setCell2MsgWithModel:(ChatMsgWorkModel *)model
- {
- self.cell2TitleLabel.text = model.Name;
- self.cell2TimeLabel.text = [NSDate getTimeStringAutoShort2:[self isNullWithString:model.LastModifiedDate]];
- }
- - (void)setCell3DataWithModel:(ChatMsgListImModel *)model
- {
- WS(weakSelf);
- [SDWebImageManager.sharedManager loadImageWithURL:[NSURL URLWithString:model.AvatarUrl] options:SDWebImageAvoidAutoSetImage progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
-
- } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
- weakSelf.cell3UserImgView.image = [UIImage cutImageWithImage:image];
- }];
- self.cell3TitleLabel.text = model.Name;
- NSString * infoText = [self getUserInfoInDocument:[NSString stringWithFormat:@"%ld",(long)model.ImId]];
- if (infoText.length > 0) {
- self.cell3IntroLabel.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"[草稿]%@",infoText]];
- self.cell3IntroLabel.attributedText = [self.cell3IntroLabel subhighlightString:@"[草稿]" color:[UIColor redColor]];
- }else{
- self.cell3IntroLabel.attributedText = model.ChatText;
- }
- if (model.redNum > 0 && !model.IsDisturb) {
- self.cell3RedBgView.hidden = NO;
- self.cell3RedNumLabel.text = [NSString stringWithFormat:@"%ld",(long)model.redNum];
- }else{
- self.cell3RedBgView.hidden = YES;
- }
- self.IsTopView.hidden = !model.IsTop;
- self.cell3TimeLabel.text = [NSDate getTimeStringAutoShort2:model.LastModifiedDate];
- }
- - (void)setCell5DataWithModel:(ChatMsgListImModel *)model
- {
- WS(weakSelf);
- [SDWebImageManager.sharedManager loadImageWithURL:[NSURL URLWithString:model.AvatarUrl] options:SDWebImageAvoidAutoSetImage progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
-
- } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
- weakSelf.cell5UserImgView.image = [UIImage cutImageWithImage:image];
- }];
- self.cell5TitleLabel.text = model.Name;
- NSString * infoText = [self getUserInfoInDocument:[NSString stringWithFormat:@"%ld",(long)model.ImId]];
- if (infoText.length > 0) {
- self.cell5IntroLabel.attributedText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"[草稿]%@",infoText]];
- self.cell5IntroLabel.attributedText = [self.cell3IntroLabel subhighlightString:@"[草稿]" color:[UIColor redColor]];
- }else{
- self.cell5IntroLabel.attributedText = model.ChatText;
- }
- self.cell5RedBgView.hidden = YES;
- self.cell5TimeLabel.text = @"";
- self.IsTopView.hidden = !model.IsTop;
- self.cell5SelectBtn.selected = model.isSelected;
- }
- - (NSString *)isNullWithString:(id)value
- {
- if ([value isKindOfClass:[NSNull class]]) {
- return @"";
- }else{
- if ([value isKindOfClass:[NSString class]]) {
- return value;
- }else{
- return [value stringValue];
- }
- }
- }
- - (void)layoutSubviews
- {
- for (UIView *supView in self.subviews){
- if ([supView isKindOfClass:NSClassFromString(@"UITableViewCellReorderControl")]){
- for (UIView *view in supView.subviews)
- {
- if ([view isKindOfClass: [UIImageView class]])
- {
- UIImageView * imagV = (UIImageView *)view;
- [imagV setFrame:CGRectMake(0, 0, 22, 18)];
- imagV.center = supView.center;
- imagV.contentMode = UIViewContentModeCenter;
- imagV.image = [UIImage imageNamed: @"list_sort"];
- UILabel * label = [UILabel new];
- label.backgroundColor = UIColorHex(#EAEAEA);
- [supView addSubview:label];
- [label setFrame:CGRectMake(0, supView.frame.size.height - 0.5, supView.frame.size.width, 0.5)];
- }else{
- [view removeFromSuperview];
- }
- }
- }
- if ([supView isKindOfClass:NSClassFromString(@"_UITableViewCellSeparatorView")]){
- }
- }
- [super layoutSubviews];
- }
- - (NSString *)getUserInfoInDocument:(NSString *)ImId{
- self.chatDistoryArray = [[NSMutableArray alloc] initWithArray:USERDEFAULTSGET(@"ChatList")];
- for (NSMutableDictionary * dict in self.chatDistoryArray) {
- if ([[dict objectForKey:@"ImId"] isEqualToString:ImId]) {
- NSString * text = [dict objectForKey:@"text"];
- return text;
- }
- }
- return @"";
- }
- @end
|