1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- //
- // TXChatMusicShareCell.m
- // TUIChat
- //
- // Created by 王智 on 2023/8/10.
- //
- #import "TXChatMusicShareCell.h"
- #import "TXShareMusicCellContentView.h"
- #import "Masonry.h"
- @interface TXChatMusicShareCell ()
- @property (nonatomic, strong) TXShareMusicCellContentView *musicContentView;
- @end
- @implementation TXChatMusicShareCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
-
- if (self) {
- [self configUI];
- }
- return self;
- }
- - (void)configUI {
- [self.container addSubview:self.musicContentView];
- [self.musicContentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.container.mas_left);
- make.top.mas_equalTo(self.container.mas_top);
- make.width.mas_equalTo(260);
- make.bottom.mas_equalTo(self.container.mas_bottom).offset(-10);
- }];
- }
- - (void)fillWithData:(TXChatMusicMessage *)data {
- [super fillWithData:data];
- [self.musicContentView configWithSongName:data.songName type:data.chargeType authName:data.songAuth sendAvatar:data.teacherAvatar sendName:data.teacherName userId:data.innerMessage.sender tags:data.musicTagNames];
- if (data.direction == MsgDirectionIncoming) {
- [self.musicContentView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.container.mas_left);
- make.top.mas_equalTo(self.container.mas_top);
- make.width.mas_equalTo(260);
- make.bottom.mas_equalTo(self.container.mas_bottom).offset(-10);
- }];
- }
- else {
- [self.musicContentView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(self.container.mas_right);
- make.top.mas_equalTo(self.container.mas_top);
- make.width.mas_equalTo(260);
- make.bottom.mas_equalTo(self.container.mas_bottom).offset(-10);
- }];
- }
- }
- - (TXShareMusicCellContentView *)musicContentView {
- if (!_musicContentView) {
- _musicContentView = [TXShareMusicCellContentView shareInstance];
- }
- return _musicContentView;
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- #pragma mark - TUIMessageCellProtocol
- + (CGSize)getContentSize:(TUIMessageCellData *)data {
- CGFloat width = ([UIScreen mainScreen].bounds.size.width > [UIScreen mainScreen].bounds.size.height ? [UIScreen mainScreen].bounds.size.height : [UIScreen mainScreen].bounds.size.width);
- return CGSizeMake(width, 100+20);
- }
- @end
|