FavoritesPictrueCell.m 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // FavoritesPictrueCell.m
  3. // AIIM
  4. //
  5. // Created by qitewei on 2025/4/30.
  6. //
  7. #import "FavoritesPictrueCell.h"
  8. #import "CryptoAES.h"
  9. @interface FavoritesPictrueCell()
  10. @property (nonatomic, strong) UILabel * contentLbl;
  11. @property (nonatomic, strong) UILabel * timeLbl;
  12. @property (nonatomic, strong) UIImageView * contentImageView;
  13. @end
  14. @implementation FavoritesPictrueCell
  15. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  16. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  17. [self configUI];
  18. }
  19. return self;
  20. }
  21. - (void)configUI{
  22. self.contentView.backgroundColor = globalColor(GCTypeDark6);
  23. [self.contentView addSubview:self.timeLbl];
  24. [self.timeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.height.mas_equalTo(12);
  26. make.left.mas_equalTo(20);
  27. make.bottom.mas_equalTo(-24);
  28. }];
  29. [self.contentView addSubview:self.contentLbl];
  30. CGFloat contentMaxWidth = [UIScreen mainScreen].bounds.size.width-152;
  31. [self.contentLbl mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.height.mas_equalTo(14);
  33. make.width.mas_lessThanOrEqualTo(contentMaxWidth);
  34. make.left.mas_equalTo(20);
  35. make.bottom.mas_equalTo(self.timeLbl.mas_top).offset(-12);
  36. }];
  37. [self.contentView addSubview:self.contentImageView];
  38. [self.contentImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.size.mas_equalTo(CGSizeMake(60, 60));
  40. make.left.mas_equalTo(self.contentLbl.mas_right).offset(12);
  41. make.top.mas_equalTo(16);
  42. make.bottom.mas_equalTo(-16);
  43. }];
  44. }
  45. - (void)setMsg:(NSDictionary *)msg{
  46. _msg = msg;
  47. NSString *extend = msg[@"extend"];
  48. NSData *data = [extend dataUsingEncoding:NSUTF8StringEncoding];
  49. NSError *error;
  50. NSDictionary *extendDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
  51. self.contentLbl.text = extendDict[@"fileName"]?:@"";
  52. [self.contentImageView sd_setImageWithURL:getURL(extendDict[@"url"]) placeholderImage:kImageMake(@"downloadfile")];
  53. self.timeLbl.text = msg[@"createTime"];
  54. }
  55. #pragma mark lazy
  56. - (UILabel *)contentLbl{
  57. if (!_contentLbl) {
  58. _contentLbl = [[UILabel alloc] init];
  59. _contentLbl.textColor = UIColor.whiteColor;
  60. _contentLbl.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
  61. }
  62. return _contentLbl;
  63. }
  64. - (UILabel *)timeLbl{
  65. if (!_timeLbl) {
  66. _timeLbl = [[UILabel alloc] init];
  67. _timeLbl.textColor = globalColor(GCTypeDark7);
  68. _timeLbl.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
  69. }
  70. return _timeLbl;
  71. }
  72. - (UIImageView *)contentImageView{
  73. if (!_contentImageView) {
  74. _contentImageView = [[UIImageView alloc] init];
  75. _contentImageView.layer.cornerRadius = 10.f;
  76. _contentImageView.clipsToBounds = YES;
  77. _contentImageView.contentMode = UIViewContentModeScaleAspectFill;
  78. }
  79. return _contentImageView;
  80. }
  81. @end