ASCheckoutTopView.m 2.5 KB

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