WFCFavoriteFileCell.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // WFCFavoriteUnknownCell.m
  3. // WildFireChat
  4. //
  5. // Created by Tom Lee on 2020/11/1.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCFavoriteFileCell.h"
  9. #import <WFChatUIKit/WFChatUIKit.h>
  10. @interface WFCFavoriteFileCell ()
  11. @property(nonatomic, strong)UIImageView *iconView;
  12. @property(nonatomic, strong)UILabel *nameLabel;
  13. @property(nonatomic, strong)UILabel *infoLabel;
  14. @end
  15. @implementation WFCFavoriteFileCell
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. }
  20. - (void)setFavoriteItem:(WFCUFavoriteItem *)favoriteItem {
  21. [super setFavoriteItem:favoriteItem];
  22. [self iconView];
  23. self.nameLabel.text = favoriteItem.title;
  24. NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:[favoriteItem.data dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:nil];
  25. long size = [dict[@"size"] longValue];
  26. self.infoLabel.text = [WFCUUtilities formatSizeLable:size];
  27. }
  28. + (CGFloat)contentHeight:(WFCUFavoriteItem *)favoriteItem {
  29. return 56;
  30. }
  31. - (UIImageView *)iconView {
  32. if (!_iconView) {
  33. _iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 56, 56)];
  34. _iconView.image = [UIImage imageNamed:@"file_icon"];
  35. _iconView.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.f];
  36. [self.contentArea addSubview:_iconView];
  37. }
  38. return _iconView;
  39. }
  40. - (UILabel *)nameLabel {
  41. if (!_nameLabel) {
  42. _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(64, 4, self.bounds.size.width-72, 20)];
  43. _nameLabel.font = [UIFont systemFontOfSize:18];
  44. [self.contentArea addSubview:_nameLabel];
  45. }
  46. return _nameLabel;
  47. }
  48. - (UILabel *)infoLabel {
  49. if (!_infoLabel) {
  50. _infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(64, 30, self.bounds.size.width-80, 18)];
  51. _infoLabel.font = [UIFont systemFontOfSize:14];
  52. _infoLabel.textColor = [UIColor grayColor];
  53. [self.contentArea addSubview:_infoLabel];
  54. }
  55. return _infoLabel;
  56. }
  57. @end