ASPointDetailCell.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. //
  2. // ASPointDetailCell.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/6/24.
  6. //
  7. #import "ASPointDetailCell.h"
  8. @interface ASPointDetailCell ()
  9. @property (nonatomic, strong) UIView *bgV;
  10. @property (nonatomic, strong) UIView *lineV;
  11. @property (nonatomic, strong) UILabel *titleLb;
  12. @property (nonatomic, strong) UILabel *pointsLb;
  13. @property (nonatomic, strong) UILabel *elsePointsLb;
  14. @property (nonatomic, strong) UILabel *dateLb;
  15. @end
  16. @implementation ASPointDetailCell
  17. - (void)setData:(ASPointDetailModel *)model {
  18. self.titleLb.text = model.event_data;
  19. self.dateLb.text = model.created_at;
  20. self.pointsLb.text = [NSString stringWithFormat:@"%@ Points",model.points_delta];
  21. self.elsePointsLb.text = [NSString stringWithFormat:@"My points:%@",model.points_balance];
  22. }
  23. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  24. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  25. if (self) {
  26. [self confgSubV];
  27. }
  28. return self;
  29. }
  30. - (void)awakeFromNib {
  31. [super awakeFromNib];
  32. // Initialization code
  33. }
  34. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  35. [super setSelected:selected animated:animated];
  36. // Configure the view for the selected state
  37. }
  38. - (void)confgSubV {
  39. self.backgroundColor = Col_FFF;
  40. self.contentView.backgroundColor = Col_FFF;
  41. self.selectionStyle = UITableViewCellSelectionStyleNone;
  42. [self.contentView addSubview:self.bgV];
  43. [self.bgV addSubview:self.titleLb];
  44. [self.bgV addSubview:self.pointsLb];
  45. [self.bgV addSubview:self.elsePointsLb];
  46. [self.bgV addSubview:self.dateLb];
  47. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.edges.equalTo(self.contentView);
  49. make.height.equalTo(@80);
  50. }];
  51. [self.bgV addSubview:self.lineV];
  52. [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.height.equalTo(@1);
  54. make.leading.equalTo(self.bgV).offset(10);
  55. make.trailing.equalTo(self.bgV).offset(-10);
  56. make.bottom.equalTo(self.bgV);
  57. }];
  58. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.left.equalTo(self.bgV).offset(10);
  60. make.top.equalTo(self.bgV).offset(20);
  61. make.height.greaterThanOrEqualTo(@17);
  62. }];
  63. [self.dateLb mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.left.equalTo(self.bgV).offset(10);
  65. make.height.equalTo(@14);
  66. make.bottom.equalTo(self.bgV).offset(-20);
  67. }];
  68. [self.pointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  69. [self.pointsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.right.equalTo(self.bgV.mas_right).offset(-10);
  71. make.left.equalTo(self.titleLb.mas_right).offset(30);
  72. make.top.equalTo(self.titleLb);
  73. make.height.equalTo(@14);
  74. make.width.greaterThanOrEqualTo(@60);
  75. }];
  76. [self.elsePointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  77. [self.elsePointsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.right.equalTo(self.bgV.mas_right).offset(-10);
  79. make.left.equalTo(self.dateLb.mas_right).offset(30);
  80. make.centerY.equalTo(self.dateLb);
  81. make.height.equalTo(@14);
  82. }];
  83. }
  84. - (UILabel *)titleLb {
  85. if (!_titleLb) {
  86. UILabel *lb = [UILabel new];
  87. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:1];
  88. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  89. lb.numberOfLines = 0;
  90. _titleLb = lb;
  91. }
  92. return _titleLb;
  93. }
  94. - (UILabel *)pointsLb {
  95. if (!_pointsLb) {
  96. UILabel *lb = [UILabel new];
  97. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:1];
  98. lb.textAlignment = NSTextAlignmentRight;
  99. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  100. lb.numberOfLines = 1;
  101. [lb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  102. _pointsLb = lb;
  103. }
  104. return _pointsLb;
  105. }
  106. - (UILabel *)elsePointsLb {
  107. if (!_elsePointsLb) {
  108. UILabel *lb = [UILabel new];
  109. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.6];
  110. lb.textAlignment = NSTextAlignmentRight;
  111. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  112. lb.numberOfLines = 1;
  113. _elsePointsLb = lb;
  114. }
  115. return _elsePointsLb;
  116. }
  117. - (UILabel *)dateLb {
  118. if (!_dateLb) {
  119. UILabel *lb = [UILabel new];
  120. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.6];
  121. lb.textAlignment = NSTextAlignmentLeft;
  122. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  123. lb.numberOfLines = 1;
  124. _dateLb = lb;
  125. }
  126. return _dateLb;
  127. }
  128. -(UIView *)bgV {
  129. if (!_bgV) {
  130. UIView *v = [UIView new];
  131. v.backgroundColor = Col_FFF;
  132. _bgV = v;
  133. }
  134. return _bgV;
  135. }
  136. -(UIView *)lineV {
  137. if (!_lineV) {
  138. UIView *v = [UIView new];
  139. v.backgroundColor = [_043632 colorWithAlphaComponent:0.1];
  140. _lineV = v;
  141. }
  142. return _lineV;
  143. }
  144. @end