// // TFBookStoreComicMaxStyleCell.m // TFReader // // Created by 谢腾飞 on 2020/12/16. // Copyright © 2020 xtfei_2011@126.com. All rights reserved. // #import "TFBookStoreComicMaxStyleCell.h" #import "TFBookStoreComicMaxItemCell.h" #import "TFBookStoreComicNormalItemCell.h" @interface TFBookStoreComicMaxStyleCell () @end @implementation TFBookStoreComicMaxStyleCell static NSString *maxItem = @"TFBookStoreComicMaxItemCell"; static NSString *normalItem = @"TFBookStoreComicNormalItemCell"; - (void)createSubviews { [super createSubviews]; self.collectionView.delegate = self; self.collectionView.dataSource = self; [self.collectionView registerClass:[TFBookStoreComicMaxItemCell class] forCellWithReuseIdentifier:maxItem]; [self.collectionView registerClass:[TFBookStoreComicNormalItemCell class] forCellWithReuseIdentifier:normalItem]; } - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { if (self.labelModel.list.count == 0) { return 0; } return 2; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { if (section == 0) { return 1; } else { return self.labelModel.list.count <= 3 ? self.labelModel.list.count : 3; } } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { TFBookStoreComicMaxItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:maxItem forIndexPath:indexPath]; cell.productionModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row]; return cell; } else { TFBookStoreComicNormalItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:normalItem forIndexPath:indexPath]; cell.productionModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row + 1]; return cell; } } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { return CGSizeMake(Comic_MaxCell_Width ,Comic_MaxCell_Height); } return CGSizeMake(Comic_NormalCell_Width ,Comic_NormalCell_Height); } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { return 10; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { TFProductionModel *production = [self.labelModel.list objectOrNilAtIndex:indexPath.row]; if (indexPath.section != 0) { production = [self.labelModel.list objectOrNilAtIndex:indexPath.row + 1]; } if (self.cellDidSelectItemBlock) { self.cellDidSelectItemBlock(production.production_id); } } @end