WFCUNewFriendTableViewCell.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // NewFriendTableViewCell.m
  3. // WFChat UIKit
  4. //
  5. // Created by WF Chat on 2017/10/28.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUNewFriendTableViewCell.h"
  9. #import <WFChatClient/WFCChatClient.h>
  10. #import "SDWebImage.h"
  11. @interface WFCUNewFriendTableViewCell ()
  12. @end
  13. @implementation WFCUNewFriendTableViewCell
  14. - (void)awakeFromNib {
  15. [super awakeFromNib];
  16. // Initialization code
  17. }
  18. - (void)onFriendRequestUpdated:(NSNotification *)notification {
  19. [self updateBubbleNumber];
  20. }
  21. - (void)updateBubbleNumber {
  22. int unreadCount = [[WFCCIMService sharedWFCIMService] getUnreadFriendRequestStatus];
  23. if (unreadCount) {
  24. self.bubbleView.hidden = NO;
  25. [self.bubbleView setBubbleTipNumber:unreadCount];
  26. } else {
  27. self.bubbleView.hidden = YES;
  28. }
  29. }
  30. - (void)refresh {
  31. [[NSNotificationCenter defaultCenter] removeObserver:self];
  32. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onFriendRequestUpdated:) name:kFriendRequestUpdated object:nil];
  33. [self updateBubbleNumber];
  34. }
  35. - (BubbleTipView *)bubbleView {
  36. if (!_bubbleView) {
  37. if (self.portraitView) {
  38. _bubbleView = [[BubbleTipView alloc] initWithParentView:self.contentView];
  39. _bubbleView.hidden = YES;
  40. }
  41. }
  42. return _bubbleView;
  43. }
  44. - (UIImageView *)portraitView {
  45. if (!_portraitView) {
  46. _portraitView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 36, 36)];
  47. _portraitView.layer.masksToBounds = YES;
  48. _portraitView.layer.cornerRadius = 3.f;
  49. [self.contentView addSubview:_portraitView];
  50. }
  51. return _portraitView;
  52. }
  53. - (UILabel *)nameLabel {
  54. if (!_nameLabel) {
  55. _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(56, 19, [UIScreen mainScreen].bounds.size.width - 64, 16)];
  56. _nameLabel.font = [UIFont systemFontOfSize:16];
  57. [self.contentView addSubview:_nameLabel];
  58. }
  59. return _nameLabel;
  60. }
  61. - (void)dealloc {
  62. [[NSNotificationCenter defaultCenter] removeObserver:self];
  63. }
  64. @end