// // ASPointDetailCell.m // Asteria // // Created by iOS on 2023/6/24. // #import "ASPointDetailCell.h" @interface ASPointDetailCell () @property (nonatomic, strong) UIView *bgV; @property (nonatomic, strong) UIView *lineV; @property (nonatomic, strong) UILabel *titleLb; @property (nonatomic, strong) UILabel *pointsLb; @property (nonatomic, strong) UILabel *elsePointsLb; @property (nonatomic, strong) UILabel *dateLb; @end @implementation ASPointDetailCell - (void)setData:(ASPointDetailModel *)model { self.titleLb.text = model.comment; self.dateLb.text = model.created_at; self.pointsLb.text = [NSString stringWithFormat:@"%@ Points",model.points_delta]; self.elsePointsLb.text = [NSString stringWithFormat:@"My points:%@",model.points_balance]; } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self confgSubV]; } return self; } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (void)confgSubV { self.backgroundColor = Col_FFF; self.contentView.backgroundColor = Col_FFF; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.bgV]; [self.bgV addSubview:self.titleLb]; [self.bgV addSubview:self.pointsLb]; [self.bgV addSubview:self.elsePointsLb]; [self.bgV addSubview:self.dateLb]; [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.contentView); make.height.equalTo(@80); }]; [self.bgV addSubview:self.lineV]; [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) { make.height.equalTo(@1); make.leading.equalTo(self.bgV).offset(10); make.trailing.equalTo(self.bgV).offset(-10); make.bottom.equalTo(self.bgV); }]; [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.bgV).offset(10); make.top.equalTo(self.bgV).offset(20); make.height.greaterThanOrEqualTo(@17); }]; [self.dateLb mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.bgV).offset(10); make.height.equalTo(@14); make.bottom.equalTo(self.bgV).offset(-20); }]; [self.pointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal]; [self.pointsLb mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.bgV.mas_right).offset(-10); make.left.equalTo(self.titleLb.mas_right).offset(30); make.top.equalTo(self.titleLb); make.height.equalTo(@14); make.width.greaterThanOrEqualTo(@60); }]; [self.elsePointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal]; [self.elsePointsLb mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.bgV.mas_right).offset(-10); make.left.equalTo(self.dateLb.mas_right).offset(30); make.centerY.equalTo(self.dateLb); make.height.equalTo(@14); }]; } - (UILabel *)titleLb { if (!_titleLb) { UILabel *lb = [UILabel new]; lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:1]; lb.font = [UIFont fontWithName:Rob_Regular size:14]; lb.numberOfLines = 0; _titleLb = lb; } return _titleLb; } - (UILabel *)pointsLb { if (!_pointsLb) { UILabel *lb = [UILabel new]; lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:1]; lb.textAlignment = NSTextAlignmentRight; lb.font = [UIFont fontWithName:Rob_Regular size:12]; lb.numberOfLines = 1; [lb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal]; _pointsLb = lb; } return _pointsLb; } - (UILabel *)elsePointsLb { if (!_elsePointsLb) { UILabel *lb = [UILabel new]; lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.6]; lb.textAlignment = NSTextAlignmentRight; lb.font = [UIFont fontWithName:Rob_Regular size:12]; lb.numberOfLines = 1; _elsePointsLb = lb; } return _elsePointsLb; } - (UILabel *)dateLb { if (!_dateLb) { UILabel *lb = [UILabel new]; lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.6]; lb.textAlignment = NSTextAlignmentLeft; lb.font = [UIFont fontWithName:Rob_Regular size:12]; lb.numberOfLines = 1; _dateLb = lb; } return _dateLb; } -(UIView *)bgV { if (!_bgV) { UIView *v = [UIView new]; v.backgroundColor = Col_FFF; _bgV = v; } return _bgV; } -(UIView *)lineV { if (!_lineV) { UIView *v = [UIView new]; v.backgroundColor = [_043632 colorWithAlphaComponent:0.1]; _lineV = v; } return _lineV; } @end