| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- //
- // FavoritesAudioCell.m
- // AIIM
- //
- // Created by qitewei on 2025/4/30.
- //
- #import "FavoritesAudioCell.h"
- #import "Masonry.h"
- #import "config.h"
- @interface FavoritesAudioCell()
- @property (nonatomic, strong) UILabel * contentLbl;
- @property (nonatomic, strong) UILabel * timeLbl;
- @property (nonatomic, strong) UIImageView * typeImageView;
- @end
- @implementation FavoritesAudioCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- [self configUI];
- }
- return self;
- }
- - (void)configUI{
- self.contentView.backgroundColor = globalColor(GCTypeDark6);
-
- [self.contentView addSubview:self.typeImageView];
- [self.typeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.size.mas_equalTo(CGSizeMake(60, 60));
- make.right.mas_equalTo(-20);
- make.top.mas_equalTo(16);
- make.bottom.mas_equalTo(-16);
- }];
-
- [self.contentView addSubview:self.timeLbl];
- [self.timeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(12);
- make.left.mas_equalTo(20);
- make.bottom.mas_equalTo(-24);
- }];
-
- [self.contentView addSubview:self.contentLbl];
- [self.contentLbl mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(14);
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(self.typeImageView.mas_left).offset(-12);
- make.bottom.mas_equalTo(self.timeLbl.mas_top).offset(-12);
- }];
- }
- - (void)setMsg:(NSDictionary *)msg{
- _msg = msg;
-
- NSString *extend = msg[@"extend"];
- NSData *data = [extend dataUsingEncoding:NSUTF8StringEncoding];
- NSError *error;
- NSDictionary *extendDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
-
- if ([msg[@"messageType"] isEqualToString:@"3"]) {
- self.typeImageView.image = kImageMake(@"audio_icon");
- if ([extendDict jk_hasKey:@"time"]) {
- self.contentLbl.text = [NSString stringWithFormat:@"%@''",extendDict[@"time"]];
- }
- }else{
- self.contentLbl.text = extendDict[@"fileName"]?:@"";
- self.typeImageView.image = kImageMake(@"file_icon");
- }
- self.timeLbl.text = msg[@"createTime"];
-
- }
- #pragma mark lazy
- - (UILabel *)contentLbl{
- if (!_contentLbl) {
- _contentLbl = [[UILabel alloc] init];
- _contentLbl.textColor = UIColor.whiteColor;
- _contentLbl.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
- }
- return _contentLbl;
- }
- - (UILabel *)timeLbl{
- if (!_timeLbl) {
- _timeLbl = [[UILabel alloc] init];
- _timeLbl.textColor = globalColor(GCTypeDark7);
- _timeLbl.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
- }
- return _timeLbl;
- }
- - (UIImageView *)typeImageView{
- if (!_typeImageView) {
- _typeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"audio_icon"]];
- }
- return _typeImageView;
- }
- @end
|