ASOrderDetailsPriceCell.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // ASOrderDetailsPriceCell.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/16.
  6. //
  7. #import "ASOrderDetailsPriceCell.h"
  8. @interface ASOrderDetailsPriceCell()
  9. @property (nonatomic, strong) UIView *backView;
  10. @end
  11. @implementation ASOrderDetailsPriceCell
  12. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  13. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  14. self.selectionStyle = UITableViewCellSelectionStyleNone;
  15. self.contentView.backgroundColor = _F8F8F8;
  16. _backView = [[UIView alloc] init];
  17. _backView.backgroundColor = Col_FFF;
  18. TT_ViewRadius(_backView, 3);
  19. [self.contentView addSubview:_backView];
  20. [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.left.mas_equalTo(10);
  22. make.top.mas_equalTo(5);
  23. make.right.mas_equalTo(-10);
  24. make.bottom.mas_equalTo(-20);
  25. }];
  26. }
  27. return self;
  28. }
  29. - (void)setOrderModel:(ASOrderDetailsModel *)orderModel {
  30. _orderModel = orderModel;
  31. NSMutableArray *listArr = [[NSMutableArray alloc] initWithCapacity:1];
  32. if (AS_String_valid(_orderModel.subtotal)) {
  33. NSDictionary *dic = @{@"title":@"Subtotal", @"value":_orderModel.subtotal};
  34. [listArr addObject:dic];
  35. }
  36. if (AS_String_valid(_orderModel.shipping_tax_amount)) {
  37. NSDictionary *dic = @{@"title":@"Shipping", @"value":_orderModel.shipping_tax_amount};
  38. [listArr addObject:dic];
  39. }
  40. if (AS_String_valid(_orderModel.discount_amount)) {
  41. NSDictionary *dic = @{@"title":@"Gift Card", @"value":_orderModel.discount_amount};
  42. [listArr addObject:dic];
  43. }
  44. UILabel *tempLab = nil;
  45. for (int i = 0; i < listArr.count; i++) {
  46. NSDictionary *dic = listArr[i];
  47. UILabel *rightLab = [UILabel labelCreateWithText:dic[@"value"] font:[UIFont fontWithName:Rob_Regular size:14] textColor:_0B0B0B];
  48. rightLab.textAlignment = NSTextAlignmentRight;
  49. [_backView addSubview:rightLab];
  50. if (i == 0) {
  51. [rightLab mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.mas_equalTo(20);
  53. make.right.mas_equalTo(-10);
  54. make.height.mas_equalTo(19);
  55. }];
  56. } else {
  57. [rightLab mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.top.mas_equalTo(tempLab.mas_bottom).offset(10);
  59. make.right.mas_equalTo(-10);
  60. make.height.mas_equalTo(19);
  61. }];
  62. }
  63. tempLab = rightLab;
  64. UILabel *leftLab = [UILabel labelCreateWithText:dic[@"title"] font:[UIFont fontWithName:Rob_Regular size:14] textColor:_0B0B0B];
  65. [_backView addSubview:leftLab];
  66. [leftLab mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.centerY.mas_equalTo(rightLab);;
  68. make.left.mas_equalTo(10);
  69. make.right.equalTo(rightLab.mas_left).offset(-6);
  70. }];
  71. }
  72. UIView *lineView1 = [[UIView alloc] init];
  73. lineView1.backgroundColor = _F4F4F4;
  74. [_backView addSubview:lineView1];
  75. [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.mas_equalTo(10);
  77. make.right.mas_equalTo(-10);
  78. make.height.mas_equalTo(1);
  79. make.top.equalTo(tempLab.mas_bottom).offset(20);
  80. // make.bottom.mas_equalTo(-20);
  81. }];
  82. UILabel *grandRightLab = [UILabel labelCreateWithText:AS_String_NotNull(_orderModel.grand_total) font:[UIFont fontWithName:Rob_Bold size:24] textColor:Col_000];
  83. grandRightLab.textAlignment = NSTextAlignmentRight;
  84. [_backView addSubview:grandRightLab];
  85. [grandRightLab mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.top.mas_equalTo(lineView1.mas_bottom).offset(15);
  87. make.right.mas_equalTo(-10);
  88. make.height.mas_equalTo(30);
  89. make.bottom.mas_equalTo(-15);
  90. }];
  91. UILabel *grandLeftLab = [UILabel labelCreateWithText:@"Grand Total" font:[UIFont fontWithName:Rob_Bold size:14] textColor:Col_000];
  92. [_backView addSubview:grandLeftLab];
  93. [grandLeftLab mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.centerY.mas_equalTo(grandRightLab);;
  95. make.left.mas_equalTo(10);
  96. make.right.equalTo(grandRightLab.mas_left).offset(-6);
  97. }];
  98. }
  99. @end