ASCheckoutTopView.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // ASCheckoutTopView.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/8.
  6. //
  7. #import "ASCheckoutTopView.h"
  8. @implementation ASCheckoutTopView
  9. - (instancetype)initWithFrame:(CGRect)frame {
  10. if (self = [super initWithFrame:frame]) {
  11. self.backgroundColor = ThemeLightColor;
  12. _countLab = [[UILabel alloc] init];
  13. _countLab.textColor = _0B0B0B;
  14. _countLab.text = @"show order items";
  15. _countLab.font = [UIFont fontWithName:Rob_Bold size:16];
  16. [self addSubview:_countLab];
  17. [_countLab mas_makeConstraints:^(MASConstraintMaker *make) {
  18. make.left.mas_equalTo(20);
  19. make.centerY.equalTo(self);
  20. }];
  21. _arrowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  22. [_arrowBtn setImage:[UIImage imageNamed:@"checkout_arrow_up"] forState:UIControlStateNormal];
  23. [_arrowBtn setImage:[UIImage imageNamed:@"checkout_arrow_down"] forState:UIControlStateSelected];
  24. _arrowBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:12];
  25. [_arrowBtn addTarget:self action:@selector(_isFlodClick:) forControlEvents:UIControlEventTouchUpInside];
  26. [_arrowBtn setTitleColor:_0B0B0B forState:0];
  27. [self addSubview:_arrowBtn];
  28. [_arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.right.mas_equalTo(-12);
  30. make.centerY.equalTo(self);
  31. make.width.mas_equalTo(35);
  32. make.height.mas_equalTo(32);
  33. }];
  34. _priceLab = [[UILabel alloc] init];
  35. _priceLab.textColor = _0B0B0B;
  36. _priceLab.font = [UIFont fontWithName:Rob_Bold size:16];
  37. [self addSubview:_priceLab];
  38. [_priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.right.equalTo(_arrowBtn.mas_left).offset(-6);
  40. make.centerY.equalTo(self);
  41. }];
  42. }
  43. return self;
  44. }
  45. - (void)setTopViewData:(NSString *)itemCount price:(NSString *)priceStr {
  46. _countLab.text = [NSString stringWithFormat:@"show order items (%@)", itemCount];
  47. _priceLab.text = priceStr;
  48. }
  49. - (void)_isFlodClick:(UIButton *)button {
  50. button.selected = !button.selected;
  51. if (self.isFlodBlock) {
  52. self.isFlodBlock(button.selected);
  53. }
  54. }
  55. @end