ASPointDetailCell.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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.right.equalTo(self.bgV).offset(-120);
  62. make.height.greaterThanOrEqualTo(@17);
  63. }];
  64. [self.dateLb mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.equalTo(self.titleLb.mas_bottom).offset(12);
  66. make.left.equalTo(self.bgV).offset(10);
  67. make.height.equalTo(@14);
  68. make.bottom.equalTo(self.bgV).offset(-20);
  69. }];
  70. [self.pointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  71. [self.pointsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.right.equalTo(self.bgV.mas_right).offset(-10);
  73. make.left.equalTo(self.titleLb.mas_right).offset(30);
  74. make.top.equalTo(self.titleLb);
  75. make.height.equalTo(@14);
  76. make.width.mas_equalTo(@100);
  77. }];
  78. [self.elsePointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  79. [self.elsePointsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.right.equalTo(self.bgV.mas_right).offset(-10);
  81. make.left.equalTo(self.dateLb.mas_right).offset(30);
  82. make.centerY.equalTo(self.dateLb);
  83. make.height.equalTo(@14);
  84. }];
  85. }
  86. - (UILabel *)titleLb {
  87. if (!_titleLb) {
  88. UILabel *lb = [UILabel new];
  89. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:1];
  90. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  91. lb.numberOfLines = 0;
  92. _titleLb = lb;
  93. }
  94. return _titleLb;
  95. }
  96. - (UILabel *)pointsLb {
  97. if (!_pointsLb) {
  98. UILabel *lb = [UILabel new];
  99. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:1];
  100. lb.textAlignment = NSTextAlignmentRight;
  101. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  102. lb.numberOfLines = 1;
  103. [lb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  104. _pointsLb = lb;
  105. _pointsLb.adjustsFontSizeToFitWidth = YES;
  106. }
  107. return _pointsLb;
  108. }
  109. - (UILabel *)elsePointsLb {
  110. if (!_elsePointsLb) {
  111. UILabel *lb = [UILabel new];
  112. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.6];
  113. lb.textAlignment = NSTextAlignmentRight;
  114. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  115. lb.numberOfLines = 1;
  116. _elsePointsLb = lb;
  117. }
  118. return _elsePointsLb;
  119. }
  120. - (UILabel *)dateLb {
  121. if (!_dateLb) {
  122. UILabel *lb = [UILabel new];
  123. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.6];
  124. lb.textAlignment = NSTextAlignmentLeft;
  125. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  126. lb.numberOfLines = 1;
  127. _dateLb = lb;
  128. }
  129. return _dateLb;
  130. }
  131. -(UIView *)bgV {
  132. if (!_bgV) {
  133. UIView *v = [UIView new];
  134. v.backgroundColor = Col_FFF;
  135. _bgV = v;
  136. }
  137. return _bgV;
  138. }
  139. -(UIView *)lineV {
  140. if (!_lineV) {
  141. UIView *v = [UIView new];
  142. v.backgroundColor = [_043632 colorWithAlphaComponent:0.1];
  143. _lineV = v;
  144. }
  145. return _lineV;
  146. }
  147. @end