TUIGroupPendencyController.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // TUIGroupPendencyController.m
  3. // TXIMSDK_TUIKit_iOS
  4. //
  5. // Created by annidyfeng on 2019/6/18.
  6. // Copyright © 2023 Tencent. All rights reserved.
  7. //
  8. #import "TUIGroupPendencyController.h"
  9. #import <TIMCommon/TIMDefine.h>
  10. @interface TUIGroupPendencyController ()
  11. @end
  12. @implementation TUIGroupPendencyController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. [self.tableView registerClass:[TUIGroupPendencyCell class] forCellReuseIdentifier:@"PendencyCell"];
  16. self.tableView.tableFooterView = [UIView new];
  17. self.title = TIMCommonLocalizableString(TUIKitGroupApplicant);
  18. }
  19. - (void)dealloc {
  20. [[NSNotificationCenter defaultCenter] removeObserver:self];
  21. }
  22. #pragma mark - Table view data source
  23. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  24. return 1;
  25. }
  26. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  27. return self.viewModel.dataList.count;
  28. }
  29. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  30. TUIGroupPendencyCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PendencyCell" forIndexPath:indexPath];
  31. TUIGroupPendencyCellData *data = self.viewModel.dataList[indexPath.row];
  32. data.cselector = @selector(cellClick:);
  33. data.cbuttonSelector = @selector(btnClick:);
  34. [cell fillWithData:data];
  35. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  36. return cell;
  37. }
  38. - (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
  39. return NO;
  40. }
  41. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  42. return YES;
  43. }
  44. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  45. return 70;
  46. }
  47. // Override to support editing the table view.
  48. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  49. if (editingStyle == UITableViewCellEditingStyleDelete) {
  50. // add code here for when you hit delete
  51. [self.tableView beginUpdates];
  52. TUIGroupPendencyCellData *data = self.viewModel.dataList[indexPath.row];
  53. [self.viewModel removeData:data];
  54. [self.tableView deleteRowsAtIndexPaths:@[ indexPath ] withRowAnimation:UITableViewRowAnimationFade];
  55. [self.tableView endUpdates];
  56. }
  57. }
  58. - (void)btnClick:(TUIGroupPendencyCell *)cell {
  59. [self.viewModel acceptData:cell.pendencyData];
  60. [self.tableView reloadData];
  61. }
  62. - (void)cellClick:(TUIGroupPendencyCell *)cell {
  63. if (self.cellClickBlock) {
  64. self.cellClickBlock(cell);
  65. }
  66. }
  67. @end