| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 | ////  ASHomeBestSellCell.m//  Asteria////  Created by iOS on 2023/6/6.//#import "ASHomeBestSellCell.h"#import "HomeFlashDealSubCollectCell.h"@interface ASHomeBestSellCell ()<UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource>@property (nonatomic, strong) UIView *bottomV;@property (nonatomic, strong) UIButton *moreBt;@end@implementation ASHomeBestSellCell- (void)setModel:(ASHomeMainListModel *)model {    _model = model;    self.titleLb.text = model.title;    CGFloat lineH = (KScreenWidth-30)/2 + productHWithOutImg;    NSInteger line = model.productList.count/2;    line = line + (model.productList.count%2);    CGFloat collH = (lineH + 10)*line + 10;    [self.collectV mas_remakeConstraints:^(MASConstraintMaker *make) {        make.left.equalTo(self.contentView).offset(0);        make.right.equalTo(self.contentView).offset(-0);        make.height.equalTo([NSNumber numberWithFloat:collH]);        make.top.equalTo(self.titleLb.mas_bottom).offset(20);    }];    }- (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}- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];    if (self) {        [self loadSubV];    }    return self;}- (void)loadSubV {    self.selectionStyle = UITableViewCellSelectionStyleNone;    self.contentView.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];    self.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];            [self.contentView addSubview:self.titleLb];    [self.contentView addSubview:self.collectV];    [self.contentView addSubview:self.bottomV];    [self.bottomV addSubview:self.moreBt];                [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.equalTo(self.contentView).offset(25);        make.centerX.equalTo(self.contentView);        make.left.greaterThanOrEqualTo(self.contentView).offset(20);        make.height.equalTo(@30);    }];        CGFloat collH = (KScreenWidth-30)/2 + productHWithOutImg;    [self.collectV mas_makeConstraints:^(MASConstraintMaker *make) {        make.left.equalTo(self.contentView).offset(0);        make.right.equalTo(self.contentView).offset(-0);        make.height.equalTo([NSNumber numberWithFloat:collH]);        make.top.equalTo(self.titleLb.mas_bottom).offset(20);    }];    [self.bottomV mas_makeConstraints:^(MASConstraintMaker *make) {        make.centerX.equalTo(self.contentView);        make.height.equalTo(@(20+36));        make.leading.equalTo(self.contentView);        make.top.equalTo(self.collectV.mas_bottom).offset(20);        make.bottom.equalTo(self.contentView).offset(-40);    }];    [self.moreBt mas_makeConstraints:^(MASConstraintMaker *make) {        make.width.equalTo(@200);        make.height.equalTo(@36);        make.centerX.equalTo(self.bottomV);        make.centerY.equalTo(self.bottomV);    }];       }// MARK: - delegate datasource- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {        if (self.productClick) {                ASProductBaseModel *m = self.model.productList[indexPath.row];        self.productClick(indexPath.row, m);    }    }// MARK: - UICollectionViewDataSource- (nonnull __kindof UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {        HomeFlashDealSubCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeFlashDealSubCollectCell" forIndexPath:indexPath];    if (self.model.productList.count <= indexPath.row)    {        return cell;    }       ASProductBaseModel *m = self.model.productList[indexPath.row];    cell.model = m;    cell.contView.addCartBt.hidden = true;    return cell;}- (NSInteger)collectionView:(nonnull UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {    return self.model.productList.count;}- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {        CGFloat marg = 10;    CGFloat w = (KScreenWidth-3*marg)/2;    CGFloat collH = (KScreenWidth-30)/2 + productHWithOutImg;    return CGSizeMake(w, collH);}-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {    return 10;}-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {    return 10;}- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {    return UIEdgeInsetsMake(10, 10, 10, 10);}- (UILabel *)titleLb {    if (!_titleLb) {        UILabel *lb = [[UILabel alloc] init];        lb.textColor = [UIColor blackColor];        lb.font = [UIFont fontWithName:Rob_Bold size:24];        lb.textAlignment = NSTextAlignmentCenter;        _titleLb = lb;    }    return _titleLb;}-(UICollectionView *)collectV {    if (!_collectV) {        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];        layout.sectionInset = UIEdgeInsetsMake(10, 0, 10, 0);        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;        CGFloat collH = (KScreenWidth-30)/2 + 126;        layout.itemSize = CGSizeMake((KScreenWidth - 30)/2, collH);        UICollectionView *collV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, collH) collectionViewLayout:layout];        collV.backgroundColor = [UIColor whiteColor];        collV.alwaysBounceHorizontal = true;        collV.scrollEnabled = false;        collV.delegate = self;        collV.dataSource = self;        collV.showsHorizontalScrollIndicator = false;        [collV registerClass:[HomeFlashDealSubCollectCell class] forCellWithReuseIdentifier:@"HomeFlashDealSubCollectCell"];        _collectV = collV;    }    return  _collectV;}-(UIView *)bottomV {    if (!_bottomV) {        UIView *v = [UIView baseV];        v.backgroundColor = Col_FFF;        v.clipsToBounds = true;        _bottomV = v;    }    return _bottomV;}- (UIButton *)moreBt {    if (!_moreBt) {        UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];        [bt setTitle:@"VIEW MORE" forState:UIControlStateNormal];        [bt setTitleColor:Col_000 forState:UIControlStateNormal];        bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];        bt.layer.cornerRadius = 4;        bt.layer.borderColor = Col_000.CGColor;        bt.layer.borderWidth = 1;        bt.layer.masksToBounds = true;        _moreBt = bt;    }    return _moreBt;}@end
 |