2
0

WFCUConferenceMemberTableViewCell.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // WFCUConferenceMemberTableViewCell.m
  3. // WFChatUIKit
  4. //
  5. // Created by Tom Lee on 2021/2/15.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUConferenceMemberTableViewCell.h"
  9. #import <WFChatClient/WFCChatClient.h>
  10. #import <SDWebImage/SDWebImage.h>
  11. #import "WFCUImage.h"
  12. @interface WFCUConferenceMemberTableViewCell ()
  13. @property(nonatomic, strong)UIImageView *portraitView;
  14. @property(nonatomic, strong)UILabel *nameLabel;
  15. @property(nonatomic, strong)UILabel *extraLabel;
  16. @property(nonatomic, strong)UIImageView *audioImageView;
  17. @property(nonatomic, strong)UIImageView *videoImageView;
  18. @end
  19. @implementation WFCUConferenceMemberTableViewCell
  20. - (void)awakeFromNib {
  21. [super awakeFromNib];
  22. for (UIView *view in self.contentView.subviews) {
  23. [view removeFromSuperview];
  24. }
  25. }
  26. - (void)setMember:(WFCUConferenceMember *)member {
  27. _member = member;
  28. WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:member.userId refresh:NO];
  29. [self.portraitView sd_setImageWithURL:[NSURL URLWithString:userInfo.portrait] placeholderImage: [WFCUImage imageNamed:@"PersonalChat"]];
  30. NSString *title = userInfo.displayName;
  31. if(userInfo.friendAlias.length) {
  32. title = userInfo.friendAlias;
  33. }
  34. self.nameLabel.text = title;
  35. self.nameLabel.frame = CGRectMake(56, 8, [UIScreen mainScreen].bounds.size.width - 80-56, 18);
  36. if(member.isHost && member.isMe) {
  37. self.extraLabel.hidden = NO;
  38. self.extraLabel.text = @"(主持人,我)";
  39. } else if(member.isHost) {
  40. self.extraLabel.hidden = NO;
  41. self.extraLabel.text = @"(主持人)";
  42. } else if(member.isMe) {
  43. self.extraLabel.hidden = NO;
  44. self.extraLabel.text = @"(我)";
  45. } else {
  46. self.extraLabel.hidden = YES;
  47. self.nameLabel.frame = CGRectMake(56, 8, [UIScreen mainScreen].bounds.size.width - 80-56, 40);
  48. }
  49. if(member.isAudioOnly) {
  50. self.audioImageView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 40, 12, 24, 24);
  51. self.videoImageView.hidden = YES;
  52. } else {
  53. self.audioImageView.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 72, 12, 24, 24);
  54. self.videoImageView.hidden = NO;
  55. }
  56. BOOL videoMuted = YES;
  57. BOOL audioMuted = YES;
  58. if(!member.isAudience) {
  59. audioMuted = !member.isAudioEnabled;
  60. videoMuted = !member.isVideoEnabled;
  61. }
  62. self.audioImageView.image = [WFCUImage imageNamed:audioMuted?@"conference_audio_mute_hover":@"conference_audio"];
  63. self.videoImageView.image = [WFCUImage imageNamed:videoMuted?@"conference_video_mute_hover":@"conference_video"];
  64. }
  65. - (UIImageView *)portraitView {
  66. if (!_portraitView) {
  67. _portraitView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 40, 40)];
  68. _portraitView.layer.masksToBounds = YES;
  69. _portraitView.layer.cornerRadius = 3.f;
  70. [self.contentView addSubview:_portraitView];
  71. }
  72. return _portraitView;
  73. }
  74. - (UILabel *)nameLabel {
  75. if (!_nameLabel) {
  76. _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(56, 8, [UIScreen mainScreen].bounds.size.width - 80-56, 18)];
  77. _nameLabel.font = [UIFont systemFontOfSize:18];
  78. [self.contentView addSubview:_nameLabel];
  79. }
  80. return _nameLabel;
  81. }
  82. - (UILabel *)extraLabel {
  83. if (!_extraLabel) {
  84. _extraLabel = [[UILabel alloc] initWithFrame:CGRectMake(56, 32, [UIScreen mainScreen].bounds.size.width - 80-56, 12)];
  85. _extraLabel.textColor = [UIColor grayColor];
  86. _extraLabel.font = [UIFont systemFontOfSize:12];
  87. [self.contentView addSubview:_extraLabel];
  88. }
  89. return _extraLabel;
  90. }
  91. - (UIImageView *)videoImageView {
  92. if(!_videoImageView) {
  93. _videoImageView = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 40, 12, 24, 24)];
  94. [self.contentView addSubview:_videoImageView];
  95. }
  96. return _videoImageView;
  97. }
  98. - (UIImageView *)audioImageView {
  99. if(!_audioImageView) {
  100. _audioImageView = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 72, 12, 24, 24)];
  101. [self.contentView addSubview:_audioImageView];
  102. }
  103. return _audioImageView;
  104. }
  105. @end