// // ASOrderDetailsPriceCell.m // Asteria // // Created by xingyu on 2024/5/16. // #import "ASOrderDetailsPriceCell.h" @interface ASOrderDetailsPriceCell() @property (nonatomic, strong) UIView *backView; @end @implementation ASOrderDetailsPriceCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.contentView.backgroundColor = _F8F8F8; _backView = [[UIView alloc] init]; _backView.backgroundColor = Col_FFF; TT_ViewRadius(_backView, 3); [self.contentView addSubview:_backView]; [_backView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.mas_equalTo(5); make.right.mas_equalTo(-10); make.bottom.mas_equalTo(-20); }]; } return self; } - (void)setOrderModel:(ASOrderDetailsModel *)orderModel { _orderModel = orderModel; NSMutableArray *listArr = [[NSMutableArray alloc] initWithCapacity:1]; if (AS_String_valid(_orderModel.subtotal)) { NSDictionary *dic = @{@"title":@"Subtotal", @"value":_orderModel.subtotal}; [listArr addObject:dic]; } if (AS_String_valid(_orderModel.shipping_tax_amount)) { NSDictionary *dic = @{@"title":@"Shipping", @"value":_orderModel.shipping_tax_amount}; [listArr addObject:dic]; } if (AS_String_valid(_orderModel.discount_amount)) { NSDictionary *dic = @{@"title":@"Gift Card", @"value":_orderModel.discount_amount}; [listArr addObject:dic]; } UILabel *tempLab = nil; for (int i = 0; i < listArr.count; i++) { NSDictionary *dic = listArr[i]; UILabel *rightLab = [UILabel labelCreateWithText:dic[@"value"] font:[UIFont fontWithName:Rob_Regular size:14] textColor:_0B0B0B]; rightLab.textAlignment = NSTextAlignmentRight; [_backView addSubview:rightLab]; if (i == 0) { [rightLab mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(20); make.right.mas_equalTo(-10); make.height.mas_equalTo(19); }]; } else { [rightLab mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(tempLab.mas_bottom).offset(10); make.right.mas_equalTo(-10); make.height.mas_equalTo(19); }]; } tempLab = rightLab; UILabel *leftLab = [UILabel labelCreateWithText:dic[@"title"] font:[UIFont fontWithName:Rob_Regular size:14] textColor:_0B0B0B]; [_backView addSubview:leftLab]; [leftLab mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(rightLab);; make.left.mas_equalTo(10); make.right.equalTo(rightLab.mas_left).offset(-6); }]; } UIView *lineView1 = [[UIView alloc] init]; lineView1.backgroundColor = _F4F4F4; [_backView addSubview:lineView1]; [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.right.mas_equalTo(-10); make.height.mas_equalTo(1); make.top.equalTo(tempLab.mas_bottom).offset(20); // make.bottom.mas_equalTo(-20); }]; UILabel *grandRightLab = [UILabel labelCreateWithText:AS_String_NotNull(_orderModel.grand_total) font:[UIFont fontWithName:Rob_Bold size:24] textColor:Col_000]; grandRightLab.textAlignment = NSTextAlignmentRight; [_backView addSubview:grandRightLab]; [grandRightLab mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(lineView1.mas_bottom).offset(15); make.right.mas_equalTo(-10); make.height.mas_equalTo(30); make.bottom.mas_equalTo(-15); }]; UILabel *grandLeftLab = [UILabel labelCreateWithText:@"Grand Total" font:[UIFont fontWithName:Rob_Bold size:14] textColor:Col_000]; [_backView addSubview:grandLeftLab]; [grandLeftLab mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(grandRightLab);; make.left.mas_equalTo(10); make.right.equalTo(grandRightLab.mas_left).offset(-6); }]; } @end