ASCheckoutTopView.m 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. [self addSubview:self.countLab];
  13. [self addSubview:self.arrowBtn];
  14. [self addSubview:self.priceLab];
  15. [self.countLab mas_makeConstraints:^(MASConstraintMaker *make) {
  16. make.left.mas_equalTo(20);
  17. make.centerY.equalTo(self);
  18. }];
  19. [self.arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  20. make.right.mas_equalTo(-12);
  21. make.centerY.equalTo(self);
  22. make.width.mas_equalTo(35);
  23. make.height.mas_equalTo(32);
  24. }];
  25. [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.right.equalTo(self.arrowBtn.mas_left).offset(-6);
  27. make.centerY.equalTo(self);
  28. }];
  29. }
  30. return self;
  31. }
  32. - (void)setTopViewData:(NSString *)itemCount price:(NSString *)priceStr {
  33. self.countLab.text = [NSString stringWithFormat:@"show order items (%@)", AS_String_valid(itemCount) ? AS_String_NotNull(itemCount) : @"0"];
  34. self.priceLab.text = priceStr;
  35. }
  36. - (void)_isFlodClick:(UIButton *)button {
  37. button.selected = !button.selected;
  38. if (self.isFlodBlock) {
  39. self.isFlodBlock(button.selected);
  40. }
  41. }
  42. - (UILabel *)countLab {
  43. if (!_countLab) {
  44. _countLab = [[UILabel alloc] init];
  45. _countLab.textColor = _0B0B0B;
  46. _countLab.text = @"show order items";
  47. _countLab.font = [UIFont fontWithName:Rob_Bold size:16];
  48. }
  49. return _countLab;
  50. }
  51. - (UIButton *)arrowBtn {
  52. if (!_arrowBtn) {
  53. _arrowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  54. [_arrowBtn setImage:[UIImage imageNamed:@"checkout_arrow_up"] forState:UIControlStateNormal];
  55. [_arrowBtn setImage:[UIImage imageNamed:@"checkout_arrow_down"] forState:UIControlStateSelected];
  56. _arrowBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:12];
  57. [_arrowBtn addTarget:self action:@selector(_isFlodClick:) forControlEvents:UIControlEventTouchUpInside];
  58. [_arrowBtn setTitleColor:_0B0B0B forState:0];
  59. }
  60. return _arrowBtn;
  61. }
  62. - (UILabel *)priceLab {
  63. if (!_priceLab) {
  64. _priceLab = [[UILabel alloc] init];
  65. _priceLab.textColor = _0B0B0B;
  66. _priceLab.font = [UIFont fontWithName:Rob_Bold size:16];
  67. }
  68. return _priceLab;
  69. }
  70. @end