123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- //
- // GoosSizeSelectCell.m
- // westkissMob
- //
- // Created by 王猛 on 2022/9/22.
- //
- #import "GoosSizeSelectCell.h"
- #import "RadioButton.h"
- @interface GoosSizeSelectCell()
- @property (nonatomic, strong) UILabel *option_nameLab;
- @property(nonatomic, strong) QMUIFloatLayoutView *floatLayoutView;
- @property (nonatomic, strong) NSMutableArray *radBtnAry;
- @end
- @implementation GoosSizeSelectCell
- - (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.selectTag = 0;
- [self.contentView addSubview:self.option_nameLab];
- [self.contentView addSubview:self.floatLayoutView];
- [self.option_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(18);
- make.top.mas_equalTo(20);
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(-20);
- }];
- [self.floatLayoutView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.option_nameLab.mas_bottom).offset(10);
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10);
- make.bottom.mas_equalTo(-10);
- }];
- }
- -(void)change_Option_nameLabAlignmentLeft{
- self.option_nameLab.textAlignment = NSTextAlignmentLeft;
- }
- - (void)configData:(id)Data{
- OptionsModel *optionM = (OptionsModel *)Data;
- self.optionModel = optionM;
- self.option_nameLab.text = [NSString stringWithFormat:@"%@",optionM.product_sku];
- while (self.floatLayoutView.subviews.count) {
- [self.floatLayoutView.subviews.lastObject removeFromSuperview];
- }
- [self.radBtnAry removeAllObjects];
- for (int i =0; i<optionM.values.count; i++) {
- OptionsValuesM *valueModel = optionM.values[i];
- RadioButton *btn = [[RadioButton alloc]init];
- btn.model = valueModel;
- btn.layer.cornerRadius =2;
- btn.clipsToBounds = YES;
- btn.layer.borderColor = [UIColor colorWithHexString:@"#E6E6E6"].CGColor;
- btn.layer.borderWidth = 0.5;
- btn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
- btn.tag = i;
- [btn addTarget:self action:@selector(xxx_onRadioButtonValueChanged:) forControlEvents:UIControlEventValueChanged];
- [btn setTitle:[NSString stringWithFormat:@" %@ ",valueModel.title] forState:UIControlStateNormal];
- [btn setTitleColor:[UIColor colorWithHexString:@"#0B0B0B"] forState:UIControlStateNormal];
- [btn setTitleColor:[UIColor colorWithHexString:@"#000000"] forState:UIControlStateSelected];
-
- [self.floatLayoutView addSubview:btn];
- [self.radBtnAry addObject:btn];
- }
- [self.radBtnAry[0] setGroupButtons:self.radBtnAry];
- [self.radBtnAry[optionM.optionSelectTag] setSelected:YES];
- [self tool_changeSelcetBtn:self.radBtnAry[optionM.optionSelectTag]];
- self.floatLayoutView.frame = CGRectMake(10, CGRectGetMaxY(self.option_nameLab.frame)+10, KScreenWidth-20, INFINITY);
- [self.floatLayoutView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(self.floatLayoutView.mj_h);
- }];
- }
- -(void)xxx_onRadioButtonValueChanged:(RadioButton *)btn{
- if(btn.selected){
- [self tool_changeSelcetBtn:btn];
- OptionsValuesM *valueM =btn.model;
- self.optionModel.optionSelectTag = btn.tag;
- if (self.currencyparameterClose) {
- self.currencyparameterClose(btn.tag, valueM);
- }
- }else{ //select == NO
- [self tool_changenomralbtn:btn];
- }
- }
- -(void)tool_changenomralbtn:(UIButton *)btn{
- btn.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
- btn.layer.borderColor = [UIColor colorWithHexString:@"#E6E6E6"].CGColor;
- btn.layer.borderWidth = 1;
- btn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
- }
- -(void)tool_changeSelcetBtn:(UIButton *)btn{
- btn.backgroundColor = ThemeColor;
- btn.layer.borderWidth = 0.0;
- btn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:14];
- }
- -(UILabel *)option_nameLab{
- if(!_option_nameLab){
- _option_nameLab = [[UILabel alloc]init];
- _option_nameLab.frame =CGRectMake(20, 20, KScreenWidth-40, 18);
- _option_nameLab.font = [UIFont fontWithName:Rob_Bold size:14];
- _option_nameLab.textAlignment = NSTextAlignmentLeft;
- }
- return _option_nameLab;
- }
- -(NSMutableArray *)radBtnAry{
- if (!_radBtnAry) {
- _radBtnAry = [[NSMutableArray alloc]init];
- }
- return _radBtnAry;
- }
- -(QMUIFloatLayoutView *)floatLayoutView{
- if(!_floatLayoutView){
- _floatLayoutView = [[QMUIFloatLayoutView alloc]init];
- _floatLayoutView.itemMargins = UIEdgeInsetsMake(5, 5, 5, 5);
- _floatLayoutView.padding = UIEdgeInsetsMake(5, 5, 5, 5);
- CGFloat minWithd = (KScreenWidth-20-50)/4;
- _floatLayoutView.minimumItemSize = CGSizeMake(minWithd, 32);// 以每行最少4个按钮作为最小宽度
- }
- return _floatLayoutView;
- }
- - (void)upadteFlotSubviews{
- }
- @end
|