2
0

WFCUForwardMessageCell.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // ForwardMessageCell.m
  3. // WildFireChat
  4. //
  5. // Created by heavyrain lee on 2018/9/27.
  6. // Copyright © 2018 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUForwardMessageCell.h"
  9. #import "SDWebImage.h"
  10. @interface WFCUForwardMessageCell()
  11. @property (strong, nonatomic) UIImageView *portrait;
  12. @property (strong, nonatomic) UILabel *name;
  13. @end
  14. @implementation WFCUForwardMessageCell
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. }
  19. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  20. [super setSelected:selected animated:animated];
  21. // Configure the view for the selected state
  22. }
  23. - (void)setConversation:(WFCCConversation *)conversation {
  24. _conversation = conversation;
  25. NSString *name;
  26. NSString *portrait;
  27. if (conversation.type == Single_Type) {
  28. WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:conversation.target refresh:NO];
  29. if (userInfo) {
  30. name = userInfo.displayName;
  31. portrait = userInfo.portrait;
  32. } else {
  33. name = [NSString stringWithFormat:@"用户<%@>", conversation.target];
  34. }
  35. [self.portrait sd_setImageWithURL:[NSURL URLWithString:portrait] placeholderImage:[UIImage imageNamed:@"PersonalChat"]];
  36. } else if (conversation.type == Group_Type) {
  37. WFCCGroupInfo *groupInfo = [[WFCCIMService sharedWFCIMService] getGroupInfo:conversation.target refresh:NO];
  38. if (groupInfo) {
  39. name = groupInfo.name;
  40. portrait = groupInfo.portrait;
  41. } else {
  42. name = [NSString stringWithFormat:@"群组<%@>", conversation.target];
  43. }
  44. [self.portrait sd_setImageWithURL:[NSURL URLWithString:portrait] placeholderImage:[UIImage imageNamed:@"group_default_portrait"]];
  45. } else if (conversation.type == Channel_Type) {
  46. WFCCChannelInfo *channelInfo = [[WFCCIMService sharedWFCIMService] getChannelInfo:conversation.target refresh:NO];
  47. if (channelInfo) {
  48. name = channelInfo.name;
  49. portrait = channelInfo.portrait;
  50. } else {
  51. name = [NSString stringWithFormat:@"频道<%@>", conversation.target];
  52. }
  53. [self.portrait sd_setImageWithURL:[NSURL URLWithString:portrait] placeholderImage:[UIImage imageNamed:@"channel_default_portrait"]];
  54. }
  55. self.name.text = name;
  56. }
  57. - (UIImageView *)portrait {
  58. if (!_portrait) {
  59. _portrait = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 40, 40)];
  60. [self.contentView addSubview:_portrait];
  61. }
  62. return _portrait;
  63. }
  64. - (UILabel *)name {
  65. if (!_name) {
  66. _name = [[UILabel alloc] initWithFrame:CGRectMake(56, 16, [UIScreen mainScreen].bounds.size.width - 64, 24)];
  67. [self.contentView addSubview:_name];
  68. }
  69. return _name;
  70. }
  71. @end