WFCUConferenceHandupTableViewController.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // WFCUConferenceHandupTableViewController.m
  3. // WFChatUIKit
  4. //
  5. // Created by Rain on 2022/10/3.
  6. // Copyright © 2022 Wildfirechat. All rights reserved.
  7. //
  8. #import "WFCUConferenceHandupTableViewController.h"
  9. #import "UIColor+YH.h"
  10. #import "WFCUConferenceMemberTableViewCell.h"
  11. #import "WFCUConferenceManager.h"
  12. #import <SDWebImage/SDWebImage.h>
  13. #import "WFCUUtilities.h"
  14. #import "WFCUImage.h"
  15. @interface WFCUConferenceHandupTableViewController () <UITableViewDataSource, UITableViewDelegate>
  16. @property (nonatomic, strong)UITableView *tableView;
  17. @property(nonatomic, strong)UIButton *putdownAllBtn;
  18. @end
  19. @implementation WFCUConferenceHandupTableViewController
  20. #if WFCU_SUPPORT_VOIP
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. self.view.backgroundColor = [UIColor whiteColor];
  24. CGRect bounds = self.view.bounds;
  25. CGFloat buttonHeight = 48;
  26. CGFloat buttonWidth = bounds.size.width - 16 - 16;
  27. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, bounds.size.height - [WFCUUtilities wf_safeDistanceBottom] - buttonHeight - 16)];
  28. self.tableView.delegate = self;
  29. self.tableView.dataSource = self;
  30. if (@available(iOS 15, *)) {
  31. self.tableView.sectionHeaderTopPadding = 0;
  32. }
  33. self.tableView.sectionIndexColor = [UIColor colorWithHexString:@"0x4e4e4e"];
  34. self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  35. [self.view addSubview:self.tableView];
  36. [self.tableView reloadData];
  37. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:WFCString(@"Close") style:UIBarButtonItemStyleDone target:self action:@selector(onClose:)];
  38. }
  39. - (void)viewWillAppear:(BOOL)animated {
  40. [super viewWillAppear:animated];
  41. if([WFCUConferenceManager sharedInstance].handupMembers.count && !self.putdownAllBtn) {
  42. CGRect bounds = self.view.bounds;
  43. CGFloat buttonHeight = 48;
  44. CGFloat buttonWidth = bounds.size.width - 16 - 16;
  45. self.putdownAllBtn = [self createBtn:CGRectMake(16, bounds.size.height - [WFCUUtilities wf_safeDistanceBottom] - buttonHeight - 16, buttonWidth, buttonHeight) title:@"全部放下" action:@selector(onPutdownAllBtnPressed:)];
  46. }
  47. }
  48. - (void)onPutdownAllBtnPressed:(id)sender {
  49. [[WFCUConferenceManager sharedInstance] putAllHandDown];
  50. [self.tableView reloadData];
  51. }
  52. - (void)onClose:(id)sender {
  53. [self dismissViewControllerAnimated:YES completion:nil];
  54. }
  55. - (UIButton *)createBtn:(CGRect)frame title:(NSString *)title action:(SEL)action {
  56. UIButton *btn = [[UIButton alloc] initWithFrame:frame];
  57. [btn setTitle:title forState:UIControlStateNormal];
  58. btn.titleLabel.font = [UIFont systemFontOfSize:14];
  59. [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  60. btn.layer.borderWidth = 1;
  61. btn.layer.borderColor = [UIColor grayColor].CGColor;
  62. btn.layer.masksToBounds = YES;
  63. btn.layer.cornerRadius = 5.f;
  64. [btn addTarget:self action:action forControlEvents:UIControlEventTouchDown];
  65. [self.view addSubview:btn];
  66. return btn;
  67. }
  68. #pragma mark - UITableViewDataSource<NSObject>
  69. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  70. return [WFCUConferenceManager sharedInstance].handupMembers.count;
  71. }
  72. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  73. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  74. if(!cell) {
  75. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  76. CGSize size = cell.bounds.size;
  77. size.width = self.view.bounds.size.width;
  78. CGFloat buttonWidth = 24;
  79. UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(size.width - 8 - buttonWidth, (size.height - buttonWidth)/2, buttonWidth, buttonWidth)];
  80. imageview.image = [WFCUImage imageNamed:@"conference_handup"];
  81. [cell.contentView addSubview:imageview];
  82. }
  83. for (UIView *view in cell.contentView.subviews) {
  84. if([view isKindOfClass:[UIImageView class]]) {
  85. [cell.contentView bringSubviewToFront:view];
  86. }
  87. }
  88. NSString *userId = [WFCUConferenceManager sharedInstance].handupMembers[indexPath.row];
  89. WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:userId refresh:NO];
  90. cell.textLabel.text = userInfo.friendAlias.length?userInfo.friendAlias:userInfo.displayName;
  91. [cell.imageView sd_setImageWithURL:[NSURL URLWithString:userInfo.portrait] placeholderImage:[WFCUImage imageNamed:@"PersonalChat"]];
  92. cell.tag = indexPath.row;
  93. return cell;
  94. }
  95. #pragma mark - UITableViewDelegate
  96. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  97. NSString *userId = [WFCUConferenceManager sharedInstance].handupMembers[indexPath.row];
  98. }
  99. #endif
  100. @end