WFCUGroupTableViewCell.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // GroupTableViewCell.m
  3. // WFChat UIKit
  4. //
  5. // Created by WF Chat on 2017/9/13.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUGroupTableViewCell.h"
  9. #import "SDWebImage.h"
  10. @interface WFCUGroupTableViewCell()
  11. @property (strong, nonatomic) UIImageView *portrait;
  12. @property (strong, nonatomic) UILabel *name;
  13. @end
  14. @implementation WFCUGroupTableViewCell
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. }
  19. - (UIImageView *)portrait {
  20. if (!_portrait) {
  21. _portrait = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 40, 40)];
  22. [self.contentView addSubview:_portrait];
  23. }
  24. return _portrait;
  25. }
  26. - (UILabel *)name {
  27. if (!_name) {
  28. _name = [[UILabel alloc] initWithFrame:CGRectMake(56, 16, [UIScreen mainScreen].bounds.size.width - 64, 24)];
  29. [self.contentView addSubview:_name];
  30. }
  31. return _name;
  32. }
  33. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  34. [super setSelected:selected animated:animated];
  35. // Configure the view for the selected state
  36. }
  37. - (void)setGroupInfo:(WFCCGroupInfo *)groupInfo {
  38. _groupInfo = groupInfo;
  39. if (groupInfo.name.length == 0) {
  40. self.name.text = [NSString stringWithFormat:@"Group<%@>", groupInfo.target];
  41. } else {
  42. self.name.text = [NSString stringWithFormat:@"%@(%d)", groupInfo.name, (int)groupInfo.memberCount];
  43. }
  44. [self.portrait sd_setImageWithURL:[NSURL URLWithString:groupInfo.portrait] placeholderImage:[UIImage imageNamed:@"group_default_portrait"]];
  45. }
  46. @end