WFCUGroupTableViewCell.m 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/SDWebImage.h>
  10. #import "UIFont+YH.h"
  11. #import "UIColor+YH.h"
  12. @interface WFCUGroupTableViewCell()
  13. @property (strong, nonatomic) UIImageView *portrait;
  14. @property (strong, nonatomic) UILabel *name;
  15. @end
  16. @implementation WFCUGroupTableViewCell
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. // Initialization code
  20. }
  21. - (void)layoutSubviews {
  22. [super layoutSubviews];
  23. _portrait.frame = CGRectMake(18, (self.frame.size.height - 40) / 2.0, 40, 40);
  24. _name.frame = CGRectMake(18 + 40 + 9, (self.frame.size.height - 17) / 2.0, [UIScreen mainScreen].bounds.size.width - (18 + 40 + 9), 17);
  25. }
  26. - (UIImageView *)portrait {
  27. if (!_portrait) {
  28. _portrait = [UIImageView new];
  29. _portrait.layer.cornerRadius = 4.0f;
  30. _portrait.layer.masksToBounds = YES;
  31. }
  32. return _portrait;
  33. }
  34. - (UILabel *)name {
  35. if (!_name) {
  36. _name = [UILabel new];
  37. _name.textColor = [UIColor colorWithHexString:@"0x1d1d1d"];
  38. _name.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:17];
  39. [self.contentView addSubview:_name];
  40. }
  41. return _name;
  42. }
  43. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  44. [super setSelected:selected animated:animated];
  45. // Configure the view for the selected state
  46. }
  47. - (void)setGroupInfo:(WFCCGroupInfo *)groupInfo {
  48. _groupInfo = groupInfo;
  49. if (groupInfo.name.length == 0) {
  50. self.name.text = WFCString(@"GroupChat");
  51. } else {
  52. self.name.text = [NSString stringWithFormat:@"%@(%d)", groupInfo.name, (int)groupInfo.memberCount];
  53. }
  54. [self.portrait sd_setImageWithURL:[NSURL URLWithString:[groupInfo.portrait stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage:[UIImage imageNamed:@"group_default_portrait"]];
  55. }
  56. @end