123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- //
- // ASCheckoutShipMethodCell.m
- // Asteria
- //
- // Created by xingyu on 2024/5/9.
- //
- #import "ASCheckoutShipMethodCell.h"
- @implementation ASCheckoutShipMethodData
- @end
- @interface ASCheckoutShipMethodCell()
- @property (nonatomic, strong) UIView *shipMethodView;
- @property (nonatomic, strong) UILabel *shipMethodLab;
- @property (nonatomic, strong) UILabel *shipPriceLab;
- @end
- @implementation ASCheckoutShipMethodCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (void)setupSubviewS {
-
- self.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
-
- _shipMethodView = [[UIView alloc] init];
- TT_ViewRadius(_shipMethodView, 4);
- _shipMethodView.backgroundColor = [UIColor whiteColor];
- [self.contentView addSubview:_shipMethodView];
- [_shipMethodView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.top.mas_equalTo(10);
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(50);
- make.bottom.mas_equalTo(0);
- }];
- }
- - (void)configData:(id)Data{
- ASCheckoutShipMethodData *model = (ASCheckoutShipMethodData *)Data;
-
- self.cellData = model;
-
- float floatY = 0;
-
- for (int i = 0; i < model.shipMethodArray.count; i++) {
- ASCheckoutShipMethodModel *shipModel = model.shipMethodArray[i];
-
- ASShipMethodItem *shipItem = [[ASShipMethodItem alloc] initWithFrame:CGRectMake(0, floatY, KScreenWidth - 20, 53)];
- [_shipMethodView addSubview:shipItem];
-
- [shipItem setShipItemData:shipModel symbol:model.shipmethodSymbol];
- shipItem.selectBtn.tag = i;
- [shipItem.selectBtn addTarget:self action:@selector(_selectShipMethod:) forControlEvents:UIControlEventTouchUpInside];
-
-
- floatY = floatY + 53;
-
- }
-
- [_shipMethodView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(floatY);
- }];
-
- }
- - (void)_selectShipMethod:(UIButton *)button {
-
- if (button.selected) {
- return;
- }
-
- button.selected = !button.selected;
-
-
- if (self.currencyparameterClose) {
- self.currencyparameterClose(button.tag, self.cellData);
- }
- }
- @end
- @interface ASShipMethodItem()
- @property (nonatomic, strong) UILabel *shipMethodLab;
- @property (nonatomic, strong) UILabel *shipPriceLab;
- @end
- @implementation ASShipMethodItem
- - (instancetype)initWithFrame:(CGRect)frame {
- if (self = [super initWithFrame:frame]) {
-
- _selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_selectBtn setImage:[UIImage imageNamed:@"base_radio_unselect"] forState:UIControlStateNormal];
- [_selectBtn setImage:[UIImage imageNamed:@"base_radio_select"] forState:UIControlStateSelected];
-
- [self addSubview:_selectBtn];
- [_selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-10);
- make.width.height.mas_equalTo(26);
- make.centerY.equalTo(self);
- }];
-
- _shipPriceLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Bold size:14] textColor:_0B0B0B];
- _shipPriceLab.textAlignment = NSTextAlignmentRight;
- _shipPriceLab.adjustsFontSizeToFitWidth = YES;
- [self addSubview:_shipPriceLab];
- [_shipPriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(_selectBtn.mas_left).offset(-8);
- make.centerY.mas_equalTo(self);
- }];
-
- _shipMethodLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Bold size:14] textColor:_0B0B0B];
- [self addSubview:_shipMethodLab];
- [_shipMethodLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(_shipPriceLab.mas_left).offset(-8);
- make.centerY.mas_equalTo(self);
- make.height.mas_equalTo(18);
- make.bottom.mas_equalTo(-20);
- }];
-
-
- }
- return self;
- }
- - (void)setShipItemData:(ASCheckoutShipMethodModel *)shipModel symbol:(NSString *)symbol {
-
- _shipMethodLab.text = [NSString stringWithFormat:@"%@ %@", shipModel.method_title, shipModel.carrier_title];
- _shipPriceLab.text = [NSString stringWithFormat:@"%@%@", symbol, shipModel.amount];
-
- _selectBtn.selected = shipModel.isSelect;
- }
- @end
|