WFCUConferenceMemberManagerViewController.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. //
  2. // WFCUConferenceMemberManagerViewController.m
  3. // WFChatUIKit
  4. //
  5. // Created by Tom Lee on 2021/2/15.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #if WFCU_SUPPORT_VOIP
  9. #import "WFCUConferenceMemberManagerViewController.h"
  10. #import "UIColor+YH.h"
  11. #import "WFCUConferenceUnmuteRequestTableViewController.h"
  12. #import "WFCUConferenceHandupTableViewController.h"
  13. #import <WFAVEngineKit/WFAVEngineKit.h>
  14. #import "WFCUUtilities.h"
  15. #import "WFCUConferenceMember.h"
  16. #import "WFCUConferenceManager.h"
  17. #import "WFCUConferenceMemberTableViewCell.h"
  18. #import "WFCUConferenceInviteViewController.h"
  19. #import "WFZConferenceInfo.h"
  20. #import "WFCUPinyinUtility.h"
  21. #import "WFCUProfileTableViewController.h"
  22. #import "WFCUImage.h"
  23. @interface WFCUConferenceMemberManagerViewController () <UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate>
  24. @property (nonatomic, strong)UITableView *tableView;
  25. @property (nonatomic, strong)UISearchBar *searchBar;
  26. @property (nonatomic, strong) NSMutableArray<WFCUConferenceMember *> *participants;
  27. @property(nonatomic, strong)UIButton *muteAllBtn;
  28. @property(nonatomic, strong)UIButton *unmuteAllBtn;
  29. @property(nonatomic, strong)UIView *headerViewContainer;
  30. @property(nonatomic, strong)UIButton *unmuteAudioRequestBtn;
  31. @property(nonatomic, strong)UIButton *unmuteVideoRequestBtn;
  32. @property(nonatomic, strong)UIButton *handupBtn;
  33. @end
  34. @implementation WFCUConferenceMemberManagerViewController
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 40)];
  38. self.searchBar.delegate = self;
  39. self.searchBar.placeholder = @"搜索";
  40. self.searchBar.barStyle = UIBarStyleDefault;
  41. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
  42. self.tableView.delegate = self;
  43. self.tableView.dataSource = self;
  44. if (@available(iOS 15, *)) {
  45. self.tableView.sectionHeaderTopPadding = 0;
  46. }
  47. self.tableView.sectionIndexColor = [UIColor colorWithHexString:@"0x4e4e4e"];
  48. self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  49. [self.tableView registerClass:[WFCUConferenceMemberTableViewCell class] forCellReuseIdentifier:@"cell"];
  50. self.headerViewContainer = [[UIView alloc] initWithFrame:CGRectZero];
  51. [self.headerViewContainer addSubview:self.searchBar];
  52. self.unmuteAudioRequestBtn = [[UIButton alloc] initWithFrame:CGRectZero];
  53. [self.unmuteAudioRequestBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  54. self.unmuteAudioRequestBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  55. [self.unmuteAudioRequestBtn addTarget:self action:@selector(onUnmuteAudioRequestBtnPressed:) forControlEvents:UIControlEventTouchDown];
  56. [self.headerViewContainer addSubview:self.unmuteAudioRequestBtn];
  57. self.unmuteVideoRequestBtn = [[UIButton alloc] initWithFrame:CGRectZero];
  58. [self.unmuteVideoRequestBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  59. self.unmuteVideoRequestBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  60. [self.unmuteVideoRequestBtn addTarget:self action:@selector(onUnmuteVideoRequestBtnPressed:) forControlEvents:UIControlEventTouchDown];
  61. [self.headerViewContainer addSubview:self.unmuteVideoRequestBtn];
  62. self.handupBtn = [[UIButton alloc] initWithFrame:CGRectZero];
  63. [self.handupBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  64. self.handupBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  65. [self.handupBtn addTarget:self action:@selector(onHandupBtnPressed:) forControlEvents:UIControlEventTouchDown];
  66. [self.headerViewContainer addSubview:self.handupBtn];
  67. self.tableView.tableHeaderView = self.headerViewContainer;
  68. [self.view addSubview:self.tableView];
  69. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:WFCString(@"Close") style:UIBarButtonItemStyleDone target:self action:@selector(onClose:)];
  70. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:WFCString(@"Invite") style:UIBarButtonItemStyleDone target:self action:@selector(onInvite:)];
  71. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onConferenceMemberChanged:) name:@"kConferenceMemberChanged" object:nil];
  72. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onConferenceEnded:) name:@"kConferenceEnded" object:nil];
  73. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onConferenceMutedStateChanged:) name:@"kConferenceMutedStateChanged" object:nil];
  74. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onConferenceCommandStateChanged:) name:@"kConferenceCommandStateChanged" object:nil];
  75. self.title = WFCString(@"ConferenceMembers");
  76. [self loadData];
  77. [self.tableView reloadData];
  78. }
  79. - (void)onUnmuteAudioRequestBtnPressed:(id)sender {
  80. WFCUConferenceUnmuteRequestTableViewController *vc = [[WFCUConferenceUnmuteRequestTableViewController alloc] init];
  81. vc.isAudio = YES;
  82. UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
  83. [self presentViewController:nav animated:YES completion:nil];
  84. }
  85. - (void)onUnmuteVideoRequestBtnPressed:(id)sender {
  86. WFCUConferenceUnmuteRequestTableViewController *vc = [[WFCUConferenceUnmuteRequestTableViewController alloc] init];
  87. vc.isAudio = NO;
  88. UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
  89. [self presentViewController:nav animated:YES completion:nil];
  90. }
  91. - (void)onHandupBtnPressed:(id)sender {
  92. WFCUConferenceHandupTableViewController *vc = [[WFCUConferenceHandupTableViewController alloc] init];
  93. UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
  94. [self presentViewController:nav animated:YES completion:nil];
  95. }
  96. - (void)updateTableViewHeader {
  97. if([self.searchBar isFirstResponder] || ([WFCUConferenceManager sharedInstance].applyingUnmuteAudioMembers.count == 0 && [WFCUConferenceManager sharedInstance].applyingUnmuteVideoMembers.count == 0 && [WFCUConferenceManager sharedInstance].handupMembers.count == 0)) {
  98. self.headerViewContainer.frame = CGRectMake(0, 50, self.view.bounds.size.width, 40);
  99. self.unmuteAudioRequestBtn.frame = CGRectZero;
  100. self.unmuteVideoRequestBtn.frame = CGRectZero;
  101. self.handupBtn.frame = CGRectZero;
  102. } else {
  103. int height = 40;
  104. NSMutableArray<NSString *> *applyingUnmuteAudioMembers = [WFCUConferenceManager sharedInstance].applyingUnmuteAudioMembers;
  105. if(applyingUnmuteAudioMembers.count) {
  106. self.unmuteAudioRequestBtn.frame = CGRectMake(0, height, self.view.bounds.size.width, 40);
  107. NSString *name;
  108. if(applyingUnmuteAudioMembers.count == 1) {
  109. WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:applyingUnmuteAudioMembers[0] refresh:NO];
  110. name = userInfo.friendAlias.length ? userInfo.friendAlias : userInfo.displayName;
  111. if(!name.length) {
  112. name = @"1名成员";
  113. }
  114. } else {
  115. name = [NSString stringWithFormat:@"%ld名成员", applyingUnmuteAudioMembers.count];
  116. }
  117. [self.unmuteAudioRequestBtn setTitle:[NSString stringWithFormat:@" %@正在申请解除静音", name] forState:UIControlStateNormal];
  118. height += 40;
  119. } else {
  120. self.unmuteAudioRequestBtn.frame = CGRectZero;
  121. }
  122. NSMutableArray<NSString *> *applyingUnmuteVideoMembers = [WFCUConferenceManager sharedInstance].applyingUnmuteVideoMembers;
  123. if(applyingUnmuteVideoMembers.count) {
  124. self.unmuteVideoRequestBtn.frame = CGRectMake(0, height, self.view.bounds.size.width, 40);
  125. NSString *name;
  126. if(applyingUnmuteVideoMembers.count == 1) {
  127. WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:applyingUnmuteVideoMembers[0] refresh:NO];
  128. name = userInfo.friendAlias.length ? userInfo.friendAlias : userInfo.displayName;
  129. if(!name.length) {
  130. name = @"1名成员";
  131. }
  132. } else {
  133. name = [NSString stringWithFormat:@"%ld名成员", applyingUnmuteVideoMembers.count];
  134. }
  135. [self.unmuteVideoRequestBtn setTitle:[NSString stringWithFormat:@" %@正在申请打开摄像头", name] forState:UIControlStateNormal];
  136. height += 40;
  137. } else {
  138. self.unmuteVideoRequestBtn.frame = CGRectZero;
  139. }
  140. NSMutableArray<NSString *> *handupMembers = [WFCUConferenceManager sharedInstance].handupMembers;
  141. if([WFCUConferenceManager sharedInstance].handupMembers.count) {
  142. self.handupBtn.frame = CGRectMake(0, height, self.view.bounds.size.width, 40);
  143. NSString *name;
  144. if(handupMembers.count == 1) {
  145. WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:handupMembers[0] refresh:NO];
  146. name = userInfo.friendAlias.length ? userInfo.friendAlias : userInfo.displayName;
  147. if(!name.length) {
  148. name = @"1名成员";
  149. }
  150. } else {
  151. name = [NSString stringWithFormat:@"%ld名成员", handupMembers.count];
  152. }
  153. [self.handupBtn setTitle:[NSString stringWithFormat:@" %@正在举手", name] forState:UIControlStateNormal];
  154. height += 40;
  155. } else {
  156. self.handupBtn.frame = CGRectZero;
  157. }
  158. self.headerViewContainer.frame = CGRectMake(0, 50, self.view.bounds.size.width, height);
  159. }
  160. }
  161. - (void)viewWillAppear:(BOOL)animated {
  162. [super viewWillAppear:animated];
  163. if(!self.muteAllBtn && [[WFCUConferenceManager sharedInstance] isOwner]) {
  164. CGRect bounds = self.view.bounds;
  165. CGFloat buttonHeight = 48;
  166. CGFloat buttonWidth = bounds.size.width/2 - 16 - 8;
  167. self.muteAllBtn = [self createBtn:CGRectMake(16, bounds.size.height - [WFCUUtilities wf_safeDistanceBottom] - buttonHeight - 16, buttonWidth, buttonHeight) title:WFCString(@"MuteAll") action:@selector(onMuteAllBtnPressed:)];
  168. self.unmuteAllBtn = [self createBtn:CGRectMake(bounds.size.width - 16 - buttonWidth, bounds.size.height - [WFCUUtilities wf_safeDistanceBottom] - buttonHeight - 16, buttonWidth, buttonHeight) title:WFCString(@"UnmuteAll") action:@selector(onUnmuteAllBtnPressed:)];
  169. }
  170. [self updateTableViewHeader];
  171. }
  172. - (UIButton *)createBtn:(CGRect)frame title:(NSString *)title action:(SEL)action {
  173. UIButton *btn = [[UIButton alloc] initWithFrame:frame];
  174. [btn setTitle:title forState:UIControlStateNormal];
  175. btn.titleLabel.font = [UIFont systemFontOfSize:14];
  176. [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  177. btn.layer.borderWidth = 1;
  178. btn.layer.borderColor = [UIColor grayColor].CGColor;
  179. btn.layer.masksToBounds = YES;
  180. btn.layer.cornerRadius = 5.f;
  181. [btn addTarget:self action:action forControlEvents:UIControlEventTouchDown];
  182. [self.view addSubview:btn];
  183. return btn;
  184. }
  185. - (void)onMuteAllBtnPressed:(id)sender {
  186. [[WFCUConferenceManager sharedInstance] presentCommandAlertView:self message:@"所有成员将被静音" actionTitle:@"全体静音" cancelTitle:nil contentText:@"允许成员自主解除静音" checkBox:YES actionHandler:^(BOOL checked) {
  187. [[WFCUConferenceManager sharedInstance] requestMuteAll:checked];
  188. } cancelHandler:nil];
  189. }
  190. - (void)onUnmuteAllBtnPressed:(id)sender {
  191. [[WFCUConferenceManager sharedInstance] presentCommandAlertView:self message:@"允许全体成员开麦" actionTitle:@"取消全体静音" cancelTitle:nil contentText:@"是否要求成员开麦" checkBox:YES actionHandler:^(BOOL checked) {
  192. [[WFCUConferenceManager sharedInstance] requestUnmuteAll:checked];
  193. } cancelHandler:nil];
  194. }
  195. - (void)loadData {
  196. self.participants = [[NSMutableArray alloc] init];
  197. WFAVCallSession *callSession = [WFAVEngineKit sharedEngineKit].currentSession;
  198. NSArray<WFAVParticipantProfile *> *ps = [WFAVEngineKit sharedEngineKit].currentSession.participants;
  199. NSMutableArray *audiences = [[NSMutableArray alloc] init];
  200. for (WFAVParticipantProfile *p in ps) {
  201. WFCUConferenceMember *member = [[WFCUConferenceMember alloc] init];
  202. member.userId = p.userId;
  203. member.isHost = [p.userId isEqualToString:[WFCUConferenceManager sharedInstance].currentConferenceInfo.owner];
  204. member.isVideoEnabled = !p.videoMuted;
  205. member.isAudioEnabled = !p.audioMuted;
  206. member.isMe = NO;
  207. member.isAudience = p.audience;
  208. member.isAudioOnly = callSession.audioOnly;
  209. if(self.searchBar.isFirstResponder && ![self isMatchSearchText:member.userId]) {
  210. continue;
  211. }
  212. if (p.audience) {
  213. [audiences addObject:member];
  214. } else {
  215. if(member.isHost) {
  216. [self.participants insertObject:member atIndex:0];
  217. } else {
  218. [self.participants addObject:member];
  219. }
  220. }
  221. }
  222. WFCUConferenceMember *member = [[WFCUConferenceMember alloc] init];
  223. member.userId = [WFCCNetworkService sharedInstance].userId;
  224. member.isHost = [member.userId isEqualToString:[WFCUConferenceManager sharedInstance].currentConferenceInfo.owner];
  225. member.isVideoEnabled = !callSession.isVideoMuted;
  226. member.isAudioEnabled = !callSession.isAudioMuted;
  227. member.isMe = YES;
  228. member.isAudience = callSession.isAudience;
  229. member.isAudioOnly = callSession.audioOnly;
  230. if(!self.searchBar.isFirstResponder || [self isMatchSearchText:member.userId]) {
  231. if(self.participants.count && self.participants[0].isHost) {
  232. [self.participants insertObject:member atIndex:1];
  233. } else {
  234. [self.participants insertObject:member atIndex:0];
  235. }
  236. }
  237. [self.participants addObjectsFromArray:audiences];
  238. }
  239. - (BOOL)isMatchSearchText:(NSString *)userId {
  240. WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:userId refresh:NO];
  241. NSString *searchString = self.searchBar.text;
  242. BOOL matched = NO;
  243. if([userInfo.displayName containsString:searchString] || [userInfo.friendAlias containsString:searchString]) {
  244. matched = YES;
  245. } else {
  246. WFCUPinyinUtility *pu = [[WFCUPinyinUtility alloc] init];
  247. if(![pu isChinese:searchString]) {
  248. if([pu isMatch:userInfo.displayName ofPinYin:searchString] || [pu isMatch:userInfo.friendAlias ofPinYin:searchString]) {
  249. matched = YES;
  250. }
  251. }
  252. }
  253. return matched;;
  254. }
  255. - (void)onResetKeyboard:(id)sender {
  256. [self.searchBar resignFirstResponder];
  257. }
  258. - (void)onConferenceMemberChanged:(id)sender {
  259. [self loadData];
  260. [self.tableView reloadData];
  261. }
  262. - (void)onConferenceEnded:(id)sender {
  263. [self onClose:nil];
  264. }
  265. - (void)onConferenceCommandStateChanged:(id)sender {
  266. [self loadData];
  267. [self.tableView reloadData];
  268. [self updateTableViewHeader];
  269. }
  270. - (void)onConferenceMutedStateChanged:(id)sender {
  271. [self loadData];
  272. [self.tableView reloadData];
  273. }
  274. - (void)onClose:(id)sender {
  275. [self dismissViewControllerAnimated:YES completion:nil];
  276. }
  277. - (void)onInvite:(id)sender {
  278. WFCUConferenceInviteViewController *pvc = [[WFCUConferenceInviteViewController alloc] init];
  279. WFCCConferenceInviteMessageContent *invite = [[WFCCConferenceInviteMessageContent alloc] init];
  280. WFAVCallSession *currentSession = [WFAVEngineKit sharedEngineKit].currentSession;
  281. invite.callId = currentSession.callId;
  282. invite.pin = currentSession.pin;
  283. invite.audioOnly = currentSession.audioOnly;
  284. invite.host = currentSession.host;
  285. invite.title = currentSession.title;
  286. invite.desc = currentSession.desc;
  287. invite.audience = currentSession.defaultAudience;
  288. invite.advanced = currentSession.isAdvanced;
  289. invite.password = [WFCUConferenceManager sharedInstance].currentConferenceInfo.password;
  290. pvc.invite = invite;
  291. UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:pvc];
  292. [self presentViewController:navi animated:YES completion:nil];
  293. }
  294. - (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
  295. WFCUConferenceMemberTableViewCell *cell = (WFCUConferenceMemberTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"cell"];
  296. cell.member = self.participants[indexPath.row];
  297. return cell;
  298. }
  299. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  300. return 56;
  301. }
  302. - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  303. return self.participants.count;
  304. }
  305. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  306. WFCUConferenceMember *member;
  307. member = self.participants[indexPath.row];
  308. __weak typeof(self)ws = self;
  309. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"成员管理" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  310. UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:WFCString(@"Cancel") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  311. }];
  312. UIAlertAction *showProfile = [UIAlertAction actionWithTitle:@"查看用户信息" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  313. WFCUProfileTableViewController *vc = [[WFCUProfileTableViewController alloc] init];
  314. vc.userId = member.userId;
  315. vc.hidesBottomBarWhenPushed = YES;
  316. [ws.navigationController pushViewController:vc animated:YES];
  317. }];
  318. UIAlertAction *requestPublish = [UIAlertAction actionWithTitle:@"邀请发言" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  319. // [[WFCUConferenceManager sharedInstance] request:member.userId changeModel:NO inConference:[WFAVEngineKit sharedEngineKit].currentSession.callId];
  320. [[WFCUConferenceManager sharedInstance] requestMember:member.userId Mute:NO];
  321. }];
  322. UIAlertAction *requestUnpublish = [UIAlertAction actionWithTitle:@"取消发言" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  323. [[WFCUConferenceManager sharedInstance] requestMember:member.userId Mute:YES];
  324. }];
  325. UIAlertAction *requestQuit = [UIAlertAction actionWithTitle:@"移除成员" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  326. WFAVCallSession *currentSession = [WFAVEngineKit sharedEngineKit].currentSession;
  327. [currentSession kickoffParticipant:member.userId success:^{
  328. NSLog(@"kickoff success");
  329. } error:^(int error_code) {
  330. NSLog(@"kickoff error");
  331. }];
  332. }];
  333. UIAlertAction *enableAudio = [UIAlertAction actionWithTitle:@"开启音频" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  334. [[WFCUConferenceManager sharedInstance] muteAudio:member.isAudioEnabled];
  335. }];
  336. UIAlertAction *enableVideo = [UIAlertAction actionWithTitle:@"开启视频" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  337. [[WFCUConferenceManager sharedInstance] muteVideo:member.isVideoEnabled];
  338. }];
  339. UIAlertAction *enableAudioVideo = [UIAlertAction actionWithTitle:@"开启音视频" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  340. [[WFCUConferenceManager sharedInstance] muteAudioVideo:member.isVideoEnabled];
  341. }];
  342. UIAlertAction *muteAudio = [UIAlertAction actionWithTitle:@"关闭音频" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  343. [[WFCUConferenceManager sharedInstance] muteAudio:member.isAudioEnabled];
  344. }];
  345. UIAlertAction *muteVideo = [UIAlertAction actionWithTitle:@"关闭视频" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  346. [[WFCUConferenceManager sharedInstance] muteVideo:member.isVideoEnabled];
  347. }];
  348. UIAlertAction *muteAudioVideo = [UIAlertAction actionWithTitle:@"关闭音视频" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  349. [[WFCUConferenceManager sharedInstance] muteAudioVideo:member.isVideoEnabled];
  350. }];
  351. UIAlertAction *focusMember = [UIAlertAction actionWithTitle:@"设置为焦点用户" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  352. [[WFCUConferenceManager sharedInstance] requestFocus:member.userId];
  353. }];
  354. UIAlertAction *cancelFocusMember = [UIAlertAction actionWithTitle:@"取消焦点用户" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  355. [[WFCUConferenceManager sharedInstance] requestCancelFocus];
  356. }];
  357. [alertController addAction:actionCancel];
  358. [alertController addAction:showProfile];
  359. if([[WFCUConferenceManager sharedInstance].currentConferenceInfo.owner isEqualToString:[WFCCNetworkService sharedInstance].userId] && !member.isMe) {
  360. if(!member.isAudience) {
  361. [alertController addAction:requestUnpublish];
  362. } else {
  363. [alertController addAction:requestPublish];
  364. }
  365. [alertController addAction:requestQuit];
  366. } else if(member.isMe) {
  367. if(member.isAudience) {
  368. if([[WFCUConferenceManager sharedInstance].currentConferenceInfo.owner isEqualToString:[WFCCNetworkService sharedInstance].userId] || [WFCUConferenceManager sharedInstance].currentConferenceInfo.allowTurnOnMic) {
  369. [alertController addAction:enableAudio];
  370. [alertController addAction:enableVideo];
  371. [alertController addAction:enableAudioVideo];
  372. } else {
  373. [alertController addAction:enableVideo];
  374. //Todo 举手请求发言
  375. }
  376. } else {
  377. if(member.isAudioEnabled) {
  378. [alertController addAction:muteAudio];
  379. } else {
  380. [alertController addAction:enableAudio];
  381. }
  382. if(member.isVideoEnabled) {
  383. [alertController addAction:muteVideo];
  384. } else {
  385. [alertController addAction:enableVideo];
  386. }
  387. if(member.isAudioEnabled && member.isVideoEnabled) {
  388. [alertController addAction:muteAudioVideo];
  389. } else if(!member.isAudioEnabled && !member.isVideoEnabled) {
  390. [alertController addAction:enableAudioVideo];
  391. }
  392. }
  393. }
  394. if([[WFCUConferenceManager sharedInstance].currentConferenceInfo.owner isEqualToString:[WFCCNetworkService sharedInstance].userId]) {
  395. if([member.userId isEqualToString:[WFCUConferenceManager sharedInstance].currentConferenceInfo.focus]) {
  396. [alertController addAction:cancelFocusMember];
  397. } else {
  398. [alertController addAction:focusMember];
  399. }
  400. }
  401. [self presentViewController:alertController animated:YES completion:nil];
  402. }
  403. #pragma mark - UISearchBarDelegate
  404. - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
  405. return YES;
  406. }
  407. - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
  408. [self loadData];
  409. [self.tableView reloadData];
  410. self.searchBar.showsCancelButton = YES;
  411. [self updateTableViewHeader];
  412. }
  413. - (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar {
  414. return YES;
  415. }
  416. - (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar {
  417. [self loadData];
  418. [self.tableView reloadData];
  419. self.searchBar.showsCancelButton = NO;
  420. self.searchBar.text = nil;
  421. [self updateTableViewHeader];
  422. }
  423. - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
  424. [self loadData];
  425. [self.tableView reloadData];
  426. }
  427. - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
  428. }
  429. - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
  430. [self.searchBar resignFirstResponder];
  431. }
  432. @end
  433. #endif