// // MyTDGroupViewController.m // smartRhino // // Created by tederen on 2019/10/31. // Copyright © 2019 tederen. All rights reserved. // #import "MyTDGroupViewController.h" #import "YCMenuView.h" #import "ShowNewGroupAlert.h" #import "NoticeListModel.h" #import "ChatNewRowVC.h" #import "ChatNewRowCell.h" #import "MoveViewController.h" #import "TDGroupSearchResultVC.h" #import "TDGroupInfoListVC.h" @interface MyTDGroupViewController () @property (nonatomic, strong) TDTableView *tableView; @property (nonatomic, strong) UIView *CusNavBar; @property (nonatomic, strong) UILabel *titleL; @property (nonatomic, strong) UIButton *addBtn; @property (nonatomic, strong) NSMutableArray *dataArray; @property (nonatomic, copy) NSArray *addListArray; @property (assign,nonatomic) OperationStateEnum operationStateEnum; @property (strong,nonatomic) UIView *operationBottomBgView; @property (strong, nonatomic) UIButton *operationAllSelectButton; @property (nonatomic, strong) UIButton *leftCloseBtn; @property (nonatomic, strong) UIButton *rightMoveBtn; @property (nonatomic, assign) NSUInteger currentPage; @property (nonatomic, assign) NSUInteger totalPage; @property (nonatomic, assign) NSUInteger totalRecord; @property (nonatomic, assign) BOOL isFresh; @property (nonatomic, assign) BOOL isAllSelect; @property (nonatomic, assign) Boolean iSViewEditor; @end @implementation MyTDGroupViewController - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } - (void)viewDidLoad { [super viewDidLoad]; self.fd_prefersNavigationBarHidden = YES; [self addNavbarView]; [self initBottomBgView]; [self changeToOperation:NO]; self.iSViewEditor = NO; if (self.isPush) { [self pushListVC]; } } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self setTableViewRefresh]; [self headRefresh]; } - (void)addNavbarView { if (self.isSubVC) { self.addListArray = @[@"新建小组",@"批量编辑"]; }else{ self.addListArray = @[@"新建小组",@"建文件夹",@"批量编辑"]; } [self.view addSubview:self.CusNavBar]; [self.CusNavBar mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.right.mas_equalTo(self.view); make.height.mas_offset(kNavigationHeight); }]; UILabel * lineL = [UILabel new]; lineL.backgroundColor = LINEBGCOLOR; [self.CusNavBar addSubview:lineL]; [lineL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.bottom.right.mas_equalTo(self.CusNavBar); make.height.offset(0.5); }]; UIButton * backBtn = [UIButton new]; [backBtn setImage:[UIImage imageNamed:@"back_black_icon"] forState:UIControlStateNormal]; [self.CusNavBar addSubview:backBtn]; self.operationAllSelectButton = [UIButton new]; [self.operationAllSelectButton setImage:[UIImage imageNamed:@"menu_black_icon"] forState:UIControlStateNormal]; [self.CusNavBar addSubview:self.operationAllSelectButton]; self.addBtn = [UIButton new]; [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_add_icon"] forState:UIControlStateNormal]; [self.CusNavBar addSubview:self.addBtn]; [backBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.CusNavBar); make.bottom.mas_equalTo(self.CusNavBar); make.width.offset(50); make.height.offset(44); }]; [self.operationAllSelectButton mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(backBtn.mas_right); make.width.mas_greaterThanOrEqualTo(@35); make.height.offset(44); make.bottom.mas_equalTo(self.CusNavBar); }]; [self.addBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(self.CusNavBar); make.bottom.mas_equalTo(self.CusNavBar); make.width.offset(50); make.height.offset(44); }]; [backBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside]; [self.operationAllSelectButton addTarget:self action:@selector(menuAction:) forControlEvents:UIControlEventTouchUpInside]; WS(weakSelf); [self.addBtn setAction:^{ NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray]; YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn]; view.menuColor = RGB(255, 255, 255); view.separatorColor = RGB(234, 234, 234); view.textColor = RGB(102, 102, 102); view.textFont = [UIFont systemFontOfSize:16.0]; view.menuCellHeight = 43.5; view.maxDisplayCount = 10; view.offset = -6; [view show]; }]; [self.CusNavBar addSubview:self.titleL]; [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.CusNavBar); make.centerY.mas_equalTo(backBtn); make.height.offset(44); make.width.mas_greaterThanOrEqualTo(10); }]; if (self.titleStr.length == 0) { self.titleL.attributedText = [self stringToAttribuedString:@"小组"]; }else{ self.titleL.attributedText = [self stringToAttribuedString:self.titleStr]; } [self.view addSubview:self.tableView]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.CusNavBar.mas_bottom); make.left.right.mas_equalTo(self.view); if (@available(iOS 11.0, *)) { make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom); } else { make.bottom.equalTo(self.view.mas_bottom); } }]; if (@available(iOS 11.0, *)) { self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } else { self.automaticallyAdjustsScrollViewInsets = NO; } } -(NSMutableArray *)getMenuDataSource:(NSArray *)titleArray{ NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init]; for(int i=0;i*)findModelArray{ NSMutableArray *MiddleIds = [NSMutableArray array]; for (NoticeModel *model in findModelArray) { [MiddleIds addObject:@(model.Id)]; } NSMutableDictionary *dic = [[NSMutableDictionary alloc]init]; [dic setValue:MiddleIds forKey:@"MiddleIds"]; [dic setValue:@(CreateGroupType) forKey:@"FolderType"]; SHOWLOADING WEAKSELF [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) { STRONGSELF REMOVESHOW [strongSelf headRefresh]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; } /// 移动文件夹 - (void)moveFind:(NSMutableArray*)findModelArray withSuperModel:(NoticeModel *)supermodel{ NSMutableArray *MiddleIds = [NSMutableArray array]; for (NoticeModel *model in findModelArray) { [MiddleIds addObject:@(model.Id)]; } NSMutableDictionary *dic = [[NSMutableDictionary alloc]init]; [dic setValue:MiddleIds forKey:@"Ids"]; [dic setValue:@(self.ParentId) forKey:@"ParentId"]; SHOWLOADING WEAKSELF [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_Move) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) { STRONGSELF REMOVESHOW [strongSelf headRefresh]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; } -(void)initBottomBgView{ self.leftCloseBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [self.leftCloseBtn setTitle:@"删除" forState:UIControlStateNormal]; [self.leftCloseBtn setTitleColor:RGB(255, 82, 82) forState:UIControlStateNormal]; self.leftCloseBtn.titleLabel.font = [UIFont systemFontOfSize:15]; [self.operationBottomBgView addSubview:self.leftCloseBtn]; self.leftCloseBtn.frame = CGRectMake(0, 10, SCREEN_WIDTH/2, self.operationBottomBgView.height - 10); self.self.rightMoveBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [self.rightMoveBtn setTitle:@"移动" forState:UIControlStateNormal]; [self.rightMoveBtn setTitleColor:RGB(57, 121, 211) forState:UIControlStateNormal]; [self.rightMoveBtn setTitleColor:UIColorHex(#BBBBBB) forState:UIControlStateDisabled]; self.rightMoveBtn.enabled = NO; self.rightMoveBtn.titleLabel.font = [UIFont systemFontOfSize:15]; [self.operationBottomBgView addSubview:self.rightMoveBtn]; self.rightMoveBtn.frame = CGRectMake(SCREEN_WIDTH/2, 10, SCREEN_WIDTH/2, self.operationBottomBgView.height - 10); UIView *line = [[UIView alloc] init]; line.backgroundColor = RGB(240, 239, 244); [self.operationBottomBgView addSubview:line]; line.frame = CGRectMake(SCREEN_WIDTH/2, 0, .5, self.operationBottomBgView.height); UIView *topLine = [[UIView alloc] init]; topLine.backgroundColor = RGB(240, 239, 244); [self.operationBottomBgView addSubview:topLine]; topLine.frame = CGRectMake(0, 0, SCREEN_WIDTH, 10); WS(weakSelf); [self.leftCloseBtn setAction:^{ NSMutableArray *selectIDArray = [NSMutableArray array]; for (NoticeModel * model in weakSelf.dataArray) { if (model.IsSelect) { [selectIDArray addObject:model]; } } if (selectIDArray.count == 0) { SHOWERROR(@"请选择要删除的通知"); return ; }else{ [weakSelf deleteFind:selectIDArray]; } }]; [self.rightMoveBtn setAction:^{ NSMutableArray *selectIDArray = [NSMutableArray array]; for (NoticeModel * model in weakSelf.dataArray) { if (model.IsSelect) { [selectIDArray addObject:@(model.Id)]; } } if (selectIDArray.count == 0) { SHOWERROR(@"请选择要移动的通知或者文件夹"); return ; } [weakSelf launchMoveVC:selectIDArray]; }]; [[UtilsTools getWindow] addSubview:self.operationBottomBgView]; } - (void)launchMoveVC:(NSMutableArray*)selectIDArray{ MoveViewController * vc = [MoveViewController initMoveViewController]; vc.TypeId = CreateGroupType; vc.collectType = CollectHanderType_Move; vc.ParentId = 0; vc.titleStr = self.titleL.text; vc.FolderIds = selectIDArray; [self.navigationController pushViewController:vc animated:YES]; [self changeToOperation:NO]; } -(UIView *)operationBottomBgView{ if(!_operationBottomBgView){ _operationBottomBgView = [[UIView alloc] init]; CGFloat bottomBgViewH = self.tabBarController.tabBar.height + 10; _operationBottomBgView.frame = CGRectMake(0, SCREEN_HEIGHT - bottomBgViewH, SCREEN_WIDTH, bottomBgViewH); _operationBottomBgView.backgroundColor = RGB(255, 255, 255); _operationBottomBgView.hidden = YES; } return _operationBottomBgView; } #pragma mark 批量操作与正常操作界面切换 -(void)changeToOperation:(BOOL)operation{ if(operation){ self.titleL.attributedText = [self stringToAttribuedString:@"批量操作"]; self.iSViewEditor = YES; self.addBtn.hidden = YES; //默认操作状态为批量编辑状态 self.operationStateEnum = OperationStateEnum1; // self.operationBackButton.hidden = NO; self.operationAllSelectButton.hidden = NO; [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal]; [self.operationAllSelectButton setTitleColor:UIColorHex(#0F88EB) forState:UIControlStateNormal]; [self.operationAllSelectButton setImage:nil forState:UIControlStateNormal]; self.tabBarController.tabBar.hidden = YES; self.operationBottomBgView.hidden = NO; self.view.height -= self.tabBarController.tabBar.height; self.tableView.height -= self.tabBarController.tabBar.height; [self.view layoutIfNeeded]; [self.tableView layoutIfNeeded]; }else{ if (self.titleStr.length == 0) { self.titleL.attributedText = [self stringToAttribuedString:@"小组"]; }else{ self.titleL.attributedText = [self stringToAttribuedString:self.titleStr]; } self.addBtn.hidden = NO; self.iSViewEditor = NO; //默认操作状态为无状态 self.operationStateEnum = OperationStateEnum0; self.operationAllSelectButton.hidden = NO; [self.operationAllSelectButton setImage:IMG(@"menu_black_icon") forState:UIControlStateNormal]; [self.operationAllSelectButton setTitleColor:[UIColor clearColor] forState:UIControlStateNormal]; self.tabBarController.tabBar.hidden = YES; self.tableView.height += self.tabBarController.tabBar.height; self.view.height += self.tabBarController.tabBar.height; [self.view layoutIfNeeded]; [self.tableView layoutIfNeeded]; self.operationBottomBgView.hidden = YES; } [self.tableView reloadData]; } #pragma mark 移动 isEdit:当前是否为编辑状态 -(void)userDidMove:(BOOL)move isEdit:(BOOL)isEdit{ //移动 if(move){ //默认操作状态为移动状态 self.operationStateEnum = OperationStateEnum2; self.addBtn.hidden = NO; [self resetRightBtnAction:NO]; //隐藏tabBar - 并将TableView至底端 self.tabBarController.tabBar.hidden = YES; self.view.height += self.tabBarController.tabBar.height; self.tableView.height += self.tabBarController.tabBar.height; [self.view layoutIfNeeded]; [self.tableView layoutIfNeeded]; //隐藏operationBottomBgView self.operationBottomBgView.hidden = YES; } else{ //隐藏tabBar - 并将TableView至底端有tabBar.height的高 self.tabBarController.tabBar.hidden = YES; self.view.height -= self.tabBarController.tabBar.height; self.tableView.height -= self.tabBarController.tabBar.height; [self.view layoutIfNeeded]; [self.tableView layoutIfNeeded]; //显示operationBottomBgView self.operationBottomBgView.hidden = NO; if(isEdit){ self.operationStateEnum = OperationStateEnum1; self.addBtn.hidden = YES; [self resetRightBtnAction:YES]; }else{ [self changeToOperation:NO]; } } [self.tableView reloadData]; } -(void)resetRightBtnAction:(BOOL)isShowMenu{ WS(weakSelf); if(isShowMenu){ [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_add_icon"] forState:UIControlStateNormal]; [self.addBtn setAction:^{ NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray]; YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn]; view.menuColor = RGB(255, 255, 255); view.separatorColor = RGB(234, 234, 234); view.textColor = RGB(102, 102, 102); view.textFont = [UIFont systemFontOfSize:16.0]; view.menuCellHeight = 43.5; view.maxDisplayCount = 10; view.offset = -6; [view show]; }]; }else{ [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_fileadd_icon"] forState:UIControlStateNormal]; [self.addBtn setAction:^{ [ShowtipTool showErrorWithStatus:@"未做"]; }]; } } - (void)backAction:(id)sender{ if (self.iSViewEditor) { [self changeToOperation:NO]; }else{ [self.navigationController popViewControllerAnimated:true]; } } - (BOOL)checkChatListArray { for (NoticeModel * model in self.dataArray) { if (!model.IsSelect) { return NO; } } return YES; } - (void)menuAction:(id)sender{ switch (self.operationStateEnum) { case OperationStateEnum1: for (NoticeModel *model in self.dataArray) { model.IsSelect = !self.isAllSelect; } [self.tableView reloadData]; break; default: [super menuAction:sender]; break; } } #pragma mark - setter - (TDTableView *)tableView{ if (!_tableView) { _tableView = [[TDTableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain]; _tableView.delegate = self; _tableView.dataSource = self; } return _tableView; } - (NSMutableArray *)dataArray{ if (!_dataArray) { _dataArray = [NSMutableArray new]; } return _dataArray; } #pragma Mark 左滑按钮 iOS8以上 #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0 - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action WS(weakSelf); NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row]; if (indexPath.section > 0) { switch (model.AttributeValue) { case 2:{ UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)]; UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) { [weakSelf deleteFind:@[model].mutableCopy]; }]; UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]; [alert addAction:sureAction]; [alert addAction:cancelAction]; [weakSelf presentViewController:alert animated:YES completion:^{ }]; }]; action1.backgroundColor = RGB(255, 59, 47); UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"重命名" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) { [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"修改文件夹名称" changeStr:model.FolderName confirm:^(NSString * _Nonnull groupName) { NSLog(@"%@",groupName); [weakSelf reNameFind:model withReNameString:groupName]; } cancle:^{ }] show]; }]; action2.backgroundColor = RGB(255, 149, 3); UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) { [weakSelf topFind:model]; }]; action3.backgroundColor = RGB(197, 201, 204); UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1, action2, action3]]; actions.performsFirstActionWithFullSwipe = NO; return actions; }break; default:{ UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"退出" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) { [weakSelf deleteFind:@[model].mutableCopy]; }]; action1.backgroundColor = RGB(255, 59, 47); UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"移动" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) { [weakSelf launchMoveVC:@[@(model.Id)].mutableCopy]; }]; action2.backgroundColor = UIColorHex(#589AF1); UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop ?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) { [weakSelf topFind:model]; }]; action3.backgroundColor = RGB(197, 201, 204); UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1, action2, action3]]; actions.performsFirstActionWithFullSwipe = NO; return actions; } break; } }else{ UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[]]; actions.performsFirstActionWithFullSwipe = NO; return actions; } } #else - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row]; WEAKSELF if (indexPath.section > 0) { switch (model.AttributeValue) { case 2:{ UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) { [weakSelf deleteFind:@[model].mutableCopy]; }]; action1.backgroundColor = RGB(255, 59, 47); UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"重命名" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) { [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"修改文件夹名称" changeStr:model.FolderName confirm:^(NSString * _Nonnull groupName) { NSLog(@"%@",groupName); [weakSelf reNameFind:model withReNameString:groupName]; } cancle:^{ }] show]; }]; action2.backgroundColor = RGB(255, 149, 3); // NSLog(@"") UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title: model.IsTop?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) { [weakSelf topFind:model]; }]; action3.backgroundColor = RGB(197, 201, 204); return @[action1, action2, action3]; }break; default:{ UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"退出" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) { [weakSelf deleteFind:@[model].mutableCopy]; }]; action1.backgroundColor = RGB(255, 59, 47); UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"移动" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) { [weakSelf launchMoveVC:@[@(model.Id)].mutableCopy]; }]; action2.backgroundColor = UIColorHex(#589AF1); UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:model.IsTop ?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) { [weakSelf topFind:model]; }]; action3.backgroundColor = RGB(197, 201, 204); return @[action1, action2, action3]; } break; } }else{ return @[]; } } #endif #pragma mark - UITableViewDelegate,UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (section == 0) { return 1; }else{ return self.dataArray.count; } } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if (indexPath.section == 0) { return [ChatNewRowCell configCell0Height]; }else{ return [ChatNewRowCell configCell2Height]; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ WS(weakSelf); if (indexPath.section == 0) { ChatNewRowCell *cell = [ChatNewRowCell configCell0:tableView indexPath:indexPath]; WS(weakSelf); [cell.cell0SearchBtn setAction:^{ TDGroupSearchResultVC *vc = [[TDGroupSearchResultVC alloc] init]; vc.ParentId = weakSelf.ParentId; [weakSelf.navigationController pushViewController:vc animated:YES]; }]; return cell; } else{ switch (self.operationStateEnum) { case OperationStateEnum0:{ NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row]; switch (model.AttributeValue) { case 2:{ ChatNewRowCell *cell = [ChatNewRowCell configCell1:tableView indexPath:indexPath]; cell.cell1TitleLabel.text = model.FolderName; cell.IsTopImgV.hidden = !model.IsTop; cell.cell1TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.FileCount]; cell.cell1TimeLabel.hidden = model.FileCount == 0 ? YES : NO; return cell; }break; default:{ ChatNewRowCell *cell = [ChatNewRowCell configCell2:tableView indexPath:indexPath]; [cell.cell2UserImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage]; cell.cell2TitleLabel.text = model.GroupName; cell.IsTopImgV.hidden = !model.IsTop; cell.cell2IntroLabel.text = [NSString stringWithFormat:@"共享给%ld人",(long)model.TopicSharingCount]; cell.cell2TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.TopicAllCount]; cell.cell2TimeLabel.hidden = model.TopicAllCount == 0 ? YES : NO; cell.cell2RedNumLabel.text = model.UReadTopicCount > 0 ? [NSString stringWithFormat:@"[%ld条新话题]",(long)model.UReadTopicCount] : @""; return cell; }break; } }break; default:{ NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row]; self.isAllSelect = [self checkChatListArray]; if (self.isAllSelect) { [self.operationAllSelectButton setTitle:@"取消全选" forState:UIControlStateNormal]; }else{ [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal]; } switch (model.AttributeValue) { case 2:{///文件 ChatNewRowCell *cell = [ChatNewRowCell configCell10:tableView indexPath:indexPath]; cell.cell1TitleLabel.text = model.FolderName; cell.cell1TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.FileCount]; cell.cell1TimeLabel.hidden = model.FileCount == 0 ? YES : NO; cell.cell1SelectButton.selected = model.IsSelect; [cell.cell1SelectButton setAction:^{ model.IsSelect = !model.IsSelect; [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; }]; return cell; }break; default:{///小组 ChatNewRowCell *cell = [ChatNewRowCell configCell20:tableView indexPath:indexPath]; [cell.cell2UserImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:kUserDefaultHeadImage]; cell.cell2TitleLabel.text = model.GroupName; cell.cell2IntroLabel.text = @"用户名"; cell.cell2TimeLabel.text = [NSString stringWithFormat:@"%ld",(long)model.TopicAllCount]; cell.cell2TimeLabel.hidden = model.TopicAllCount == 0 ? YES : NO; cell.cell2RedNumLabel.text = model.UReadTopicCount > 0 ? [NSString stringWithFormat:@"[%ld条新话题]",(long)model.UReadTopicCount] : @""; cell.cell2SelectButton.selected = model.IsSelect; [cell.cell2SelectButton setAction:^{ model.IsSelect = !model.IsSelect; [weakSelf.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; }]; return cell; }break; } }break; } } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; switch (self.operationStateEnum) { case OperationStateEnum1:{ NSLog(@"编辑状态的cell"); self.dataArray[indexPath.row].IsSelect = !self.dataArray[indexPath.row].IsSelect; [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; self.rightMoveBtn.enabled = [self isMoveCheckData]; }break; default:{ NSLog(@"正常状态的cell"); NoticeModel *model = [self.dataArray objectAtIndex:indexPath.row]; if(model && model != nil) { switch (model.AttributeValue) { case 2:{ MyTDGroupViewController *vc = [[MyTDGroupViewController alloc] init]; vc.ParentId = model.Id; vc.isSubVC = YES; vc.titleStr = model.FolderName; [self.navigationController pushViewController:vc animated:YES]; }break; default:{ if (self.isReturn) { MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC]; vc.Id = model.GroupId; vc.type = self.type == 0 ? CollectModel_Group : self.type; vc.isReturn = self.isReturn; vc.sendModel = self.sendModel; [self.navigationController pushViewController:vc animated:YES]; }else{ TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC]; vc.titleStr = model.GroupName; vc.GroupId = model.GroupId; vc.type = self.type; vc.sendModel = self.sendModel; [self.navigationController pushViewController:vc animated:YES]; } }break; } } }break; } } - (void)pushListVC { TDGroupInfoListVC * vc = [TDGroupInfoListVC initTDGroupInfoListVC]; vc.titleStr = self.pushDict[@"Name"]; vc.GroupId = [self.pushDict[@"Id"] integerValue]; [self.navigationController pushViewController:vc animated:NO]; } - (BOOL)isMoveCheckData { BOOL isSelect = NO; for (NoticeModel * model in self.dataArray) { if (model.AttributeValue == 2 && model.IsSelect) { return NO; } if (model.IsSelect) { isSelect = YES; } } if (!isSelect) { return NO; } return YES; } @end