// // ASCheckoutTopView.m // Asteria // // Created by xingyu on 2024/5/8. // #import "ASCheckoutTopView.h" @implementation ASCheckoutTopView - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { self.backgroundColor = ThemeLightColor; _countLab = [[UILabel alloc] init]; _countLab.textColor = _0B0B0B; _countLab.text = @"show order items"; _countLab.font = [UIFont fontWithName:Rob_Bold size:16]; [self addSubview:_countLab]; [_countLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(20); make.centerY.equalTo(self); }]; _arrowBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_arrowBtn setImage:[UIImage imageNamed:@"checkout_arrow_up"] forState:UIControlStateNormal]; [_arrowBtn setImage:[UIImage imageNamed:@"checkout_arrow_down"] forState:UIControlStateSelected]; _arrowBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:12]; [_arrowBtn addTarget:self action:@selector(_isFlodClick:) forControlEvents:UIControlEventTouchUpInside]; [_arrowBtn setTitleColor:_0B0B0B forState:0]; [self addSubview:_arrowBtn]; [_arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-12); make.centerY.equalTo(self); make.width.mas_equalTo(35); make.height.mas_equalTo(32); }]; _priceLab = [[UILabel alloc] init]; _priceLab.textColor = _0B0B0B; _priceLab.font = [UIFont fontWithName:Rob_Bold size:16]; [self addSubview:_priceLab]; [_priceLab mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(_arrowBtn.mas_left).offset(-6); make.centerY.equalTo(self); }]; } return self; } - (void)setTopViewData:(NSString *)itemCount price:(NSString *)priceStr { _countLab.text = [NSString stringWithFormat:@"show order items (%@)", itemCount]; _priceLab.text = priceStr; } - (void)_isFlodClick:(UIButton *)button { button.selected = !button.selected; if (self.isFlodBlock) { self.isFlodBlock(button.selected); } } @end