GoosSizeSelectCell.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // GoosSizeSelectCell.m
  3. // westkissMob
  4. //
  5. // Created by 王猛 on 2022/9/22.
  6. //
  7. #import "GoosSizeSelectCell.h"
  8. #import "RadioButton.h"
  9. @interface GoosSizeSelectCell()
  10. @property (nonatomic, strong) UILabel *option_nameLab;
  11. @property(nonatomic, strong) QMUIFloatLayoutView *floatLayoutView;
  12. @property (nonatomic, strong) NSMutableArray *radBtnAry;
  13. @end
  14. @implementation GoosSizeSelectCell
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. }
  19. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  20. [super setSelected:selected animated:animated];
  21. // Configure the view for the selected state
  22. }
  23. - (void)setupSubviewS{
  24. self.selectTag = 0;
  25. [self.contentView addSubview:self.option_nameLab];
  26. [self.contentView addSubview:self.floatLayoutView];
  27. [self.option_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.height.mas_equalTo(18);
  29. make.top.mas_equalTo(20);
  30. make.left.mas_equalTo(20);
  31. make.right.mas_equalTo(-20);
  32. }];
  33. [self.floatLayoutView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.top.mas_equalTo(self.option_nameLab.mas_bottom).offset(10);
  35. make.left.mas_equalTo(10);
  36. make.right.mas_equalTo(-10);
  37. make.bottom.mas_equalTo(-10);
  38. }];
  39. }
  40. -(void)change_Option_nameLabAlignmentLeft{
  41. self.option_nameLab.textAlignment = NSTextAlignmentLeft;
  42. }
  43. - (void)configData:(id)Data{
  44. OptionsModel *optionM = (OptionsModel *)Data;
  45. self.optionModel = optionM;
  46. self.option_nameLab.text = [NSString stringWithFormat:@"%@",optionM.product_sku];
  47. while (self.floatLayoutView.subviews.count) {
  48. [self.floatLayoutView.subviews.lastObject removeFromSuperview];
  49. }
  50. [self.radBtnAry removeAllObjects];
  51. for (int i =0; i<optionM.values.count; i++) {
  52. OptionsValuesM *valueModel = optionM.values[i];
  53. RadioButton *btn = [[RadioButton alloc]init];
  54. btn.model = valueModel;
  55. btn.layer.cornerRadius =2;
  56. btn.clipsToBounds = YES;
  57. btn.layer.borderColor = [UIColor colorWithHexString:@"#E6E6E6"].CGColor;
  58. btn.layer.borderWidth = 0.5;
  59. btn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
  60. btn.tag = i;
  61. [btn addTarget:self action:@selector(xxx_onRadioButtonValueChanged:) forControlEvents:UIControlEventValueChanged];
  62. [btn setTitle:[NSString stringWithFormat:@" %@ ",valueModel.title] forState:UIControlStateNormal];
  63. [btn setTitleColor:[UIColor colorWithHexString:@"#0B0B0B"] forState:UIControlStateNormal];
  64. [btn setTitleColor:[UIColor colorWithHexString:@"#000000"] forState:UIControlStateSelected];
  65. [self.floatLayoutView addSubview:btn];
  66. [self.radBtnAry addObject:btn];
  67. }
  68. [self.radBtnAry[0] setGroupButtons:self.radBtnAry];
  69. [self.radBtnAry[optionM.optionSelectTag] setSelected:YES];
  70. [self tool_changeSelcetBtn:self.radBtnAry[optionM.optionSelectTag]];
  71. self.floatLayoutView.frame = CGRectMake(10, CGRectGetMaxY(self.option_nameLab.frame)+10, KScreenWidth-20, INFINITY);
  72. [self.floatLayoutView mas_updateConstraints:^(MASConstraintMaker *make) {
  73. make.height.mas_equalTo(self.floatLayoutView.mj_h);
  74. }];
  75. }
  76. -(void)xxx_onRadioButtonValueChanged:(RadioButton *)btn{
  77. if(btn.selected){
  78. [self tool_changeSelcetBtn:btn];
  79. OptionsValuesM *valueM =btn.model;
  80. self.optionModel.optionSelectTag = btn.tag;
  81. if (self.currencyparameterClose) {
  82. self.currencyparameterClose(btn.tag, valueM);
  83. }
  84. }else{ //select == NO
  85. [self tool_changenomralbtn:btn];
  86. }
  87. }
  88. -(void)tool_changenomralbtn:(UIButton *)btn{
  89. btn.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
  90. btn.layer.borderColor = [UIColor colorWithHexString:@"#E6E6E6"].CGColor;
  91. btn.layer.borderWidth = 1;
  92. btn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
  93. }
  94. -(void)tool_changeSelcetBtn:(UIButton *)btn{
  95. btn.backgroundColor = ThemeColor;
  96. btn.layer.borderWidth = 0.0;
  97. btn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:14];
  98. }
  99. -(UILabel *)option_nameLab{
  100. if(!_option_nameLab){
  101. _option_nameLab = [[UILabel alloc]init];
  102. _option_nameLab.frame =CGRectMake(20, 20, KScreenWidth-40, 18);
  103. _option_nameLab.font = [UIFont fontWithName:Rob_Bold size:14];
  104. _option_nameLab.textAlignment = NSTextAlignmentLeft;
  105. }
  106. return _option_nameLab;
  107. }
  108. -(NSMutableArray *)radBtnAry{
  109. if (!_radBtnAry) {
  110. _radBtnAry = [[NSMutableArray alloc]init];
  111. }
  112. return _radBtnAry;
  113. }
  114. -(QMUIFloatLayoutView *)floatLayoutView{
  115. if(!_floatLayoutView){
  116. _floatLayoutView = [[QMUIFloatLayoutView alloc]init];
  117. _floatLayoutView.itemMargins = UIEdgeInsetsMake(5, 5, 5, 5);
  118. _floatLayoutView.padding = UIEdgeInsetsMake(5, 5, 5, 5);
  119. CGFloat minWithd = (KScreenWidth-20-50)/4;
  120. _floatLayoutView.minimumItemSize = CGSizeMake(minWithd, 32);// 以每行最少4个按钮作为最小宽度
  121. }
  122. return _floatLayoutView;
  123. }
  124. - (void)upadteFlotSubviews{
  125. }
  126. @end