WFCUSelectedUserTableViewCell.m 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // WFCUSelectedUserTableViewCell.m
  3. // WFChatUIKit
  4. //
  5. // Created by Zack Zhang on 2020/4/5.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUSelectedUserTableViewCell.h"
  9. #import <WFChatClient/WFCChatClient.h>
  10. #import <SDWebImage/SDWebImage.h>
  11. #import "UIColor+YH.h"
  12. #import "UIFont+YH.h"
  13. @interface WFCUSelectedUserTableViewCell()
  14. @end
  15. @implementation WFCUSelectedUserTableViewCell
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. }
  20. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  21. [super setSelected:selected animated:animated];
  22. // Configure the view for the selected state
  23. }
  24. - (void)setCheckImage:(SelectedStatusType)selectedStatus {
  25. if (selectedStatus == Disable) {
  26. self.checkImageView.image = [UIImage imageNamed:@"multi_has_selected"];
  27. }
  28. if (selectedStatus == Checked) {
  29. self.checkImageView.image = [UIImage imageNamed:@"multi_selected"];
  30. }
  31. if (selectedStatus == Unchecked) {
  32. self.checkImageView.image = [UIImage imageNamed:@"multi_unselected"];
  33. }
  34. }
  35. - (void)setSelectedUserInfo:(WFCUSelectedUserInfo *)selectedUserInfo {
  36. _selectedUserInfo = selectedUserInfo;
  37. [self setCheckImage:selectedUserInfo.selectedStatus];
  38. [self.portraitView sd_setImageWithURL:[NSURL URLWithString:[selectedUserInfo.portrait stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage: [UIImage imageNamed:@"PersonalChat"]];
  39. if (selectedUserInfo.friendAlias.length) {
  40. self.nameLabel.text = selectedUserInfo.friendAlias;
  41. } else {
  42. self.nameLabel.text = selectedUserInfo.displayName;
  43. }
  44. }
  45. - (UIImageView *)checkImageView {
  46. if (!_checkImageView) {
  47. _checkImageView = [[UIImageView alloc] initWithFrame:CGRectMake(16, 18, 20, 20)];
  48. [self.contentView addSubview:_checkImageView];
  49. }
  50. return _checkImageView;
  51. }
  52. - (UIImageView *)portraitView {
  53. if (!_portraitView) {
  54. _portraitView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 8, 40, 40)];
  55. _portraitView.layer.masksToBounds = YES;
  56. _portraitView.layer.cornerRadius = 3.f;
  57. [self.contentView addSubview:_portraitView];
  58. }
  59. return _portraitView;
  60. }
  61. - (UILabel *)nameLabel {
  62. if(!_nameLabel) {
  63. _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(50 + 40 + 12, 19, [UIScreen mainScreen].bounds.size.width - (16 + 20 + 19 + 40 + 12) - 48, 16)];
  64. _nameLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:16];
  65. _nameLabel.textColor = [UIColor colorWithHexString:@"0x1d1d1d"];
  66. [self.contentView addSubview:_nameLabel];
  67. }
  68. return _nameLabel;
  69. }
  70. @end