XYInviteFriendsHistoryCell.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // XYInviteFriendsHistoryCell.m
  3. // Starbuds
  4. //
  5. // Created by gy on 2020/6/19.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYInviteFriendsHistoryCell.h"
  9. #import "XYUserLevelLabel.h"
  10. @implementation XYInviteFriendsHistoryInfo
  11. @end
  12. @interface XYInviteFriendsHistoryCell()
  13. @property (nonatomic, strong) UIImageView *avatarImgView;
  14. @property (nonatomic, strong) UILabel *nameLab;
  15. @property (nonatomic, strong) XYUserLevelLabel *levelView;
  16. @property (nonatomic, strong) UILabel *timeLab;
  17. @property (nonatomic, strong) UILabel *lineLab;
  18. @end
  19. @implementation XYInviteFriendsHistoryCell
  20. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  21. if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  22. [self setup];
  23. }
  24. return self;
  25. }
  26. - (void)setup{
  27. self.contentView.backgroundColor = [UIColor whiteColor];
  28. [self avatarImgView];
  29. [self nameLab];
  30. [self levelView];
  31. [self timeLab];
  32. [self lineLab];
  33. }
  34. - (void)reload:(XYInviteFriendsHistoryInfo *)info{
  35. [self.avatarImgView sd_setImageWithURL:[NSURL URLWithString:info.avatar] placeholderImage:placeholderImage()];
  36. self.nameLab.text = info.name;
  37. [self.levelView configUserLevel:[info.level integerValue] shinyStatus:YES];
  38. self.timeLab.text = info.time;
  39. }
  40. - (UIImageView *)avatarImgView{
  41. if (_avatarImgView == nil) {
  42. _avatarImgView = [[UIImageView alloc] init];
  43. _avatarImgView.image = placeholderImage();
  44. _avatarImgView.contentMode = UIViewContentModeScaleAspectFill;
  45. [self.contentView addSubview:_avatarImgView];
  46. [_avatarImgView mas_makeConstraints:^(MASConstraintMaker *make) {;
  47. make.left.equalTo(self.mas_left).offset(21);
  48. make.centerY.equalTo(self.mas_centerY).offset(0);
  49. make.width.offset(48);
  50. make.height.offset(48);
  51. }];
  52. [_avatarImgView layoutIfNeeded];
  53. kViewRadius(_avatarImgView, 24);
  54. }
  55. return _avatarImgView;
  56. }
  57. - (UILabel *)nameLab{
  58. if (_nameLab == nil) {
  59. _nameLab = [[UILabel alloc] init];
  60. _nameLab.text = @"";
  61. _nameLab.textAlignment = NSTextAlignmentLeft;
  62. _nameLab.textColor = [UIColor colorWithHexString:@"#303133" alpha:1];
  63. _nameLab.font = [UIFont fontWithName:kPFSCMediumFont size:14];
  64. [_nameLab sizeToFit];
  65. [self.contentView addSubview:_nameLab];
  66. [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.equalTo(self.avatarImgView.mas_right).offset(10);
  68. make.top.equalTo(self.avatarImgView.mas_top).offset(0);
  69. }];
  70. [_nameLab layoutIfNeeded];
  71. }
  72. return _nameLab;
  73. }
  74. - (XYUserLevelLabel *)levelView{
  75. if (_levelView == nil) {
  76. _levelView = [[XYUserLevelLabel alloc] init];
  77. [_levelView sizeToFit];
  78. [self.contentView addSubview:_levelView];
  79. [_levelView mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.equalTo(self.nameLab.mas_right).offset(6);
  81. make.centerY.equalTo(self.nameLab.mas_centerY).offset(0);
  82. make.width.offset(44);
  83. make.height.offset(20);
  84. }];
  85. [_levelView layoutIfNeeded];
  86. }
  87. return _levelView;
  88. }
  89. - (UILabel *)timeLab{
  90. if (_timeLab == nil) {
  91. _timeLab = [[UILabel alloc] init];
  92. _timeLab.text = @"";
  93. _timeLab.textAlignment = NSTextAlignmentLeft;
  94. _timeLab.textColor = [UIColor colorWithHexString:@"#909399" alpha:1];
  95. _timeLab.font = [UIFont fontWithName:kPFSCFont size:12];
  96. [_timeLab sizeToFit];
  97. [self.contentView addSubview:_timeLab];
  98. [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.equalTo(self.nameLab.mas_left).offset(0);
  100. make.top.equalTo(self.nameLab.mas_bottom).offset(3);
  101. }];
  102. [_timeLab layoutIfNeeded];
  103. }
  104. return _timeLab;
  105. }
  106. - (UILabel *)lineLab{
  107. if (_lineLab == nil) {
  108. _lineLab = [[UILabel alloc] init];
  109. _lineLab.backgroundColor = [UIColor colorWithHexString:@"#EBEEF5" alpha:1];
  110. [self.contentView addSubview:_lineLab];
  111. [_lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.left.equalTo(self.mas_left).offset(0);
  113. make.top.equalTo(self.mas_bottom).offset(0);
  114. make.width.offset(kScreenWidth);
  115. make.height.offset(0.5);
  116. }];
  117. [_lineLab layoutIfNeeded];
  118. }
  119. return _lineLab;
  120. }
  121. - (void)awakeFromNib {
  122. [super awakeFromNib];
  123. // Initialization code
  124. }
  125. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  126. [super setSelected:selected animated:animated];
  127. // Configure the view for the selected state
  128. }
  129. @end