NIMTeamMemberCardHeaderCell.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // NIMTeamMemberCardHeaderCell.m
  3. // NIMKit
  4. //
  5. // Created by chris on 16/5/10.
  6. // Copyright © 2016年 NetEase. All rights reserved.
  7. //
  8. #import "NIMTeamMemberCardHeaderCell.h"
  9. #import "NIMAvatarImageView.h"
  10. #import "NIMUsrInfoData.h"
  11. #import "NIMCommonTableData.h"
  12. #import "NIMKit.h"
  13. #import "UIView+NIM.h"
  14. #import "NIMKitUtil.h"
  15. @interface NIMTeamMemberCardHeaderCell()
  16. @property (nonatomic,strong) NIMAvatarImageView *avatarView;
  17. @property (nonatomic,strong) UILabel *nickLabel;
  18. @end
  19. @implementation NIMTeamMemberCardHeaderCell
  20. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  21. {
  22. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  23. if (self) {
  24. [self addSubview:self.avatarView];
  25. [self addSubview:self.nickLabel];
  26. }
  27. return self;
  28. }
  29. - (void)refreshData:(NIMCommonTableRow *)rowData tableView:(UITableView *)tableView;{
  30. NIMUsrInfo *user = rowData.extraInfo[@"user"];
  31. NIMTeam *team = rowData.extraInfo[@"team"];
  32. NSURL *avatarURL;
  33. if (user.info.avatarUrlString.length) {
  34. avatarURL = [NSURL URLWithString:user.info.avatarUrlString];
  35. }
  36. [self.avatarView nim_setImageWithURL:avatarURL placeholderImage:user.info.avatarImage];
  37. NIMSession *session = [NIMSession session:team.teamId type:NIMSessionTypeTeam];
  38. self.nickLabel.text = [NIMKitUtil showNick:user.info.infoId inSession:session];
  39. [self.nickLabel sizeToFit];
  40. self.userInteractionEnabled = NO;
  41. }
  42. - (void)layoutSubviews
  43. {
  44. [super layoutSubviews];
  45. self.avatarView.nim_top = 52.f;
  46. self.avatarView.nim_centerX = self.nim_width * .5f;
  47. self.nickLabel.nim_centerX = self.avatarView.nim_centerX;
  48. self.nickLabel.nim_top = self.avatarView.nim_bottom + 10;
  49. }
  50. - (NIMAvatarImageView *)avatarView
  51. {
  52. if (!_avatarView) {
  53. _avatarView = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(125, 52, 70, 70)];
  54. _avatarView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
  55. }
  56. return _avatarView;
  57. }
  58. - (UILabel *)nickLabel
  59. {
  60. if (!_nickLabel) {
  61. _nickLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  62. _nickLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
  63. _nickLabel.font = [UIFont systemFontOfSize:17];
  64. _nickLabel.textColor = [UIColor colorWithRed:51.0 / 255 green:51.0 / 255 blue:51.0 / 255 alpha:1.0];
  65. }
  66. return _nickLabel;
  67. }
  68. @end