MOLiveCenterTableView.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // MOLiveCenterTableView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/12/5.
  6. //
  7. #import "MOLiveCenterTableView.h"
  8. @interface MOLiveCenterTableView ()<UITableViewDelegate,UITableViewDataSource>
  9. @end
  10. @implementation MOLiveCenterTableView
  11. - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
  12. {
  13. self = [super initWithFrame:frame style:style];
  14. if (self)
  15. {
  16. self.delegate = self;
  17. self.dataSource = self;
  18. [self registerClass:[MOLiveCenterBaseCell class] forCellReuseIdentifier:MOLiveCenterBaseCell_ID];
  19. }
  20. return self;
  21. }
  22. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  23. {
  24. return 1;
  25. }
  26. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  27. {
  28. if(self.cellType == MOLiveCenterUserCellType){
  29. return self.dataArr.count;
  30. }
  31. else{
  32. return 3;
  33. }
  34. }
  35. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  36. if(self.cellType == MOLiveCenterUserCellType){
  37. MOLiveCenterBaseCell *cell = [tableView dequeueReusableCellWithIdentifier:MOLiveCenterBaseCell_ID];
  38. if (cell == nil){
  39. cell = [[MOLiveCenterBaseCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MOLiveCenterBaseCell_ID];
  40. }
  41. if(self.dataArr.count > 0){
  42. MOPersonList *model = self.dataArr[indexPath.row];
  43. cell.cellModel = model;
  44. }
  45. return cell;
  46. }
  47. else{
  48. MOListCenterTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:MOListCenterTitleCell_ID];
  49. if (cell == nil){
  50. cell = [[MOListCenterTitleCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MOListCenterTitleCell_ID];
  51. }
  52. if(indexPath.row == 0){
  53. cell.titleLab.text = NSLocalString(@"mimo_live_center_wish_list_reward");
  54. [cell.goldNumBtn setTitle:[NSString stringWithFormat:@"%.f",self.otherGoldenBean] forState:UIControlStateNormal];
  55. cell.rightImg.hidden = NO;
  56. }
  57. else if(indexPath.row == 1){
  58. cell.titleLab.text = NSLocalString(@"mimo_live_center_like_list");
  59. [cell.goldNumBtn setTitle:[NSString stringWithFormat:@"%.f",self.likeGoldenBean] forState:UIControlStateNormal];
  60. cell.rightImg.hidden = YES;
  61. }
  62. else if (indexPath.row == 2){
  63. cell.titleLab.text = NSLocalString(@"mimo_live_center_divide_list");
  64. [cell.goldNumBtn setTitle:[NSString stringWithFormat:@"%.f",self.divideGoldenBean] forState:UIControlStateNormal];
  65. cell.rightImg.hidden = YES;
  66. }
  67. return cell;
  68. }
  69. }
  70. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  71. {
  72. return 65.0;
  73. }
  74. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  75. {
  76. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  77. if(self.cellType == MOLiveCenterUserCellType){
  78. if(self.dataArr.count > 0){
  79. MOPersonList *model = self.dataArr[indexPath.row];
  80. self.cellClickBlock ? self.cellClickBlock(model) : nil;
  81. }
  82. }
  83. else{
  84. if(indexPath.row == 1 || indexPath.row == 2){
  85. return;
  86. }
  87. self.wishCellClickBlock ? self.wishCellClickBlock() : nil;
  88. }
  89. }
  90. - (NSMutableArray *)dataArr{
  91. if(!_dataArr){
  92. _dataArr = [NSMutableArray array];
  93. }
  94. return _dataArr;
  95. }
  96. @end