WFCUContactSelectTableViewCell.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.h"
  11. @interface WFCUContactSelectTableViewCell()
  12. @property(nonatomic, strong)UIImageView *checkImageView;
  13. @property(nonatomic, strong)UIImageView *portraitView;
  14. @property(nonatomic, strong)UILabel *nameLabel;
  15. @end
  16. @implementation WFCUContactSelectTableViewCell
  17. - (void)awakeFromNib {
  18. [super awakeFromNib];
  19. // Initialization code
  20. }
  21. - (UIImageView *)checkImageView {
  22. if (!_checkImageView) {
  23. _checkImageView = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 44, 18, 20, 20)];
  24. [self.contentView addSubview:_checkImageView];
  25. }
  26. return _checkImageView;
  27. }
  28. - (UIImageView *)portraitView {
  29. if (!_portraitView) {
  30. _portraitView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 40, 40)];
  31. _portraitView.layer.masksToBounds = YES;
  32. _portraitView.layer.cornerRadius = 3.f;
  33. [self.contentView addSubview:_portraitView];
  34. }
  35. return _portraitView;
  36. }
  37. - (UILabel *)nameLabel {
  38. if(!_nameLabel) {
  39. _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(56, 19, [UIScreen mainScreen].bounds.size.width - 56 - 48, 16)];
  40. _nameLabel.font = [UIFont systemFontOfSize:16];
  41. [self.contentView addSubview:_nameLabel];
  42. }
  43. return _nameLabel;
  44. }
  45. - (void)setDisabled:(BOOL)disabled {
  46. _disabled = disabled;
  47. if (disabled) {
  48. [self.checkImageView setAlpha:0.5];
  49. } else {
  50. [self.checkImageView setAlpha:1.f];
  51. }
  52. }
  53. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  54. [super setSelected:selected animated:animated];
  55. // Configure the view for the selected state
  56. }
  57. - (void)setChecked:(BOOL)checked {
  58. _checked = checked;
  59. if (self.multiSelect) {
  60. if (checked) {
  61. self.checkImageView.image = [UIImage imageNamed:@"multi_selected"];
  62. } else {
  63. self.checkImageView.image = [UIImage imageNamed:@"multi_unselected"];
  64. }
  65. } else {
  66. if (checked) {
  67. self.checkImageView.image = [UIImage imageNamed:@"single_selected"];
  68. } else {
  69. self.checkImageView.image = [UIImage imageNamed:@"single_unselected"];
  70. }
  71. }
  72. }
  73. - (void)setMultiSelect:(BOOL)multiSelect {
  74. _multiSelect = multiSelect;
  75. }
  76. - (void)setFriendUid:(NSString *)friendUid {
  77. _friendUid = friendUid;
  78. WFCCUserInfo *friendInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:friendUid refresh:NO];
  79. [self.portraitView sd_setImageWithURL:[NSURL URLWithString:friendInfo.portrait] placeholderImage: [UIImage imageNamed:@"PersonalChat"]];
  80. self.nameLabel.text = friendInfo.displayName;
  81. }
  82. @end