TXChatMusicShareCell.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. // TXChatMusicShareCell.m
  3. // TUIChat
  4. //
  5. // Created by 王智 on 2023/8/10.
  6. //
  7. #import "TXChatMusicShareCell.h"
  8. #import "TXShareMusicCellContentView.h"
  9. #import "Masonry.h"
  10. @interface TXChatMusicShareCell ()
  11. @property (nonatomic, strong) TXShareMusicCellContentView *musicContentView;
  12. @end
  13. @implementation TXChatMusicShareCell
  14. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  15. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  16. if (self) {
  17. [self configUI];
  18. }
  19. return self;
  20. }
  21. - (void)configUI {
  22. [self.container addSubview:self.musicContentView];
  23. [self.musicContentView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.left.mas_equalTo(self.container.mas_left);
  25. make.top.mas_equalTo(self.container.mas_top);
  26. make.width.mas_equalTo(260);
  27. make.bottom.mas_equalTo(self.container.mas_bottom).offset(-10);
  28. }];
  29. }
  30. - (void)fillWithData:(TXChatMusicMessage *)data {
  31. [super fillWithData:data];
  32. [self.musicContentView configWithSongName:data.songName type:data.chargeType authName:data.songAuth sendAvatar:data.teacherAvatar sendName:data.teacherName userId:data.innerMessage.sender tags:data.musicTagNames];
  33. if (data.direction == MsgDirectionIncoming) {
  34. [self.musicContentView mas_remakeConstraints:^(MASConstraintMaker *make) {
  35. make.left.mas_equalTo(self.container.mas_left);
  36. make.top.mas_equalTo(self.container.mas_top);
  37. make.width.mas_equalTo(260);
  38. make.bottom.mas_equalTo(self.container.mas_bottom).offset(-10);
  39. }];
  40. }
  41. else {
  42. [self.musicContentView mas_remakeConstraints:^(MASConstraintMaker *make) {
  43. make.right.mas_equalTo(self.container.mas_right);
  44. make.top.mas_equalTo(self.container.mas_top);
  45. make.width.mas_equalTo(260);
  46. make.bottom.mas_equalTo(self.container.mas_bottom).offset(-10);
  47. }];
  48. }
  49. }
  50. - (TXShareMusicCellContentView *)musicContentView {
  51. if (!_musicContentView) {
  52. _musicContentView = [TXShareMusicCellContentView shareInstance];
  53. }
  54. return _musicContentView;
  55. }
  56. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  57. [super setSelected:selected animated:animated];
  58. // Configure the view for the selected state
  59. }
  60. #pragma mark - TUIMessageCellProtocol
  61. + (CGSize)getContentSize:(TUIMessageCellData *)data {
  62. CGFloat width = ([UIScreen mainScreen].bounds.size.width > [UIScreen mainScreen].bounds.size.height ? [UIScreen mainScreen].bounds.size.height : [UIScreen mainScreen].bounds.size.width);
  63. return CGSizeMake(width, 100+20);
  64. }
  65. @end