WFCUContactSelectTableViewCell.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // ContactSelectTableViewCell.m
  3. // WFChat UIKit
  4. //
  5. // Created by WF Chat on 2017/10/25.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUContactSelectTableViewCell.h"
  9. #import <WFChatClient/WFCChatClient.h>
  10. #import <SDWebImage/SDWebImage.h>
  11. #import "UIColor+YH.h"
  12. #import "UIFont+YH.h"
  13. @interface WFCUContactSelectTableViewCell()
  14. @property(nonatomic, strong)UIImageView *checkImageView;
  15. @property(nonatomic, strong)UIImageView *portraitView;
  16. @end
  17. @implementation WFCUContactSelectTableViewCell
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. // Initialization code
  21. }
  22. - (UIImageView *)checkImageView {
  23. if (!_checkImageView) {
  24. _checkImageView = [[UIImageView alloc] initWithFrame:CGRectMake(16, 18, 20, 20)];
  25. [self.contentView addSubview:_checkImageView];
  26. }
  27. return _checkImageView;
  28. }
  29. - (UIImageView *)portraitView {
  30. if (!_portraitView) {
  31. _portraitView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 8, 40, 40)];
  32. _portraitView.layer.masksToBounds = YES;
  33. _portraitView.layer.cornerRadius = 3.f;
  34. [self.contentView addSubview:_portraitView];
  35. }
  36. return _portraitView;
  37. }
  38. - (UILabel *)nameLabel {
  39. if(!_nameLabel) {
  40. _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(50 + 40 + 12, 19, [UIScreen mainScreen].bounds.size.width - (16 + 20 + 19 + 40 + 12) - 48, 16)];
  41. _nameLabel.font = [UIFont pingFangSCWithWeight:FontWeightStyleRegular size:16];
  42. _nameLabel.textColor = [UIColor colorWithHexString:@"0x1d1d1d"];
  43. [self.contentView addSubview:_nameLabel];
  44. }
  45. return _nameLabel;
  46. }
  47. - (void)setDisabled:(BOOL)disabled {
  48. _disabled = disabled;
  49. if (disabled) {
  50. [self.checkImageView setAlpha:0.5];
  51. } else {
  52. [self.checkImageView setAlpha:1.f];
  53. }
  54. }
  55. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  56. [super setSelected:selected animated:animated];
  57. // Configure the view for the selected state
  58. }
  59. - (void)setChecked:(BOOL)checked {
  60. _checked = checked;
  61. if (self.multiSelect) {
  62. if (checked) {
  63. self.checkImageView.image = [UIImage imageNamed:@"multi_selected"];
  64. } else {
  65. self.checkImageView.image = [UIImage imageNamed:@"multi_unselected"];
  66. }
  67. } else {
  68. if (checked) {
  69. self.checkImageView.image = [UIImage imageNamed:@"single_selected"];
  70. } else {
  71. self.checkImageView.image = [UIImage imageNamed:@"single_unselected"];
  72. }
  73. }
  74. }
  75. - (void)setMultiSelect:(BOOL)multiSelect {
  76. _multiSelect = multiSelect;
  77. }
  78. - (void)setFriendUid:(NSString *)friendUid {
  79. _friendUid = friendUid;
  80. WFCCUserInfo *friendInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:friendUid refresh:NO];
  81. [self.portraitView sd_setImageWithURL:[NSURL URLWithString:[friendInfo.portrait stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage: [UIImage imageNamed:@"PersonalChat"]];
  82. if (friendInfo.friendAlias.length) {
  83. self.nameLabel.text = friendInfo.friendAlias;
  84. } else {
  85. self.nameLabel.text = friendInfo.displayName;
  86. }
  87. }
  88. @end